From 0ec8740c60ef85accb9f3444a0f45ebc8c5f1a95 Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Tue, 28 Feb 2023 12:05:44 +0000 Subject: [PATCH] [stable][ddc] Add ddc-options to compiler configuration Use explicit ddc-options to pass `--canary` flag to the compiler instead of sniffing for a builder tag. This just feels more expected and makes more sense if you are trying to understand how the canary configurations compile tests differently from the stable configurations. Issue: https://github.com/dart-lang/sdk/issues/51481 Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/280783 Change-Id: I6cc7c6a0a573b6f397b8b183dff13758f816fd33 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284542 Reviewed-by: Alexander Thomas --- pkg/smith/lib/configuration.dart | 9 +++++++++ pkg/smith/test/configuration_test.dart | 4 ++++ pkg/test_runner/lib/src/compiler_configuration.dart | 9 ++++++--- pkg/test_runner/lib/src/configuration.dart | 3 +++ pkg/test_runner/lib/src/options.dart | 6 ++++++ tools/bots/test_matrix.json | 10 ++++++++-- 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/pkg/smith/lib/configuration.dart b/pkg/smith/lib/configuration.dart index 85a11f3f0baf..e8dfea3d7279 100644 --- a/pkg/smith/lib/configuration.dart +++ b/pkg/smith/lib/configuration.dart @@ -250,6 +250,7 @@ class Configuration { genKernelOptions: stringListOption("gen-kernel-options"), vmOptions: stringListOption("vm-options"), dart2jsOptions: stringListOption("dart2js-options"), + ddcOptions: stringListOption("ddc-options"), experiments: stringListOption("enable-experiment"), timeout: intOption("timeout"), enableAsserts: boolOption("enable-asserts"), @@ -300,6 +301,8 @@ class Configuration { final List dart2jsOptions; + final List ddcOptions; + /// The names of the experiments to enable while running tests. /// /// A test may *require* an experiment to always be enabled by containing a @@ -347,6 +350,7 @@ class Configuration { List? genKernelOptions, List? vmOptions, List? dart2jsOptions, + List? ddcOptions, List? experiments, int? timeout, bool? enableAsserts, @@ -368,6 +372,7 @@ class Configuration { genKernelOptions = genKernelOptions ?? [], vmOptions = vmOptions ?? [], dart2jsOptions = dart2jsOptions ?? [], + ddcOptions = ddcOptions ?? [], experiments = experiments ?? [], timeout = timeout ?? -1, enableAsserts = enableAsserts ?? false, @@ -403,6 +408,7 @@ class Configuration { _listsEqual(genKernelOptions, other.genKernelOptions) && _listsEqual(vmOptions, other.vmOptions) && _listsEqual(dart2jsOptions, other.dart2jsOptions) && + _listsEqual(ddcOptions, other.ddcOptions) && _listsEqual(experiments, other.experiments) && timeout == other.timeout && enableAsserts == other.enableAsserts && @@ -453,6 +459,7 @@ class Configuration { genKernelOptions.join(" & ").hashCode ^ vmOptions.join(" & ").hashCode ^ dart2jsOptions.join(" & ").hashCode ^ + ddcOptions.join(" & ").hashCode ^ experiments.join(" & ").hashCode ^ timeout.hashCode ^ _toBinary([ @@ -495,6 +502,7 @@ class Configuration { stringListField("gen-kernel-options", genKernelOptions); stringListField("vm-options", vmOptions); stringListField("dart2js-options", dart2jsOptions); + stringListField("ddc-options", ddcOptions); stringListField("enable-experiment", experiments); if (timeout > 0) fields.add("timeout: $timeout"); if (enableAsserts) fields.add("enable-asserts"); @@ -551,6 +559,7 @@ class Configuration { "gen-kernel-options", genKernelOptions, other.genKernelOptions); stringListField("vm-options", vmOptions, other.vmOptions); stringListField("dart2js-options", dart2jsOptions, other.dart2jsOptions); + stringListField("ddc-options", ddcOptions, other.ddcOptions); stringListField("experiments", experiments, other.experiments); fields.add("timeout: $timeout ${other.timeout}"); boolField("enable-asserts", enableAsserts, other.enableAsserts); diff --git a/pkg/smith/test/configuration_test.dart b/pkg/smith/test/configuration_test.dart index 566148ecd514..8c81ab6499fe 100644 --- a/pkg/smith/test/configuration_test.dart +++ b/pkg/smith/test/configuration_test.dart @@ -359,6 +359,7 @@ void main() { builderTag: "a tag", vmOptions: ["vm a1", "vm a2"], dart2jsOptions: ["dart2js a1", "dart2js a2"], + ddcOptions: ["ddc a1", "ddc a2"], experiments: ["experiment a1", "experiment a2"], timeout: 1); @@ -373,6 +374,7 @@ void main() { builderTag: "b tag", vmOptions: ["vm b1", "vm b2"], dart2jsOptions: ["dart2js b1", "dart2js b2"], + ddcOptions: ["ddc b1", "ddc b2"], experiments: ["experiment b1", "experiment b2"], timeout: 2, enableAsserts: true, @@ -402,6 +404,7 @@ architecture: ia32 x64 builder-tag: a tag b tag vm-options: [vm a1, vm a2] [vm b1, vm b2] dart2js-options: [dart2js a1, dart2js a2] [dart2js b1, dart2js b2] + ddc-options: [ddc a1, ddc a2] [ddc b1, ddc b2] experiments: [experiment a1, experiment a2] [experiment b1, experiment b2] timeout: 1 2 enable-asserts: false true @@ -432,6 +435,7 @@ architecture: ia32 ia32 builder-tag: a tag a tag vm-options: [vm a1, vm a2] [vm a1, vm a2] dart2js-options: [dart2js a1, dart2js a2] [dart2js a1, dart2js a2] + ddc-options: [ddc a1, ddc a2] [ddc a1, ddc a2] experiments: [experiment a1, experiment a2] [experiment a1, experiment a2] timeout: 1 1 """)); diff --git a/pkg/test_runner/lib/src/compiler_configuration.dart b/pkg/test_runner/lib/src/compiler_configuration.dart index d63cc0aa0d5c..02235c6dfe2e 100644 --- a/pkg/test_runner/lib/src/compiler_configuration.dart +++ b/pkg/test_runner/lib/src/compiler_configuration.dart @@ -602,11 +602,14 @@ class DevCompilerConfiguration extends CompilerConfiguration { TestFile testFile, List vmOptions, List args) { return [ ...testFile.sharedOptions, + ...testFile.ddcOptions, ..._configuration.sharedOptions, + ..._configuration.ddcOptions, ..._experimentsArgument(_configuration, testFile), - ...testFile.ddcOptions, - if (_configuration.nnbdMode == NnbdMode.strong) '--sound-null-safety', - if (_configuration.configuration.builderTag == 'canary') '--canary', + if (_configuration.nnbdMode == NnbdMode.strong) + '--sound-null-safety' + else + '--no-sound-null-safety', // The file being compiled is the last argument. args.last ]; diff --git a/pkg/test_runner/lib/src/configuration.dart b/pkg/test_runner/lib/src/configuration.dart index fc6a0bfff0ab..f006f16702cc 100644 --- a/pkg/test_runner/lib/src/configuration.dart +++ b/pkg/test_runner/lib/src/configuration.dart @@ -152,6 +152,9 @@ class TestConfiguration { /// Extra dart2js options passed to the testing script. List get dart2jsOptions => configuration.dart2jsOptions; + /// Extra ddc options passed to the testing script. + List get ddcOptions => configuration.ddcOptions; + /// Extra gen_kernel options passed to the testing script. List get genKernelOptions => configuration.genKernelOptions; diff --git a/pkg/test_runner/lib/src/options.dart b/pkg/test_runner/lib/src/options.dart index 073675836f6b..aee684192388 100644 --- a/pkg/test_runner/lib/src/options.dart +++ b/pkg/test_runner/lib/src/options.dart @@ -347,6 +347,10 @@ options. Used to be able to make sane updates to the status files.''', aliases: ['dart2js_options'], hide: true, help: 'Extra options for dart2js compilation step.') + ..addMultiOption('ddc-options', + aliases: ['ddc_options'], + hide: true, + help: 'Extra command line options passed to the DDC compiler.') ..addMultiOption('shared-options', aliases: ['shared_options'], hide: true, help: 'Extra shared options.') ..addMultiOption('enable-experiment', @@ -628,6 +632,7 @@ has been specified on the command line.''') } var dart2jsOptions = listOption("dart2js-options"); + var ddcOptions = listOption("ddc-options"); var vmOptions = listOption("vm-options"); var sharedOptions = listOption("shared-options"); var experiments = data["enable-experiment"] as List?; @@ -819,6 +824,7 @@ has been specified on the command line.''') isMinified: data["minified"] as bool, vmOptions: vmOptions, dart2jsOptions: dart2jsOptions, + ddcOptions: ddcOptions, experiments: experiments, babel: data['babel'] as String?, builderTag: data["builder-tag"] as String?, diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json index d99fa8356bd9..1c901becc24c 100644 --- a/tools/bots/test_matrix.json +++ b/tools/bots/test_matrix.json @@ -928,7 +928,10 @@ "builder-tag": "canary", "checked": true, "use-sdk": true, - "enable-asserts": true + "enable-asserts": true, + "ddc-options": [ + "--canary" + ] } }, "dartdevc-canary-weak-(linux|mac|win)-release-(chrome|firefox)-(x64|arm64)": { @@ -936,7 +939,10 @@ "builder-tag": "canary", "checked": true, "use-sdk": true, - "enable-asserts": true + "enable-asserts": true, + "ddc-options": [ + "--canary" + ] } }, "cfe-(linux|mac|win)": {