Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c34eef4

Browse files
athomascommit-bot@chromium.org
authored andcommitted
[testing] Simplify test.py arguments for null safety testing
test.py invocations that specify a null safety mode will now work without tool specific options. For instance, `test.py --nnbd=strong -cdartkp -mrelease` will now add the `non-nullable` experiment flag as well as the pass `--sound-null-safety` to the relevant subcommands. Fixes dart-lang/sdk#42370 Change-Id: I1ae5bf569cc77ed6f26411c171c2cafe0a12eaff Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164160 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Alexander Thomas <athom@google.com>
1 parent d966206 commit c34eef4

File tree

2 files changed

+42
-121
lines changed

2 files changed

+42
-121
lines changed

pkg/test_runner/lib/src/compiler_configuration.dart

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,30 @@ List<String> _replaceDartFiles(List<String> list, String replacement) {
2525
/// list allows the result of calling this to be spread into another list.
2626
List<String> _experimentsArgument(
2727
TestConfiguration configuration, TestFile testFile) {
28-
if (configuration.experiments.isEmpty && testFile.experiments.isEmpty) {
28+
var experiments = {
29+
...configuration.experiments,
30+
...testFile.experiments,
31+
if (configuration.nnbdMode != NnbdMode.legacy)
32+
'non-nullable',
33+
};
34+
if (experiments.isEmpty) {
2935
return const [];
3036
}
3137

32-
var experiments = {...configuration.experiments, ...testFile.experiments};
33-
return ["--enable-experiment=${experiments.join(',')}"];
38+
return ['--enable-experiment=${experiments.join(',')}'];
39+
}
40+
41+
List<String> _nnbdModeArgument(TestConfiguration configuration) {
42+
switch (configuration.nnbdMode) {
43+
case NnbdMode.legacy:
44+
return [];
45+
case NnbdMode.strong:
46+
return ['--sound-null-safety'];
47+
case NnbdMode.weak:
48+
return ['--no-sound-null-safety'];
49+
}
50+
51+
throw 'unreachable';
3452
}
3553

3654
/// Grouping of a command with its expected result.
@@ -175,6 +193,7 @@ class NoneCompilerConfiguration extends CompilerConfiguration {
175193
else if (_configuration.hotReloadRollback)
176194
'--hot-reload-rollback-test-mode',
177195
...vmOptions,
196+
..._nnbdModeArgument(_configuration),
178197
...testFile.sharedOptions,
179198
..._configuration.sharedOptions,
180199
..._experimentsArgument(_configuration, testFile),
@@ -426,13 +445,18 @@ class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration {
426445
..._configuration.sharedOptions,
427446
..._experimentsArgument(_configuration, testFile),
428447
...testFile.dart2jsOptions,
448+
..._nnbdModeArgument(_configuration),
429449
...args
430450
];
431451
}
432452

433453
CommandArtifact computeCompilationArtifact(String tempDir,
434454
List<String> arguments, Map<String, String> environmentOverrides) {
435-
var compilerArguments = [...arguments, ..._configuration.dart2jsOptions];
455+
var compilerArguments = [
456+
...arguments,
457+
..._configuration.dart2jsOptions,
458+
..._nnbdModeArgument(_configuration),
459+
];
436460

437461
// TODO(athom): input filename extraction is copied from DDC. Maybe this
438462
// should be passed to computeCompilationArtifact, instead?
@@ -729,9 +753,14 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
729753
static const String ndkPath = "third_party/android_tools/ndk";
730754
String get abiTriple => _isArm || _isArmX64
731755
? "arm-linux-androideabi"
732-
: _isArm64 ? "aarch64-linux-android" : null;
733-
String get host =>
734-
Platform.isLinux ? "linux" : Platform.isMacOS ? "darwin" : null;
756+
: _isArm64
757+
? "aarch64-linux-android"
758+
: null;
759+
String get host => Platform.isLinux
760+
? "linux"
761+
: Platform.isMacOS
762+
? "darwin"
763+
: null;
735764

736765
Command computeAssembleCommand(String tempDir, List arguments,
737766
Map<String, String> environmentOverrides) {
@@ -1104,6 +1133,7 @@ abstract class VMKernelCompilerMixin {
11041133
arguments.contains('--enable-asserts') ||
11051134
arguments.contains('--enable_asserts'))
11061135
'--enable-asserts',
1136+
..._nnbdModeArgument(_configuration),
11071137
..._configuration.genKernelOptions,
11081138
];
11091139

tools/bots/test_matrix.json

Lines changed: 5 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,7 @@
398398
"enable-asserts": true,
399399
"mode": "release",
400400
"runtime": "vm",
401-
"timeout": 240,
402-
"enable-experiment": [
403-
"non-nullable"
404-
]
401+
"timeout": 240
405402
}
406403
},
407404
"analyzer-unittest-asserts-(debug|product|release)-(linux|mac|win)": {
@@ -516,12 +513,6 @@
516513
"dart2js-weak-(linux|mac|win)-x64-d8": {
517514
"options": {
518515
"builder-tag": "dart2js-weak",
519-
"enable-experiment": [
520-
"non-nullable"
521-
],
522-
"dart2js-options": [
523-
"--no-sound-null-safety"
524-
],
525516
"use-sdk": true
526517
}
527518
},
@@ -576,11 +567,7 @@
576567
"dart2js-hostasserts-weak-(linux|win)-x64-(d8|chrome)": {
577568
"options": {
578569
"builder-tag": "dart2js-weak",
579-
"enable-experiment": [
580-
"non-nullable"
581-
],
582570
"dart2js-options": [
583-
"--no-sound-null-safety",
584571
"--libraries-spec=sdk/lib/libraries.json",
585572
"--platform-binaries=out/ReleaseX64/"
586573
],
@@ -591,11 +578,7 @@
591578
"dart2js-hostasserts-weak-mac-x64-(d8|chrome)": {
592579
"options": {
593580
"builder-tag": "dart2js-weak",
594-
"enable-experiment": [
595-
"non-nullable"
596-
],
597581
"dart2js-options": [
598-
"--no-sound-null-safety",
599582
"--libraries-spec=sdk/lib/libraries.json",
600583
"--platform-binaries=xcodebuild/ReleaseX64/"
601584
],
@@ -606,11 +589,7 @@
606589
"dart2js-hostasserts-strong-(linux|win)-x64-(d8|chrome)": {
607590
"options": {
608591
"builder-tag": "dart2js-strong",
609-
"enable-experiment": [
610-
"non-nullable"
611-
],
612592
"dart2js-options": [
613-
"--sound-null-safety",
614593
"--libraries-spec=sdk/lib/libraries.json",
615594
"--platform-binaries=out/ReleaseX64/"
616595
],
@@ -621,11 +600,7 @@
621600
"dart2js-hostasserts-strong-mac-x64-(d8|chrome)": {
622601
"options": {
623602
"builder-tag": "dart2js-strong",
624-
"enable-experiment": [
625-
"non-nullable"
626-
],
627603
"dart2js-options": [
628-
"--sound-null-safety",
629604
"--libraries-spec=sdk/lib/libraries.json",
630605
"--platform-binaries=xcodebuild/ReleaseX64/"
631606
],
@@ -710,115 +685,49 @@
710685
},
711686
"dartkp-weak-asserts-(linux|mac)-(debug|product|release)-x64": {
712687
"options": {
713-
"enable-experiment": [
714-
"non-nullable"
715-
],
716-
"gen-kernel-options": [
717-
"--no-sound-null-safety"
718-
],
719688
"enable-asserts": true,
720-
"vm-options": [
721-
"--no-sound-null-safety"
722-
],
723689
"builder-tag": "vm_nnbd"
724690
}
725691
},
726692
"dartkp-weak-asserts-(linux|mac)-(debug|product|release)-simarm64": {
727693
"options": {
728-
"enable-experiment": [
729-
"non-nullable"
730-
],
731-
"gen-kernel-options": [
732-
"--no-sound-null-safety"
733-
],
734694
"enable-asserts": true,
735695
"use-elf": true,
736-
"vm-options": [
737-
"--no-sound-null-safety"
738-
],
739696
"builder-tag": "vm_nnbd"
740697
}
741698
},
742699
"dartkp-weak-asserts-win-(debug|product|release)-(simarm64|x64)": {
743700
"options": {
744-
"enable-experiment": [
745-
"non-nullable"
746-
],
747-
"gen-kernel-options": [
748-
"--no-sound-null-safety"
749-
],
750701
"enable-asserts": true,
751702
"use-elf": true,
752-
"vm-options": [
753-
"--no-sound-null-safety"
754-
],
755703
"builder-tag": "vm_nnbd"
756704
}
757705
},
758706
"dartk-weak-asserts-(linux|mac|win)-(debug|product|release)-x64": {
759707
"options": {
760-
"enable-experiment": [
761-
"non-nullable"
762-
],
763708
"enable-asserts": true,
764-
"vm-options": [
765-
"--no-sound-null-safety"
766-
],
767709
"builder-tag": "vm_nnbd"
768710
}
769711
},
770712
"dartk-strong-(linux|mac|win)-(debug|product|release)-x64": {
771713
"options": {
772-
"enable-experiment": [
773-
"non-nullable"
774-
],
775-
"vm-options": [
776-
"--sound-null-safety"
777-
],
778714
"builder-tag": "vm_nnbd"
779715
}
780716
},
781717
"dartkp-strong-(linux|mac)-(debug|product|release)-x64": {
782718
"options": {
783-
"enable-experiment": [
784-
"non-nullable"
785-
],
786-
"gen-kernel-options": [
787-
"--sound-null-safety"
788-
],
789-
"vm-options": [
790-
"--sound-null-safety"
791-
],
792719
"builder-tag": "vm_nnbd"
793720
}
794721
},
795722
"dartkp-strong-(linux|mac)-(debug|product|release)-simarm64": {
796723
"options": {
797-
"enable-experiment": [
798-
"non-nullable"
799-
],
800-
"gen-kernel-options": [
801-
"--sound-null-safety"
802-
],
803724
"use-elf": true,
804-
"vm-options": [
805-
"--sound-null-safety"
806-
],
807725
"builder-tag": "vm_nnbd"
808726
}
809727
},
810728
"dartkp-strong-win-(debug|product|release)-(simarm64|x64)": {
811729
"options": {
812730
"use-elf": true,
813-
"enable-experiment": [
814-
"non-nullable"
815-
],
816-
"gen-kernel-options": [
817-
"--sound-null-safety"
818-
],
819-
"vm-options": [
820-
"--sound-null-safety"
821-
],
822731
"builder-tag": "vm_nnbd"
823732
}
824733
},
@@ -868,19 +777,13 @@
868777
"options": {
869778
"checked": true,
870779
"use-sdk": true,
871-
"enable-experiment": [
872-
"non-nullable"
873-
],
874780
"enable-asserts": true
875781
}
876782
},
877783
"dartdevk-weak-linux-release-chrome": {
878784
"options": {
879785
"checked": true,
880786
"use-sdk": true,
881-
"enable-experiment": [
882-
"non-nullable"
883-
],
884787
"enable-asserts": true
885788
}
886789
},
@@ -891,18 +794,12 @@
891794
},
892795
"cfe-weak-(linux|mac|win)": {
893796
"options": {
894-
"compiler": "fasta",
895-
"enable-experiment": [
896-
"non-nullable"
897-
]
797+
"compiler": "fasta"
898798
}
899799
},
900800
"cfe-strong-(linux|mac|win)": {
901801
"options": {
902-
"compiler": "fasta",
903-
"enable-experiment": [
904-
"non-nullable"
905-
]
802+
"compiler": "fasta"
906803
}
907804
},
908805
"analyzer-(linux|mac|win)": {
@@ -922,20 +819,14 @@
922819
"options": {
923820
"compiler": "dart2analyzer",
924821
"enable-asserts": true,
925-
"use-sdk": true,
926-
"enable-experiment": [
927-
"non-nullable"
928-
]
822+
"use-sdk": true
929823
}
930824
},
931825
"analyzer-asserts-weak-(linux|mac|win)": {
932826
"options": {
933827
"compiler": "dart2analyzer",
934828
"enable-asserts": true,
935-
"use-sdk": true,
936-
"enable-experiment": [
937-
"non-nullable"
938-
]
829+
"use-sdk": true
939830
}
940831
}
941832
},

0 commit comments

Comments
 (0)