From eec6a7f9b6e94353a8eaa81ade1e9a14911e5abb Mon Sep 17 00:00:00 2001 From: Nurhan Turgut Date: Wed, 8 Jan 2020 16:08:26 -0800 Subject: [PATCH 1/3] modify test_runner.dart for windows to fix test build errors --- lib/web_ui/dev/test_runner.dart | 20 ++++++++++++++++++++ lib/web_ui/dev/utils.dart | 1 + 2 files changed, 21 insertions(+) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index d21aa65fd2a70..b53145ba1f8f1 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -60,6 +60,10 @@ class TestCommand extends Command { _copyTestFontsIntoWebUi(); await _buildHostPage(); + if(io.Platform.isWindows) { + // Error on windows if not run. + await _runPubGet(); + } final List targets = this.targets.map((t) => FilePath.fromCwd(t)).toList(); @@ -179,6 +183,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 c7d5e70ce59cd..8534b9375de68 100644 --- a/lib/web_ui/dev/utils.dart +++ b/lib/web_ui/dev/utils.dart @@ -43,6 +43,7 @@ Future runProcess( executable, arguments, workingDirectory: workingDirectory, + runInShell: io.Platform.isWindows, mode: io.ProcessStartMode.inheritStdio, ); final int exitCode = await process.exitCode; From 888cb30d75d847fb6f6035d783fa1d9e24bc3bd0 Mon Sep 17 00:00:00 2001 From: Nurhan Turgut Date: Thu, 9 Jan 2020 08:51:59 -0800 Subject: [PATCH 2/3] addressing PR comments --- lib/web_ui/dev/test_runner.dart | 14 +++++++++----- lib/web_ui/dev/utils.dart | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index b53145ba1f8f1..f6ccebdf2a2bd 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -60,8 +60,10 @@ class TestCommand extends Command { _copyTestFontsIntoWebUi(); await _buildHostPage(); - if(io.Platform.isWindows) { - // Error on windows if not run. + 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(); } @@ -166,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); } } @@ -193,8 +197,8 @@ class TestCommand extends Command { ); if (exitCode != 0) { - io.stderr.writeln( - 'Failed to run pub get. Exited with exit code $exitCode'); + io.stderr + .writeln('Failed to run pub get. Exited with exit code $exitCode'); io.exit(1); } } diff --git a/lib/web_ui/dev/utils.dart b/lib/web_ui/dev/utils.dart index 8534b9375de68..3df28a6c15826 100644 --- a/lib/web_ui/dev/utils.dart +++ b/lib/web_ui/dev/utils.dart @@ -43,6 +43,8 @@ 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, ); From 5140bee684170742d218e79390e444d1d34c5367 Mon Sep 17 00:00:00 2001 From: Nurhan Turgut Date: Thu, 9 Jan 2020 09:06:04 -0800 Subject: [PATCH 3/3] fixing trailing space in the comment --- lib/web_ui/dev/utils.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web_ui/dev/utils.dart b/lib/web_ui/dev/utils.dart index 3df28a6c15826..f891bd35876e5 100644 --- a/lib/web_ui/dev/utils.dart +++ b/lib/web_ui/dev/utils.dart @@ -43,7 +43,7 @@ Future runProcess( executable, arguments, workingDirectory: workingDirectory, - // Running the process in a system shell for Windows. Otherwise + // 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,