@@ -114,17 +114,21 @@ class Command {
114
114
Uri workingDirectory) {
115
115
return new FastaCompilationCommand ._(
116
116
compilerLocation,
117
- outputFile,
117
+ outputFile. toFilePath () ,
118
118
bootstrapDependencies,
119
- executable,
119
+ executable. toFilePath () ,
120
120
arguments,
121
121
environment,
122
- workingDirectory);
122
+ workingDirectory? . toFilePath () );
123
123
}
124
124
125
125
/// A descriptive name for this command.
126
126
final String displayName;
127
127
128
+ /// When cloning a command object to run it multiple times, we give
129
+ /// the different copies distinct values for index.
130
+ int index;
131
+
128
132
/// Number of times this command *can* be retried.
129
133
int get maxNumRetries => 2 ;
130
134
@@ -135,7 +139,15 @@ class Command {
135
139
/// be expensive to compute (and hashCode is called often).
136
140
int _cachedHashCode;
137
141
138
- Command ._(this .displayName);
142
+ Command ._(this .displayName, {this .index = 0 });
143
+
144
+ /// A virtual clone method for a member of the Command hierarchy.
145
+ /// Two clones with the same index will be equal, with different indices
146
+ /// will be distinct. Used to run tests multiple times, since identical
147
+ /// commands are only run once by the dependency graph scheduler.
148
+ Command indexedCopy (int index) {
149
+ return Command ._(displayName, index: index);
150
+ }
139
151
140
152
int get hashCode {
141
153
if (_cachedHashCode == null ) {
@@ -152,10 +164,13 @@ class Command {
152
164
153
165
void _buildHashCode (HashCodeBuilder builder) {
154
166
builder.addJson (displayName);
167
+ builder.add (index);
155
168
}
156
169
157
170
bool _equal (covariant Command other) =>
158
- hashCode == other.hashCode && displayName == other.displayName;
171
+ hashCode == other.hashCode &&
172
+ displayName == other.displayName &&
173
+ index == other.index;
159
174
160
175
String toString () => reproductionCommand;
161
176
@@ -176,8 +191,8 @@ class ProcessCommand extends Command {
176
191
final String workingDirectory;
177
192
178
193
ProcessCommand ._(String displayName, this .executable, this .arguments,
179
- [this .environmentOverrides, this .workingDirectory])
180
- : super ._(displayName) {
194
+ [this .environmentOverrides, this .workingDirectory, int index = 0 ])
195
+ : super ._(displayName, index : index ) {
181
196
if (io.Platform .operatingSystem == 'windows' ) {
182
197
// Windows can't handle the first command if it is a .bat file or the like
183
198
// with the slashes going the other direction.
@@ -186,6 +201,11 @@ class ProcessCommand extends Command {
186
201
}
187
202
}
188
203
204
+ ProcessCommand indexedCopy (int index) {
205
+ return ProcessCommand ._(displayName, executable, arguments,
206
+ environmentOverrides, workingDirectory, index);
207
+ }
208
+
189
209
void _buildHashCode (HashCodeBuilder builder) {
190
210
super ._buildHashCode (builder);
191
211
builder.addJson (executable);
@@ -240,9 +260,21 @@ class CompilationCommand extends ProcessCommand {
240
260
String executable,
241
261
List <String > arguments,
242
262
Map <String , String > environmentOverrides,
243
- {String workingDirectory})
263
+ {String workingDirectory,
264
+ int index = 0 })
244
265
: super ._(displayName, executable, arguments, environmentOverrides,
245
- workingDirectory);
266
+ workingDirectory, index);
267
+
268
+ CompilationCommand indexedCopy (int index) => CompilationCommand ._(
269
+ displayName,
270
+ _outputFile,
271
+ _alwaysCompile,
272
+ _bootstrapDependencies,
273
+ executable,
274
+ arguments,
275
+ environmentOverrides,
276
+ workingDirectory: workingDirectory,
277
+ index: index);
246
278
247
279
bool get outputIsUpToDate {
248
280
if (_alwaysCompile) return false ;
@@ -294,15 +326,27 @@ class FastaCompilationCommand extends CompilationCommand {
294
326
295
327
FastaCompilationCommand ._(
296
328
this ._compilerLocation,
297
- Uri outputFile,
329
+ String outputFile,
298
330
List <Uri > bootstrapDependencies,
299
- Uri executable,
331
+ String executable,
300
332
List <String > arguments,
301
333
Map <String , String > environmentOverrides,
302
- Uri workingDirectory)
303
- : super ._("fasta" , outputFile.toFilePath (), true , bootstrapDependencies,
304
- executable.toFilePath (), arguments, environmentOverrides,
305
- workingDirectory: workingDirectory? .toFilePath ());
334
+ String workingDirectory,
335
+ {int index = 0 })
336
+ : super ._("fasta" , outputFile, true , bootstrapDependencies, executable,
337
+ arguments, environmentOverrides,
338
+ workingDirectory: workingDirectory, index: index);
339
+
340
+ @override
341
+ FastaCompilationCommand indexedCopy (int index) => FastaCompilationCommand ._(
342
+ _compilerLocation,
343
+ _outputFile,
344
+ _bootstrapDependencies,
345
+ executable,
346
+ arguments,
347
+ environmentOverrides,
348
+ workingDirectory,
349
+ index: index);
306
350
307
351
@override
308
352
List <String > get batchArguments {
@@ -370,13 +414,20 @@ class FastaCompilationCommand extends CompilationCommand {
370
414
class VMKernelCompilationCommand extends CompilationCommand {
371
415
VMKernelCompilationCommand ._(
372
416
String outputFile,
373
- bool neverSkipCompilation ,
417
+ bool alwaysCompile ,
374
418
List <Uri > bootstrapDependencies,
375
419
String executable,
376
420
List <String > arguments,
377
- Map <String , String > environmentOverrides)
378
- : super ._('vm_compile_to_kernel' , outputFile, neverSkipCompilation,
379
- bootstrapDependencies, executable, arguments, environmentOverrides);
421
+ Map <String , String > environmentOverrides,
422
+ {int index = 0 })
423
+ : super ._('vm_compile_to_kernel' , outputFile, alwaysCompile,
424
+ bootstrapDependencies, executable, arguments, environmentOverrides,
425
+ index: index);
426
+
427
+ VMKernelCompilationCommand indexedCopy (int index) =>
428
+ VMKernelCompilationCommand ._(_outputFile, _alwaysCompile,
429
+ _bootstrapDependencies, executable, arguments, environmentOverrides,
430
+ index: index);
380
431
381
432
int get maxNumRetries => 1 ;
382
433
}
@@ -398,8 +449,12 @@ class BrowserTestCommand extends Command {
398
449
final TestConfiguration configuration;
399
450
final bool retry;
400
451
401
- BrowserTestCommand ._(this .url, this .configuration, this .retry)
402
- : super ._(configuration.runtime.name);
452
+ BrowserTestCommand ._(this .url, this .configuration, this .retry,
453
+ {int index = 0 })
454
+ : super ._(configuration.runtime.name, index: index);
455
+
456
+ BrowserTestCommand indexedCopy (int index) =>
457
+ BrowserTestCommand ._(url, configuration, retry, index: index);
403
458
404
459
void _buildHashCode (HashCodeBuilder builder) {
405
460
super ._buildHashCode (builder);
@@ -431,27 +486,45 @@ class BrowserTestCommand extends Command {
431
486
432
487
class AnalysisCommand extends ProcessCommand {
433
488
AnalysisCommand ._(String executable, List <String > arguments,
434
- Map <String , String > environmentOverrides)
435
- : super ._('dart2analyzer' , executable, arguments, environmentOverrides);
489
+ Map <String , String > environmentOverrides, {int index = 0 })
490
+ : super ._('dart2analyzer' , executable, arguments, environmentOverrides,
491
+ null , index);
492
+
493
+ AnalysisCommand indexedCopy (int index) =>
494
+ AnalysisCommand ._(executable, arguments, environmentOverrides,
495
+ index: index);
436
496
}
437
497
438
498
class CompareAnalyzerCfeCommand extends ProcessCommand {
439
499
CompareAnalyzerCfeCommand ._(String executable, List <String > arguments,
440
- Map <String , String > environmentOverrides)
500
+ Map <String , String > environmentOverrides, { int index = 0 } )
441
501
: super ._('compare_analyzer_cfe' , executable, arguments,
442
- environmentOverrides);
502
+ environmentOverrides, null , index);
503
+
504
+ CompareAnalyzerCfeCommand indexedCopy (int index) =>
505
+ CompareAnalyzerCfeCommand ._(executable, arguments, environmentOverrides,
506
+ index: index);
443
507
}
444
508
445
509
class SpecParseCommand extends ProcessCommand {
446
510
SpecParseCommand ._(String executable, List <String > arguments,
447
- Map <String , String > environmentOverrides)
448
- : super ._('spec_parser' , executable, arguments, environmentOverrides);
511
+ Map <String , String > environmentOverrides, {int index = 0 })
512
+ : super ._('spec_parser' , executable, arguments, environmentOverrides,
513
+ null , index);
514
+
515
+ SpecParseCommand indexedCopy (int index) =>
516
+ SpecParseCommand ._(executable, arguments, environmentOverrides,
517
+ index: index);
449
518
}
450
519
451
520
class VmCommand extends ProcessCommand {
452
521
VmCommand ._(String executable, List <String > arguments,
453
- Map <String , String > environmentOverrides)
454
- : super ._('vm' , executable, arguments, environmentOverrides);
522
+ Map <String , String > environmentOverrides,
523
+ {int index = 0 })
524
+ : super ._('vm' , executable, arguments, environmentOverrides, null , index);
525
+
526
+ VmCommand indexedCopy (int index) =>
527
+ VmCommand ._(executable, arguments, environmentOverrides, index: index);
455
528
}
456
529
457
530
class VmBatchCommand extends ProcessCommand implements VmCommand {
@@ -460,9 +533,14 @@ class VmBatchCommand extends ProcessCommand implements VmCommand {
460
533
461
534
VmBatchCommand ._(String executable, String dartFile, List <String > arguments,
462
535
Map <String , String > environmentOverrides,
463
- {this .checked: true })
536
+ {this .checked: true , int index = 0 })
464
537
: this .dartFile = dartFile,
465
- super ._('vm-batch' , executable, arguments, environmentOverrides);
538
+ super ._('vm-batch' , executable, arguments, environmentOverrides, null ,
539
+ index);
540
+
541
+ VmBatchCommand indexedCopy (int index) =>
542
+ VmBatchCommand ._(executable, dartFile, arguments, environmentOverrides,
543
+ checked: checked, index: index);
466
544
467
545
@override
468
546
List <String > get batchArguments =>
@@ -495,10 +573,18 @@ class AdbPrecompilationCommand extends Command {
495
573
this .processTestFilename,
496
574
this .precompiledTestDirectory,
497
575
this .arguments,
498
- this .useBlobs)
499
- : super ._("adb_precompilation" );
500
-
501
- void _buildHashCode (HashCodeBuilder builder) {
576
+ this .useBlobs,
577
+ {int index = 0 })
578
+ : super ._("adb_precompilation" , index: index);
579
+
580
+ AdbPrecompilationCommand indexedCopy (int index) => AdbPrecompilationCommand ._(
581
+ precompiledRunnerFilename,
582
+ processTestFilename,
583
+ precompiledTestDirectory,
584
+ arguments,
585
+ useBlobs,
586
+ index: index);
587
+ _buildHashCode (HashCodeBuilder builder) {
502
588
super ._buildHashCode (builder);
503
589
builder.add (precompiledRunnerFilename);
504
590
builder.add (precompiledTestDirectory);
@@ -520,13 +606,18 @@ class AdbPrecompilationCommand extends Command {
520
606
class JSCommandlineCommand extends ProcessCommand {
521
607
JSCommandlineCommand ._(
522
608
String displayName, String executable, List <String > arguments,
523
- [Map <String , String > environmentOverrides = null ])
524
- : super ._(displayName, executable, arguments, environmentOverrides);
609
+ [Map <String , String > environmentOverrides = null , int index = 0 ])
610
+ : super ._(displayName, executable, arguments, environmentOverrides, null ,
611
+ index);
612
+
613
+ JSCommandlineCommand indexedCopy (int index) => JSCommandlineCommand ._(
614
+ displayName, executable, arguments, environmentOverrides, index);
525
615
}
526
616
527
617
/// [ScriptCommand] s are executed by dart code.
528
618
abstract class ScriptCommand extends Command {
529
- ScriptCommand ._(String displayName) : super ._(displayName);
619
+ ScriptCommand ._(String displayName, {int index = 0 })
620
+ : super ._(displayName, index: index);
530
621
531
622
Future <ScriptCommandOutput > run ();
532
623
}
@@ -535,8 +626,13 @@ class CleanDirectoryCopyCommand extends ScriptCommand {
535
626
final String _sourceDirectory;
536
627
final String _destinationDirectory;
537
628
538
- CleanDirectoryCopyCommand ._(this ._sourceDirectory, this ._destinationDirectory)
539
- : super ._('dir_copy' );
629
+ CleanDirectoryCopyCommand ._(this ._sourceDirectory, this ._destinationDirectory,
630
+ {int index = 0 })
631
+ : super ._('dir_copy' , index: index);
632
+
633
+ CleanDirectoryCopyCommand indexedCopy (int index) =>
634
+ CleanDirectoryCopyCommand ._(_sourceDirectory, _destinationDirectory,
635
+ index: index);
540
636
541
637
String get reproductionCommand =>
542
638
"Copying '$_sourceDirectory ' to '$_destinationDirectory '." ;
@@ -581,7 +677,11 @@ class MakeSymlinkCommand extends ScriptCommand {
581
677
String _link;
582
678
String _target;
583
679
584
- MakeSymlinkCommand ._(this ._link, this ._target) : super ._('make_symlink' );
680
+ MakeSymlinkCommand ._(this ._link, this ._target, {int index = 0 })
681
+ : super ._('make_symlink' , index: index);
682
+
683
+ MakeSymlinkCommand indexedCopy (int index) =>
684
+ MakeSymlinkCommand ._(_link, _target, index: index);
585
685
586
686
String get reproductionCommand =>
587
687
"Make symbolic link '$_link ' (target: $_target )'." ;
0 commit comments