[test.py] Pass environment to dartdev[ck] through createCommand

Some tests are run via createCommand, some via
computeCompilationArtifact. This meant that some tests got an
environment and some didn't, resulting in the batch workers
getting restarted all the time.
This CL fixes the issue by passing the environment to createCommand as
well, meaning that the batch workers doesn't restart unnecessarily.

Before:

$ cls; xvfb-run -a '--server-args=-screen 0 1024x768x24' python -u ./tools/test.py -mrelease --checked --strong --use-sdk -rchrome -cdartdevk language_2
[03:09 | 100% | + 5171 | -    0]

$ cls; xvfb-run -a '--server-args=-screen 0 1024x768x24' python -u ./tools/test.py -mrelease --checked --strong --use-sdk -rchrome -cdartdevc language_2
[02:33 | 100% | + 5170 | -    0]


Now:

$ cls; xvfb-run -a '--server-args=-screen 0 1024x768x24' python -u ./tools/test.py -mrelease --checked --strong --use-sdk -rchrome -cdartdevk language_2
[01:41 | 100% | + 5171 | -    0]

$ cls; xvfb-run -a '--server-args=-screen 0 1024x768x24' python -u ./tools/test.py -mrelease --checked --strong --use-sdk -rchrome -cdartdevc language_2
[01:59 | 100% | + 5170 | -    0]


I.e. dartdevk tests are now almost twice as fast (on my machine).

Bug:
Change-Id: I15111436d3411b6ba85209950e4a5f20ee515539
Reviewed-on: https://dart-review.googlesource.com/29100
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen 2017-12-13 12:22:55 +00:00 committed by commit-bot@chromium.org
parent 5599c80edd
commit a37c34b5fb
3 changed files with 14 additions and 11 deletions

View file

@ -108,8 +108,8 @@ abstract class CompilerConfiguration {
List<Uri> bootstrapDependencies() => const <Uri>[];
/// Creates a [Command] to compile [inputFile] to [outputFile].
Command createCommand(
String inputFile, String outputFile, List<String> sharedOptions) {
Command createCommand(String inputFile, String outputFile,
List<String> sharedOptions, Map<String, String> environment) {
// TODO(rnystrom): See if this method can be unified with
// computeCompilationArtifact() and/or computeCompilerArguments() for the
// other compilers.
@ -475,9 +475,8 @@ class DevCompilerConfiguration extends CompilerConfiguration {
return result;
}
Command createCommand(
String inputFile, String outputFile, List<String> sharedOptions,
[Map<String, String> environment = const {}]) {
Command createCommand(String inputFile, String outputFile,
List<String> sharedOptions, Map<String, String> environment) {
var moduleRoot =
new Path(outputFile).directoryPath.directoryPath.toNativePath();
@ -559,9 +558,8 @@ class DevKernelCompilerConfiguration extends CompilerConfiguration {
return result;
}
Command createCommand(
String inputFile, String outputFile, List<String> sharedOptions,
[Map<String, String> environment = const {}]) {
Command createCommand(String inputFile, String outputFile,
List<String> sharedOptions, Map<String, String> environment) {
var args = sharedOptions.toList();
var sdkSummary = new Path(_configuration.buildDirectory)

View file

@ -790,6 +790,7 @@ class BatchRunnerProcess {
bool _dictEquals(Map a, Map b) {
if (a == null) return b == null;
if (b == null) return false;
if (a.length != b.length) return false;
for (var key in a.keys) {
if (a[key] != b[key]) return false;
}

View file

@ -1045,8 +1045,11 @@ class StandardTestSuite extends TestSuite {
case Compiler.dartdevk:
var toPath =
new Path('$compilationTempDir/$nameNoExt.js').toNativePath();
commands.add(configuration.compilerConfiguration.createCommand(fileName,
toPath, optionsFromFile["sharedOptions"] as List<String>));
commands.add(configuration.compilerConfiguration.createCommand(
fileName,
toPath,
optionsFromFile["sharedOptions"] as List<String>,
environmentOverrides));
break;
default:
@ -1070,7 +1073,8 @@ class StandardTestSuite extends TestSuite {
commands.add(configuration.compilerConfiguration.createCommand(
fromPath.toNativePath(),
toPath,
optionsFromFile["sharedOptions"] as List<String>));
optionsFromFile["sharedOptions"] as List<String>,
environmentOverrides));
break;
}
}