From 94c5b9f7d471a810235f64160e863d3a8f949537 Mon Sep 17 00:00:00 2001 From: Nurhan Turgut Date: Thu, 9 Jan 2020 14:58:01 -0800 Subject: [PATCH] modify test_runner.dart for windows to fix test build errors (#15326) --- lib/web_ui/dev/test_runner.dart | 26 +++++++++++++++++++++++++- lib/web_ui/dev/utils.dart | 3 +++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index d21aa65fd..f6ccebdf2 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -60,6 +60,12 @@ class TestCommand extends Command { _copyTestFontsIntoWebUi(); await _buildHostPage(); + if (io.Platform.isWindows) { + // On Dart 2.7 or greater, it gives an error for not + // recognized "pub" version and asks for "pub" get. + // See: https://github.com/dart-lang/sdk/issues/39738 + await _runPubGet(); + } final List targets = this.targets.map((t) => FilePath.fromCwd(t)).toList(); @@ -162,7 +168,9 @@ class TestCommand extends Command { // Not a test file at all. Skip. continue; } - if(!path.split(testFilePath.relativeToWebUi).contains('golden_tests')) { + if (!path + .split(testFilePath.relativeToWebUi) + .contains('golden_tests')) { unitTestFiles.add(testFilePath); } } @@ -179,6 +187,22 @@ class TestCommand extends Command { } } + Future _runPubGet() async { + final int exitCode = await runProcess( + environment.pubExecutable, + [ + 'get', + ], + workingDirectory: environment.webUiRootDir.path, + ); + + if (exitCode != 0) { + io.stderr + .writeln('Failed to run pub get. Exited with exit code $exitCode'); + io.exit(1); + } + } + Future _buildHostPage() async { final String hostDartPath = path.join('lib', 'static', 'host.dart'); final io.File hostDartFile = io.File(path.join( diff --git a/lib/web_ui/dev/utils.dart b/lib/web_ui/dev/utils.dart index c7d5e70ce..f891bd358 100644 --- a/lib/web_ui/dev/utils.dart +++ b/lib/web_ui/dev/utils.dart @@ -43,6 +43,9 @@ Future runProcess( executable, arguments, workingDirectory: workingDirectory, + // Running the process in a system shell for Windows. Otherwise + // the process is not able to get Dart from path. + runInShell: io.Platform.isWindows, mode: io.ProcessStartMode.inheritStdio, ); final int exitCode = await process.exitCode; -- GitLab