@@ -21,13 +21,13 @@ class Step {
21
21
final String script;
22
22
final List <String > arguments;
23
23
final Map <String , String > environment;
24
- final String fileSet;
25
- final int shards;
24
+ final String ? fileSet;
25
+ final int ? shards;
26
26
final bool isTestRunner;
27
- final Configuration testedConfiguration;
27
+ final Configuration ? testedConfiguration;
28
28
29
- Step (this .name, String script, this .arguments, this .environment, this .fileSet ,
30
- this .shards, this .isTestRunner, this .testedConfiguration)
29
+ Step (this .name, String ? script, this .arguments, this .environment,
30
+ this .fileSet, this . shards, this .isTestRunner, this .testedConfiguration)
31
31
: script = script ?? testScriptName;
32
32
33
33
static const testScriptName = "tools/test.py" ;
@@ -36,14 +36,14 @@ class Step {
36
36
37
37
/// Create a [Step] from the 'step template' [map] , values for supported
38
38
/// variables [configuration] , and the list of supported named configurations.
39
- static Step parse (Map map, Map <String , String > configuration,
39
+ static Step parse (Map map, Map <String , String ? > configuration,
40
40
List <Configuration > configurations) {
41
- var arguments = (map["arguments" ] as List ?? [])
41
+ var arguments = (map["arguments" ] as List ? ?? [])
42
42
.map ((argument) => _expandVariables (argument as String , configuration))
43
43
.toList ();
44
44
var testedConfigurations = < Configuration > [];
45
- var script = map["script" ] as String ?? testScriptName;
46
- var isTestRunner = map["testRunner" ] as bool ?? false ;
45
+ var script = map["script" ] as String ? ?? testScriptName;
46
+ var isTestRunner = map["testRunner" ] as bool ? ?? false ;
47
47
if (script == testScriptName || isTestRunner) {
48
48
// TODO(karlklose): replace with argument parser that can handle all
49
49
// arguments to test.py.
@@ -78,8 +78,8 @@ class Step {
78
78
script,
79
79
arguments,
80
80
< String , String > {...? map["environment" ]},
81
- map["fileset" ] as String ,
82
- map["shards" ] as int ,
81
+ map["fileset" ] as String ? ,
82
+ map["shards" ] as int ? ,
83
83
isTestRunner,
84
84
testedConfigurations.isEmpty ? null : testedConfigurations.single);
85
85
}
@@ -92,13 +92,13 @@ class Step {
92
92
/// the test matrix.
93
93
class Builder {
94
94
final String name;
95
- final String description;
95
+ final String ? description;
96
96
final List <Step > steps;
97
- final System system;
98
- final Mode mode;
99
- final Architecture arch;
100
- final Sanitizer sanitizer;
101
- final Runtime runtime;
97
+ final System ? system;
98
+ final Mode ? mode;
99
+ final Architecture ? arch;
100
+ final Sanitizer ? sanitizer;
101
+ final Runtime ? runtime;
102
102
final Set <Configuration > testedConfigurations;
103
103
104
104
Builder (this .name, this .description, this .steps, this .system, this .mode,
@@ -111,7 +111,7 @@ class Builder {
111
111
/// `${arch}` , and `${runtime}. The values for these variables are inferred
112
112
/// from the builder's name.
113
113
static Builder parse (String builderName, List <Map > steps,
114
- List <Configuration > configurations, String description) {
114
+ List <Configuration > configurations, String ? description) {
115
115
var builderParts = builderName.split ("-" );
116
116
var systemName = _findPart (builderParts, System .names, 'linux' );
117
117
var modeName = _findPart (builderParts, Mode .names, 'release' );
@@ -146,7 +146,7 @@ class Builder {
146
146
147
147
/// Tries to replace a variable named [variableName] with [value] and throws
148
148
/// and exception if the variable is used but `value == null` .
149
- String _tryReplace (String string, String variableName, String value) {
149
+ String _tryReplace (String string, String variableName, String ? value) {
150
150
var variable = "\$ {$variableName }" ;
151
151
if (string.contains (variable)) {
152
152
if (value == null ) {
@@ -160,7 +160,7 @@ String _tryReplace(String string, String variableName, String value) {
160
160
161
161
/// Replace the use of supported variable names with the their value given
162
162
/// in [values] and throws an exception if an unsupported variable name is used.
163
- String _expandVariables (String string, Map <String , String > values) {
163
+ String _expandVariables (String string, Map <String , String ? > values) {
164
164
for (var variable in ["system" , "mode" , "arch" , "sanitizer" , "runtime" ]) {
165
165
string = _tryReplace (string, variable, values[variable]);
166
166
}
@@ -171,33 +171,35 @@ Set<Configuration> _getTestedConfigurations(List<Step> steps) {
171
171
return steps
172
172
.where ((step) => step.isTestStep)
173
173
.map ((step) => step.testedConfiguration)
174
+ .whereType <Configuration >()
174
175
.toSet ();
175
176
}
176
177
177
- T _findIfNotNull <T >(T Function (String ) find, String name) {
178
+ T ? _findIfNotNull <T >(T Function (String ) find, String ? name) {
178
179
return name != null ? find (name) : null ;
179
180
}
180
181
181
- String _findPart (List <String > builderParts, List <String > parts,
182
- [String fallback]) {
183
- return builderParts.firstWhere ((part) => parts.contains (part),
184
- orElse: () => fallback);
182
+ String ? _findPart (List <String > builderParts, List <String > parts,
183
+ [String ? fallback]) {
184
+ return builderParts
185
+ .cast <String ?>()
186
+ .firstWhere ((part) => parts.contains (part), orElse: () => fallback);
185
187
}
186
188
187
189
List <Builder > parseBuilders (
188
190
List <Map > builderConfigurations, List <Configuration > configurations) {
189
191
var builders = < Builder > [];
190
192
var names = < String > {};
191
193
for (var builderConfiguration in builderConfigurations) {
192
- var meta = builderConfiguration["meta" ] as Map ?? < String , String > {};
194
+ var meta = builderConfiguration["meta" ] as Map ? ?? < String , String > {};
193
195
var builderNames = < String > [...? builderConfiguration["builders" ]];
194
196
var steps = < Map > [...? builderConfiguration["steps" ]];
195
197
for (var builderName in builderNames) {
196
198
if (! names.add (builderName)) {
197
199
throw FormatException ('Duplicate builder name: "$builderName "' );
198
200
}
199
201
builders.add (Builder .parse (
200
- builderName, steps, configurations, meta["description" ] as String ));
202
+ builderName, steps, configurations, meta["description" ] as String ? ));
201
203
}
202
204
}
203
205
return builders;
0 commit comments