Skip to content

Commit a87c563

Browse files
johnniwinthercommit-bot@chromium.org
authored and
commit-bot@chromium.org
committed
[test_runner] Make update_static_error_tests work on Windows
Change-Id: Ia2e9a1b122953d1565f5829932cd21705a725f45 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125972 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
1 parent fc47953 commit a87c563

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

pkg/test_runner/tool/update_static_error_tests.dart

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Future<void> _processFile(File file,
142142
bool insertCfe}) async {
143143
stdout.write("${file.path}...");
144144
var source = file.readAsStringSync();
145-
var testFile = TestFile.parse(Path("."), file.path, source);
145+
var testFile = TestFile.parse(Path("."), file.absolute.path, source);
146146

147147
var options = testFile.sharedOptions.toList();
148148
if (testFile.experiments.isNotEmpty) {
@@ -152,14 +152,14 @@ Future<void> _processFile(File file,
152152
var errors = <StaticError>[];
153153
if (insertAnalyzer) {
154154
stdout.write("\r${file.path} (Running analyzer...)");
155-
errors.addAll(await _runAnalyzer(file.path, options));
155+
errors.addAll(await _runAnalyzer(file.absolute.path, options));
156156
}
157157

158158
if (insertCfe) {
159159
// Clear the previous line.
160160
stdout.write("\r${file.path} ");
161161
stdout.write("\r${file.path} (Running CFE...)");
162-
errors.addAll(await _runCfe(file.path, options));
162+
errors.addAll(await _runCfe(file.absolute.path, options));
163163
}
164164

165165
errors = StaticError.simplify(errors);
@@ -182,11 +182,15 @@ Future<List<StaticError>> _runAnalyzer(
182182
// TODO(rnystrom): Running the analyzer command line each time is very slow.
183183
// Either import the analyzer as a library, or at least invoke it in a batch
184184
// mode.
185-
var result = await Process.run("sdk/bin/dartanalyzer$shellScriptExtension", [
186-
...options,
187-
"--format=machine",
188-
path,
189-
]);
185+
var result = await Process.run(
186+
Platform.isWindows
187+
? "sdk\\bin\\dartanalyzer.bat"
188+
: "sdk/bin/dartanalyzer",
189+
[
190+
...options,
191+
"--format=machine",
192+
path,
193+
]);
190194
var errors = <StaticError>[];
191195
AnalysisCommandOutput.parseErrors(result.stderr as String, errors);
192196
return errors;
@@ -197,19 +201,17 @@ Future<List<StaticError>> _runCfe(String path, List<String> options) async {
197201
// TODO(rnystrom): Running the CFE command line each time is slow and wastes
198202
// time generating code, which we don't care about. Import it as a library or
199203
// at least run it in batch mode.
200-
var result = await Process.run("sdk/bin/dart", [
204+
var result = await Process.run(
205+
Platform.isWindows ? "sdk\\bin\\dart.bat" : "sdk/bin/dart", [
201206
"pkg/front_end/tool/_fasta/compile.dart",
202207
...options,
203208
"--verify",
209+
"-o",
210+
"dev:null", // Output is only created for file URIs.
204211
path,
205212
]);
206213

207214
var errors = <StaticError>[];
208215
FastaCommandOutput.parseErrors(result.stdout as String, errors);
209-
210-
// Running the above command generates a dill file next to the test, which we
211-
// don't want, so delete it.
212-
await File("$path.dill").delete();
213-
214216
return errors;
215217
}

0 commit comments

Comments
 (0)