Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Classes and methods for enumerating and preparing tests. | 6 * Classes and methods for enumerating and preparing tests. |
| 7 * | 7 * |
| 8 * This library includes: | 8 * This library includes: |
| 9 * | 9 * |
| 10 * - Creating tests by listing all the Dart files in certain directories, | 10 * - Creating tests by listing all the Dart files in certain directories, |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 * The executable lists its tests when run with the --list command line flag. | 349 * The executable lists its tests when run with the --list command line flag. |
| 350 * Individual tests are run by specifying them on the command line. | 350 * Individual tests are run by specifying them on the command line. |
| 351 */ | 351 */ |
| 352 class CCTestSuite extends TestSuite { | 352 class CCTestSuite extends TestSuite { |
| 353 final String testPrefix; | 353 final String testPrefix; |
| 354 String targetRunnerPath; | 354 String targetRunnerPath; |
| 355 String hostRunnerPath; | 355 String hostRunnerPath; |
| 356 final String dartDir; | 356 final String dartDir; |
| 357 List<String> statusFilePaths; | 357 List<String> statusFilePaths; |
| 358 VoidFunction doDone; | 358 VoidFunction doDone; |
| 359 TestExpectations testExpectations; | |
| 360 | 359 |
| 361 CCTestSuite(Map configuration, | 360 CCTestSuite(Map configuration, |
| 362 String suiteName, | 361 String suiteName, |
| 363 String runnerName, | 362 String runnerName, |
| 364 List<String> this.statusFilePaths, | 363 this.statusFilePaths, |
| 365 {this.testPrefix: ''}) | 364 {this.testPrefix: ''}) |
| 366 : super(configuration, suiteName), | 365 : super(configuration, suiteName), |
| 367 dartDir = TestUtils.dartDir().toNativePath() { | 366 dartDir = TestUtils.dartDir().toNativePath() { |
| 368 // For running the tests we use the given '$runnerName' binary | 367 // For running the tests we use the given '$runnerName' binary |
| 369 targetRunnerPath = '$buildDir/$runnerName'; | 368 targetRunnerPath = '$buildDir/$runnerName'; |
| 370 | 369 |
| 371 // For listing the tests we use the '$runnerName.host' binary if it exists | 370 // For listing the tests we use the '$runnerName.host' binary if it exists |
| 372 // and use '$runnerName' if it doesn't. | 371 // and use '$runnerName' if it doesn't. |
| 373 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; | 372 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; |
| 374 var hostBinary = '$targetRunnerPath.host$binarySuffix'; | 373 var hostBinary = '$targetRunnerPath.host$binarySuffix'; |
| 375 if (new File(hostBinary).existsSync()) { | 374 if (new File(hostBinary).existsSync()) { |
| 376 hostRunnerPath = hostBinary; | 375 hostRunnerPath = hostBinary; |
| 377 } else { | 376 } else { |
| 378 hostRunnerPath = targetRunnerPath; | 377 hostRunnerPath = targetRunnerPath; |
| 379 } | 378 } |
| 380 } | 379 } |
| 381 | 380 |
| 382 void testNameHandler(String testName) { | 381 void testNameHandler(TestExpectations testExpectations, String testName) { |
| 383 // Only run the tests that match the pattern. Use the name | 382 // Only run the tests that match the pattern. Use the name |
| 384 // "suiteName/testName" for cc tests. | 383 // "suiteName/testName" for cc tests. |
| 385 String constructedName = '$suiteName/$testPrefix$testName'; | 384 String constructedName = '$suiteName/$testPrefix$testName'; |
| 386 | 385 |
| 387 var expectations = testExpectations.expectations( | 386 var expectations = testExpectations.expectations( |
| 388 '$testPrefix$testName'); | 387 '$testPrefix$testName'); |
| 389 | 388 |
| 390 var args = TestUtils.standardOptions(configuration); | 389 var args = TestUtils.standardOptions(configuration); |
| 391 args.add(testName); | 390 args.add(testName); |
| 392 | 391 |
| 393 var command = CommandBuilder.instance.getProcessCommand( | 392 var command = CommandBuilder.instance.getProcessCommand( |
| 394 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); | 393 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); |
| 395 enqueueNewTestCase( | 394 enqueueNewTestCase( |
| 396 new TestCase(constructedName, [command], configuration, expectations)); | 395 new TestCase(constructedName, [command], configuration, expectations)); |
| 397 } | 396 } |
| 398 | 397 |
| 399 void forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) { | 398 void forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) { |
| 400 doTest = onTest; | 399 doTest = onTest; |
| 401 doDone = onDone; | 400 doDone = onDone; |
| 402 | 401 |
| 403 var filesRead = 0; | 402 var statusFiles = |
| 404 void statusFileRead() { | 403 statusFilePaths.map((statusFile) => "$dartDir/$statusFile").toList(); |
| 405 filesRead++; | |
| 406 if (filesRead == statusFilePaths.length) { | |
| 407 ccTestLister(hostRunnerPath).then((Iterable<String> names) { | |
| 408 names.forEach(testNameHandler); | |
| 409 onDone(); | |
| 410 }).catchError((error) { | |
| 411 print("Fatal error occured: $error"); | |
| 412 exit(1); | |
| 413 }); | |
| 414 } | |
| 415 } | |
| 416 | 404 |
| 417 testExpectations = new TestExpectations(); | 405 ReadTestExpectations(statusFiles, configuration) |
| 418 for (var statusFilePath in statusFilePaths) { | 406 .then((TestExpectations expectations) { |
| 419 ReadTestExpectationsInto(testExpectations, | 407 ccTestLister(hostRunnerPath).then((Iterable<String> names) { |
| 420 '$dartDir/$statusFilePath', | 408 names.forEach((testName) => testNameHandler(expectations, testName)); |
| 421 configuration, | 409 onDone(); |
| 422 statusFileRead); | 410 }).catchError((error) { |
| 423 } | 411 print("Fatal error occured: $error"); |
| 412 exit(1); | |
| 413 }); | |
| 414 }); | |
| 424 } | 415 } |
| 425 } | 416 } |
| 426 | 417 |
| 427 | 418 |
| 428 class TestInformation { | 419 class TestInformation { |
| 429 Path originTestPath; | 420 Path originTestPath; |
| 430 Path filePath; | 421 Path filePath; |
| 431 Map optionsFromFile; | 422 Map optionsFromFile; |
| 432 bool hasCompileError; | 423 bool hasCompileError; |
| 433 bool hasRuntimeError; | 424 bool hasRuntimeError; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 assert(updater.isActive); | 568 assert(updater.isActive); |
| 578 updater.onUpdated.add(() => completer.complete(null)); | 569 updater.onUpdated.add(() => completer.complete(null)); |
| 579 | 570 |
| 580 return completer.future; | 571 return completer.future; |
| 581 } | 572 } |
| 582 | 573 |
| 583 /** | 574 /** |
| 584 * Reads the status files and completes with the parsed expectations. | 575 * Reads the status files and completes with the parsed expectations. |
| 585 */ | 576 */ |
| 586 Future<TestExpectations> readExpectations() { | 577 Future<TestExpectations> readExpectations() { |
| 587 var completer = new Completer(); | 578 var statusFiles = statusFilePaths |
| 588 var expectations = new TestExpectations(); | 579 .where((String statusFilePath) { |
|
ricow1
2014/01/06 13:25:19
move where up and indent 2
kustermann
2014/01/06 13:56:32
Done.
| |
| 580 // [forDirectory] adds name_$compiler.status for all tests suites. | |
| 581 // Use it if it exists, but otherwise skip it and don't fail. | |
| 582 if (statusFilePath.endsWith('_dart2js.status') || | |
| 583 statusFilePath.endsWith('_analyzer.status') || | |
| 584 statusFilePath.endsWith('_analyzer2.status')) { | |
| 585 var file = new File(dartDir.append(statusFilePath).toNativePath()); | |
| 586 return file.existsSync(); | |
| 587 } | |
| 588 return true; | |
| 589 }).map((statusFilePath) { | |
| 590 return dartDir.append(statusFilePath).toNativePath(); | |
| 591 }).toList(); | |
| 589 | 592 |
| 590 var filesRead = 0; | 593 return ReadTestExpectations(statusFiles, configuration); |
| 591 void statusFileRead() { | |
| 592 filesRead++; | |
| 593 if (filesRead == statusFilePaths.length) { | |
| 594 completer.complete(expectations); | |
| 595 } | |
| 596 } | |
| 597 | |
| 598 for (var statusFilePath in statusFilePaths) { | |
| 599 // [forDirectory] adds name_$compiler.status for all tests suites. Use it | |
| 600 // if it exists, but otherwise skip it and don't fail. | |
| 601 if (statusFilePath.endsWith('_dart2js.status') || | |
| 602 statusFilePath.endsWith('_analyzer.status') || | |
| 603 statusFilePath.endsWith('_analyzer2.status')) { | |
| 604 var file = new File(dartDir.append(statusFilePath).toNativePath()); | |
| 605 if (!file.existsSync()) { | |
| 606 filesRead++; | |
| 607 continue; | |
| 608 } | |
| 609 } | |
| 610 | |
| 611 ReadTestExpectationsInto(expectations, | |
| 612 dartDir.append(statusFilePath).toNativePath(), | |
| 613 configuration, statusFileRead); | |
| 614 } | |
| 615 | |
| 616 return completer.future; | |
| 617 } | 594 } |
| 618 | 595 |
| 619 Future enqueueTests() { | 596 Future enqueueTests() { |
| 620 Directory dir = new Directory(suiteDir.toNativePath()); | 597 Directory dir = new Directory(suiteDir.toNativePath()); |
| 621 return dir.exists().then((exists) { | 598 return dir.exists().then((exists) { |
| 622 if (!exists) { | 599 if (!exists) { |
| 623 print('Directory containing tests missing: ${suiteDir.toNativePath()}'); | 600 print('Directory containing tests missing: ${suiteDir.toNativePath()}'); |
| 624 return new Future.value(null); | 601 return new Future.value(null); |
| 625 } else { | 602 } else { |
| 626 var group = new FutureGroup(); | 603 var group = new FutureGroup(); |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1879 * $pass tests are expected to pass | 1856 * $pass tests are expected to pass |
| 1880 * $failOk tests are expected to fail that we won't fix | 1857 * $failOk tests are expected to fail that we won't fix |
| 1881 * $fail tests are expected to fail that we should fix | 1858 * $fail tests are expected to fail that we should fix |
| 1882 * $crash tests are expected to crash that we should fix | 1859 * $crash tests are expected to crash that we should fix |
| 1883 * $timeout tests are allowed to timeout | 1860 * $timeout tests are allowed to timeout |
| 1884 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1861 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1885 """; | 1862 """; |
| 1886 print(report); | 1863 print(report); |
| 1887 } | 1864 } |
| 1888 } | 1865 } |
| OLD | NEW |