@@ -436,35 +436,39 @@ class TestCommand extends Command<bool> with ArgUtils {
436
436
'test' ,
437
437
));
438
438
439
- if (isUnitTestsScreenshotsAvailable) {
440
- // Separate screenshot tests from unit-tests. Screenshot tests must run
441
- // one at a time. Otherwise, they will end up screenshotting each other.
442
- // This is not an issue for unit-tests.
443
- final FilePath failureSmokeTestPath = FilePath .fromWebUi (
444
- 'test/golden_tests/golden_failure_smoke_test.dart' ,
445
- );
446
- final List <FilePath > screenshotTestFiles = < FilePath > [];
447
- final List <FilePath > unitTestFiles = < FilePath > [];
448
-
449
- for (io.File testFile
450
- in testDir.listSync (recursive: true ).whereType< io.File > ()) {
451
- final FilePath testFilePath = FilePath .fromCwd (testFile.path);
452
- if (! testFilePath.absolute.endsWith ('_test.dart' )) {
453
- // Not a test file at all. Skip.
454
- continue ;
455
- }
456
- if (testFilePath == failureSmokeTestPath) {
457
- // A smoke test that fails on purpose. Skip.
458
- continue ;
459
- }
439
+ // Separate screenshot tests from unit-tests. Screenshot tests must run
440
+ // one at a time. Otherwise, they will end up screenshotting each other.
441
+ // This is not an issue for unit-tests.
442
+ final FilePath failureSmokeTestPath = FilePath .fromWebUi (
443
+ 'test/golden_tests/golden_failure_smoke_test.dart' ,
444
+ );
445
+ final List <FilePath > screenshotTestFiles = < FilePath > [];
446
+ final List <FilePath > unitTestFiles = < FilePath > [];
447
+
448
+ for (io.File testFile
449
+ in testDir.listSync (recursive: true ).whereType< io.File > ()) {
450
+ final FilePath testFilePath = FilePath .fromCwd (testFile.path);
451
+ if (! testFilePath.absolute.endsWith ('_test.dart' )) {
452
+ // Not a test file at all. Skip.
453
+ continue ;
454
+ }
455
+ if (testFilePath == failureSmokeTestPath) {
456
+ // A smoke test that fails on purpose. Skip.
457
+ continue ;
458
+ }
460
459
461
- if (path.split (testFilePath.relativeToWebUi).contains ('golden_tests' )) {
462
- screenshotTestFiles.add (testFilePath);
463
- } else {
464
- unitTestFiles.add (testFilePath);
465
- }
460
+ // All files under test/golden_tests are considered golden tests.
461
+ final bool isUnderGoldenTestsDirectory = path.split (testFilePath.relativeToWebUi).contains ('golden_tests' );
462
+ // Any file whose name ends with "_golden_test.dart" is run as a golden test.
463
+ final bool isGoldenTestFile = path.basename (testFilePath.relativeToWebUi).endsWith ('_golden_test.dart' );
464
+ if (isUnderGoldenTestsDirectory || isGoldenTestFile) {
465
+ screenshotTestFiles.add (testFilePath);
466
+ } else {
467
+ unitTestFiles.add (testFilePath);
466
468
}
469
+ }
467
470
471
+ if (isUnitTestsScreenshotsAvailable) {
468
472
// This test returns a non-zero exit code on purpose. Run it separately.
469
473
if (io.Platform .environment['CIRRUS_CI' ] != 'true' ) {
470
474
await _runTestBatch (
@@ -474,11 +478,13 @@ class TestCommand extends Command<bool> with ArgUtils {
474
478
);
475
479
_checkExitCode ();
476
480
}
481
+ }
477
482
478
- // Run all unit-tests as a single batch.
479
- await _runTestBatch (unitTestFiles, concurrency: 10 , expectFailure: false );
480
- _checkExitCode ();
483
+ // Run all unit-tests as a single batch.
484
+ await _runTestBatch (unitTestFiles, concurrency: 10 , expectFailure: false );
485
+ _checkExitCode ();
481
486
487
+ if (isUnitTestsScreenshotsAvailable) {
482
488
// Run screenshot tests one at a time.
483
489
for (FilePath testFilePath in screenshotTestFiles) {
484
490
await _runTestBatch (
@@ -488,24 +494,6 @@ class TestCommand extends Command<bool> with ArgUtils {
488
494
);
489
495
_checkExitCode ();
490
496
}
491
- } else {
492
- final List <FilePath > unitTestFiles = < FilePath > [];
493
- for (io.File testFile
494
- in testDir.listSync (recursive: true ).whereType< io.File > ()) {
495
- final FilePath testFilePath = FilePath .fromCwd (testFile.path);
496
- if (! testFilePath.absolute.endsWith ('_test.dart' )) {
497
- // Not a test file at all. Skip.
498
- continue ;
499
- }
500
- if (! path
501
- .split (testFilePath.relativeToWebUi)
502
- .contains ('golden_tests' )) {
503
- unitTestFiles.add (testFilePath);
504
- }
505
- }
506
- // Run all unit-tests as a single batch.
507
- await _runTestBatch (unitTestFiles, concurrency: 10 , expectFailure: false );
508
- _checkExitCode ();
509
497
}
510
498
}
511
499
0 commit comments