From de4dea71d7e5d22e24e68fe31ca0a078a4f993b9 Mon Sep 17 00:00:00 2001 From: Jonas Termansen Date: Wed, 23 Jan 2019 12:46:06 +0000 Subject: [PATCH] [infra] Add Windows support to test.dart. Change-Id: I1070b630f14a7a0b00d828f0fae47ec80d09d292 Reviewed-on: https://dart-review.googlesource.com/c/90464 Reviewed-by: Johnni Winther --- tools/test.dart | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/test.dart b/tools/test.dart index cd956ef59cd..79c9793c580 100755 --- a/tools/test.dart +++ b/tools/test.dart @@ -48,9 +48,10 @@ String simpleShellSingleQuote(String string) { } /// Runs a process and exits likewise if the process exits non-zero. -Future runProcess( - String executable, List arguments) async { - final processResult = await Process.run(executable, arguments); +Future runProcess(String executable, List arguments, + {bool runInShell = false}) async { + final processResult = + await Process.run(executable, arguments, runInShell: runInShell); if (processResult.exitCode != 0) { final command = ([executable]..addAll(arguments)).map(simpleShellSingleQuote).join(" "); @@ -63,9 +64,10 @@ Future runProcess( /// Runs a process and exits likewise if the process exits non-zero, but let the /// child process inherit out stdio handles. Future runProcessInheritStdio( - String executable, List arguments) async { + String executable, List arguments, + {bool runInShell = false}) async { final process = await Process.start(executable, arguments, - mode: ProcessStartMode.inheritStdio); + mode: ProcessStartMode.inheritStdio, runInShell: runInShell); final exitCode = await process.exitCode; final processResult = new ProcessResult(process.pid, exitCode, "", ""); if (processResult.exitCode != 0) { @@ -138,7 +140,8 @@ Future findMergeBase( return commit; } final arguments = ["merge-base", "$remote/$branch", "HEAD"]; - final result = await Process.run("git", arguments); + final result = + await Process.run("git", arguments, runInShell: Platform.isWindows); if (result.exitCode != 0) { throw new Exception("Failed to run: git ${arguments.join(' ')}\n" "stdout:\n${result.stdout}\n" @@ -273,7 +276,9 @@ ${parser.usage}"""); print("".padLeft(80, "=")); print("$stepName: Running tests"); print("".padLeft(80, "=")); - await runProcessInheritStdio("tools/test.py", fullArguments); + await runProcessInheritStdio( + "python", ["tools/test.py"]..addAll(fullArguments), + runInShell: Platform.isWindows); stepResultsPaths.add("${stepDirectory.path}/results.json"); stepLogsPaths.add("${stepDirectory.path}/logs.json"); // Find the list of tests to deflake. @@ -309,7 +314,9 @@ ${parser.usage}"""); "--test-list=$deflakeListPath", ]) ..addAll(options.rest); - await runProcessInheritStdio("tools/test.py", deflakeArguments); + await runProcessInheritStdio( + "python", ["tools/test.py"]..addAll(deflakeArguments), + runInShell: Platform.isWindows); deflakingResultsPaths.add("${deflakeDirectory.path}/results.json"); } // Update the flakiness information based on what we've learned.