Skip to content

Commit e0f6fdf

Browse files
committed
Refactor testing:TestConfiguration to use smith:Configuration by inclusion.
Change-Id: I5c116ad082a24c25a07b9ceb6aaf8c9cbe3f11e3 Reviewed-on: https://dart-review.googlesource.com/68361 Reviewed-by: Bob Nystrom <rnystrom@google.com>
1 parent 95d1ebd commit e0f6fdf

File tree

6 files changed

+102
-111
lines changed

6 files changed

+102
-111
lines changed

pkg/smith/lib/configuration.dart

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ class Configuration {
201201
return value as String;
202202
}
203203

204+
List<String> stringListOption(String option) {
205+
if (!optionsCopy.containsKey(option)) return null;
206+
207+
var value = optionsCopy.remove(option);
208+
if (value == null) throw FormatException('Option "$option" was null.');
209+
if (value is! List) {
210+
throw FormatException('Option "$option" had value "$value", which is '
211+
'not a List.');
212+
}
213+
return new List<String>.from(value);
214+
}
215+
204216
// Extract options from the name and map.
205217
var architecture =
206218
enumOption("architecture", Architecture.names, Architecture.find);
@@ -236,14 +248,13 @@ class Configuration {
236248
var configuration = Configuration(
237249
name, architecture, compiler, mode, runtime, system,
238250
builderTag: stringOption("builder-tag"),
239-
vmOptions: stringOption("vm-options"),
251+
vmOptions: stringListOption("vm-options"),
240252
timeout: intOption("timeout"),
241253
enableAsserts: boolOption("enable-asserts"),
242254
isChecked: boolOption("checked"),
243255
isCsp: boolOption("csp"),
244256
isHostChecked: boolOption("host-checked"),
245257
isMinified: boolOption("minified"),
246-
isStrong: boolOption("strong"),
247258
previewDart2: boolOption("preview-dart-2"),
248259
useBlobs: boolOption("use-blobs"),
249260
useDart2JSWithKernel: boolOption("dart2js-with-kernel"),
@@ -273,12 +284,11 @@ class Configuration {
273284

274285
final System system;
275286

276-
// TODO(rnystrom): Is this still needed?
277287
final String builderTag;
278288

279-
final String vmOptions;
289+
final List<String> vmOptions;
280290

281-
final int timeout;
291+
int timeout;
282292

283293
final bool enableAsserts;
284294

@@ -292,9 +302,6 @@ class Configuration {
292302

293303
final bool isMinified;
294304

295-
// TODO(rnystrom): Remove this when Dart 1.0 is no longer supported.
296-
final bool isStrong;
297-
298305
// TODO(rnystrom): Remove this when Dart 1.0 is no longer supported.
299306
final bool previewDart2;
300307

@@ -315,14 +322,13 @@ class Configuration {
315322
Configuration(this.name, this.architecture, this.compiler, this.mode,
316323
this.runtime, this.system,
317324
{String builderTag,
318-
String vmOptions,
325+
List<String> vmOptions,
319326
int timeout,
320327
bool enableAsserts,
321328
bool isChecked,
322329
bool isCsp,
323330
bool isHostChecked,
324331
bool isMinified,
325-
bool isStrong,
326332
bool previewDart2,
327333
bool useBlobs,
328334
bool useDart2JSWithKernel,
@@ -332,14 +338,13 @@ class Configuration {
332338
bool useHotReloadRollback,
333339
bool useSdk})
334340
: builderTag = builderTag ?? "",
335-
vmOptions = vmOptions ?? "",
336-
timeout = timeout ?? 0,
341+
vmOptions = vmOptions ?? <String>[],
342+
timeout = timeout,
337343
enableAsserts = enableAsserts ?? false,
338344
isChecked = isChecked ?? false,
339345
isCsp = isCsp ?? false,
340346
isHostChecked = isHostChecked ?? false,
341347
isMinified = isMinified ?? false,
342-
isStrong = isStrong ?? false,
343348
previewDart2 = previewDart2 ?? true,
344349
useBlobs = useBlobs ?? false,
345350
useDart2JSWithKernel = useDart2JSWithKernel ?? false,
@@ -365,7 +370,6 @@ class Configuration {
365370
isCsp == other.isCsp &&
366371
isHostChecked == other.isHostChecked &&
367372
isMinified == other.isMinified &&
368-
isStrong == other.isStrong &&
369373
previewDart2 == other.previewDart2 &&
370374
useBlobs == other.useBlobs &&
371375
useDart2JSWithKernel == other.useDart2JSWithKernel &&
@@ -393,15 +397,14 @@ class Configuration {
393397
(isCsp ? 4 : 0) ^
394398
(isHostChecked ? 8 : 0) ^
395399
(isMinified ? 16 : 0) ^
396-
(isStrong ? 32 : 0) ^
397-
(previewDart2 ? 64 : 0) ^
398-
(useBlobs ? 128 : 0) ^
399-
(useDart2JSWithKernel ? 256 : 0) ^
400-
(useDart2JSOldFrontEnd ? 512 : 0) ^
401-
(useFastStartup ? 1024 : 0) ^
402-
(useHotReload ? 2048 : 0) ^
403-
(useHotReloadRollback ? 4096 : 0) ^
404-
(useSdk ? 8192 : 0);
400+
(previewDart2 ? 32 : 0) ^
401+
(useBlobs ? 64 : 0) ^
402+
(useDart2JSWithKernel ? 128 : 0) ^
403+
(useDart2JSOldFrontEnd ? 256 : 0) ^
404+
(useFastStartup ? 512 : 0) ^
405+
(useHotReload ? 1024 : 0) ^
406+
(useHotReloadRollback ? 2048 : 0) ^
407+
(useSdk ? 4096 : 0);
405408

406409
String toString() {
407410
var buffer = new StringBuffer();
@@ -423,7 +426,6 @@ class Configuration {
423426
if (isCsp) fields.add("csp");
424427
if (isHostChecked) fields.add("host-checked");
425428
if (isMinified) fields.add("minified");
426-
if (isStrong) fields.add("strong");
427429
if (previewDart2) fields.add("preview-dart-2");
428430
if (useBlobs) fields.add("use-blobs");
429431
if (useDart2JSWithKernel) fields.add("dart2js-with-kernel");

pkg/smith/test/configuration_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void main() {
221221
Runtime.d8,
222222
System.host,
223223
builderTag: "the tag",
224-
vmOptions: "vm stuff",
224+
vmOptions: ["vm stuff", "more vm stuff"],
225225
enableAsserts: true,
226226
isChecked: true,
227227
isCsp: true,

tools/bots/test_matrix.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
"runtime": "vm",
168168
"mode": "release",
169169
"use-sdk": true,
170-
"vm-options": "-DuserFastParser=true",
170+
"vm-options": ["-DuserFastParser=true"],
171171
"builder-tag": "analyzer_use_fasta"
172172
}},
173173
"vm-legacy-(linux|mac|win)-(debug|release)-(ia32|x64)": {
@@ -227,14 +227,14 @@
227227
"options": {
228228
"preview-dart-2": false,
229229
"builder-tag": "optimization_counter_threshold",
230-
"vm-options": "--optimization-counter-threshold=5"
230+
"vm-options": ["--optimization-counter-threshold=5"]
231231
}},
232232
"vm-legacy-optcounter-checked-linux-release-(ia32|x64)": {
233233
"options": {
234234
"preview-dart-2": false,
235235
"checked": true,
236236
"builder-tag": "optimization_counter_threshold",
237-
"vm-options": "--optimization-counter-threshold=5"
237+
"vm-options": ["--optimization-counter-threshold=5"]
238238
}},
239239
"vm-legacy-reload-linux-(debug|release)-x64": {
240240
"options": {
@@ -346,7 +346,7 @@
346346
"dartkp-linux-release-x64": { },
347347
"dartkp-linux-debug-x64": {
348348
"options": {
349-
"vm-options": "no-enable-malloc-hooks"
349+
"vm-options": ["no-enable-malloc-hooks"]
350350
}},
351351
"dartk-(linux|mac)-(debug|release)-x64": { },
352352
"dartk-win-release-x64": { },
@@ -355,7 +355,7 @@
355355
"dartk-optcounter-linux-release-x64": {
356356
"options": {
357357
"builder-tag": "optimization_counter_threshold",
358-
"vm-options": "--optimization-counter-threshold=5",
358+
"vm-options": ["--optimization-counter-threshold=5"],
359359
"preview-dart-2": false
360360
}},
361361
"dartk-legacy-linux-release-x64": {

tools/testing/dart/configuration.dart

Lines changed: 38 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,28 @@ import 'runtime_configuration.dart';
2222
/// executed on, etc.
2323
class TestConfiguration {
2424
TestConfiguration(
25-
{this.architecture,
26-
this.compiler,
27-
this.mode,
25+
{this.configuration,
26+
this.namedConfiguration,
2827
this.progress,
29-
this.runtime,
30-
this.system,
3128
this.selectors,
3229
this.appendLogs,
3330
this.batch,
3431
this.batchDart2JS,
3532
this.copyCoreDumps,
36-
this.hotReload,
37-
this.hotReloadRollback,
38-
this.isChecked,
39-
this.isHostChecked,
40-
this.isCsp,
41-
this.isMinified,
4233
this.isVerbose,
4334
this.listTests,
4435
this.listStatusFiles,
45-
this.noPreviewDart2,
4636
this.printTiming,
4737
this.printReport,
4838
this.reportInJson,
4939
this.resetBrowser,
5040
this.skipCompilation,
5141
this.useAnalyzerCfe,
5242
this.useAnalyzerFastaParser,
53-
this.useBlobs,
54-
this.useSdk,
55-
this.useFastStartup,
56-
this.useEnableAsserts,
57-
this.useDart2JSWithKernel,
58-
this.useDart2JSOldFrontend,
5943
this.useKernelBytecode,
6044
this.writeDebugLog,
6145
this.writeTestOutcomeLog,
6246
this.writeResultLog,
63-
this.namedConfiguration,
6447
this.drtPath,
6548
this.chromePath,
6649
this.safariPath,
@@ -69,7 +52,6 @@ class TestConfiguration {
6952
this.dartPrecompiledPath,
7053
this.flutterPath,
7154
this.taskCount,
72-
int timeout,
7355
this.shardCount,
7456
this.shard,
7557
this.stepName,
@@ -78,26 +60,23 @@ class TestConfiguration {
7860
this.testDriverErrorPort,
7961
this.localIP,
8062
this.dart2jsOptions,
81-
this.vmOptions,
8263
String packages,
8364
this.packageRoot,
8465
this.suiteDirectory,
85-
this.builderTag,
8666
this.outputDirectory,
8767
this.reproducingArguments,
8868
this.fastTestsOnly,
8969
this.printPassingStdout})
90-
: _packages = packages,
91-
_timeout = timeout;
92-
93-
final Architecture architecture;
94-
final Compiler compiler;
95-
final Mode mode;
96-
final Progress progress;
97-
final Runtime runtime;
98-
final System system;
70+
: _packages = packages;
9971

10072
final Map<String, RegExp> selectors;
73+
final Progress progress;
74+
// The test configuration computed from the test options.
75+
final Configuration configuration;
76+
// The test configuration coming from the -n option. Merging
77+
// these two configurations into one will be the focus of some
78+
// usability work.
79+
final Configuration namedConfiguration;
10180

10281
// Boolean flags.
10382

@@ -106,37 +85,42 @@ class TestConfiguration {
10685
final bool batchDart2JS;
10786
final bool copyCoreDumps;
10887
final bool fastTestsOnly;
109-
final bool hotReload;
110-
final bool hotReloadRollback;
111-
final bool isChecked;
112-
final bool isHostChecked;
113-
final bool isCsp;
114-
final bool isMinified;
11588
final bool isVerbose;
11689
final bool listTests;
11790
final bool listStatusFiles;
118-
final bool noPreviewDart2;
11991
final bool printTiming;
12092
final bool printReport;
12193
final bool reportInJson;
12294
final bool resetBrowser;
12395
final bool skipCompilation;
12496
final bool useAnalyzerCfe;
12597
final bool useAnalyzerFastaParser;
126-
final bool useBlobs;
127-
final bool useSdk;
128-
final bool useFastStartup;
129-
final bool useEnableAsserts;
130-
final bool useDart2JSWithKernel;
131-
final bool useDart2JSOldFrontend;
13298
final bool useKernelBytecode;
13399
final bool writeDebugLog;
134100
final bool writeTestOutcomeLog;
135101
final bool writeResultLog;
136102
final bool printPassingStdout;
137103

138-
final Configuration
139-
namedConfiguration; // The test configuration containing all test options.
104+
Architecture get architecture => configuration.architecture;
105+
Compiler get compiler => configuration.compiler;
106+
Mode get mode => configuration.mode;
107+
Runtime get runtime => configuration.runtime;
108+
System get system => configuration.system;
109+
110+
// Boolean getters
111+
bool get hotReload => configuration.useHotReload;
112+
bool get hotReloadRollback => configuration.useHotReloadRollback;
113+
bool get isChecked => configuration.isChecked;
114+
bool get isHostChecked => configuration.isHostChecked;
115+
bool get isCsp => configuration.isCsp;
116+
bool get isMinified => configuration.isMinified;
117+
bool get noPreviewDart2 => !configuration.previewDart2;
118+
bool get useBlobs => configuration.useBlobs;
119+
bool get useSdk => configuration.useSdk;
120+
bool get useFastStartup => configuration.useFastStartup;
121+
bool get useEnableAsserts => configuration.enableAsserts;
122+
bool get useDart2JSWithKernel => configuration.useDart2JSWithKernel;
123+
bool get useDart2JSOldFrontend => configuration.useDart2JSOldFrontEnd;
140124

141125
// Various file paths.
142126

@@ -162,7 +146,7 @@ class TestConfiguration {
162146
final List<String> dart2jsOptions;
163147

164148
/// Extra VM options passed to the testing script.
165-
final List<String> vmOptions;
149+
List<String> get vmOptions => configuration.vmOptions;
166150

167151
String _packages;
168152

@@ -178,7 +162,7 @@ class TestConfiguration {
178162
final String outputDirectory;
179163
final String packageRoot;
180164
final String suiteDirectory;
181-
final String builderTag;
165+
String get builderTag => configuration.builderTag;
182166
final List<String> reproducingArguments;
183167

184168
TestingServers _servers;
@@ -226,10 +210,11 @@ class TestConfiguration {
226210
/// build/none_vm_release_x64
227211
String get buildDirectory => system.outputDirectory + configurationDirectory;
228212

229-
int _timeout;
230-
213+
// TODO(whesse): Put non-default timeouts explicitly in configs, not this.
214+
/// Calculates a default timeout based on the compiler and runtime used,
215+
/// and the mode, architecture, etc.
231216
int get timeout {
232-
if (_timeout == null) {
217+
if (configuration.timeout == null) {
233218
var isReload = hotReload || hotReloadRollback;
234219

235220
var compilerMulitiplier = compilerConfiguration.timeoutMultiplier;
@@ -239,10 +224,10 @@ class TestConfiguration {
239224
isReload: isReload,
240225
arch: architecture);
241226

242-
_timeout = 60 * compilerMulitiplier * runtimeMultiplier;
227+
configuration.timeout = 60 * compilerMulitiplier * runtimeMultiplier;
243228
}
244229

245-
return _timeout;
230+
return configuration.timeout;
246231
}
247232

248233
List<String> get standardOptions {

tools/testing/dart/launch_browser.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ void main(List<String> arguments) {
3434
}
3535

3636
var runtime = Runtime.find(name);
37-
var configuration = new TestConfiguration(runtime: runtime);
37+
var configuration = new TestConfiguration(
38+
configuration: new Configuration(
39+
"dummy configuration", null, null, null, runtime, null));
3840
var executable = configuration.browserLocation;
3941
var browser = new Browser.byRuntime(runtime, executable);
4042
browser.start(arguments[1]);

0 commit comments

Comments
 (0)