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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 Set<String> expectations = testExpectations.expectations(testName); | 388 Set<String> expectations = testExpectations.expectations(testName); |
| 389 if (configuration['report']) { | 389 if (configuration['report']) { |
| 390 // Tests with multiple VMOptions are counted more than once. | 390 // Tests with multiple VMOptions are counted more than once. |
| 391 for (var dummy in getVmOptions(optionsFromFile)) { | 391 for (var dummy in getVmOptions(optionsFromFile)) { |
| 392 SummaryReport.add(expectations); | 392 SummaryReport.add(expectations); |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 if (expectations.contains(SKIP)) return; | 395 if (expectations.contains(SKIP)) return; |
| 396 | 396 |
| 397 if (TestUtils.isBrowserRuntime(configuration['runtime'])) { | 397 if (TestUtils.isBrowserRuntime(configuration['runtime'])) { |
| 398 enqueueBrowserTest(info, testName, expectations); | 398 bool isWrappingRequired = configuration['compiler'] != 'dart2js' |
| 399 || configuration['runtime'] != 'drt'; | |
|
kasperl
2012/09/11 11:12:15
4 space indent?
| |
| 400 enqueueBrowserTest(info, testName, expectations, isWrappingRequired); | |
| 399 } else { | 401 } else { |
| 400 enqueueStandardTest(info, testName, expectations); | 402 enqueueStandardTest(info, testName, expectations); |
| 401 } | 403 } |
| 402 } | 404 } |
| 403 | 405 |
| 404 void enqueueStandardTest(TestInformation info, | 406 void enqueueStandardTest(TestInformation info, |
| 405 String testName, | 407 String testName, |
| 406 Set<String> expectations) { | 408 Set<String> expectations) { |
| 407 bool isNegative = info.isNegative || | 409 bool isNegative = info.isNegative || |
| 408 (configuration['checked'] && info.isNegativeIfChecked); | 410 (configuration['checked'] && info.isNegativeIfChecked); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 suiteDir, | 524 suiteDir, |
| 523 createTestCase, | 525 createTestCase, |
| 524 testGeneratorDone); | 526 testGeneratorDone); |
| 525 } else { | 527 } else { |
| 526 createTestCase(filePath, optionsFromFile['isNegative']); | 528 createTestCase(filePath, optionsFromFile['isNegative']); |
| 527 } | 529 } |
| 528 } | 530 } |
| 529 | 531 |
| 530 /** | 532 /** |
| 531 * The [StandardTestSuite] has support for tests that | 533 * The [StandardTestSuite] has support for tests that |
| 532 * compile a test from Dart to Javascript, and then run the resulting | 534 * compile a test from Dart to JavaScript, and then run the resulting |
| 533 * Javascript. This function creates a working directory to hold the | 535 * JavaScript. This function creates a working directory to hold the |
| 534 * Javascript version of the test, and copies the appropriate framework | 536 * JavaScript version of the test, and copies the appropriate framework |
| 535 * files to that directory. It creates a [BrowserTestCase], which has | 537 * files to that directory. It creates a [BrowserTestCase], which has |
| 536 * two sequential steps to be run by the [ProcessQueue when] the test is | 538 * two sequential steps to be run by the [ProcessQueue] when the test is |
| 537 * executed: a compilation | 539 * executed: a compilation |
| 538 * step and an execution step, both with the appropriate executable and | 540 * step and an execution step, both with the appropriate executable and |
| 539 * arguments. | 541 * arguments. |
| 540 */ | 542 */ |
| 541 void enqueueBrowserTest(TestInformation info, | 543 void enqueueBrowserTest(TestInformation info, |
| 542 String testName, | 544 String testName, |
| 543 Set<String> expectations) { | 545 Set<String> expectations, |
| 546 bool isWrappingRequired) { | |
| 544 Map optionsFromFile = info.optionsFromFile; | 547 Map optionsFromFile = info.optionsFromFile; |
| 545 Path filePath = info.filePath; | 548 Path filePath = info.filePath; |
| 546 String filename = filePath.toString(); | 549 String filename = filePath.toString(); |
| 547 bool isWebTest = optionsFromFile['containsDomImport']; | 550 bool isWebTest = optionsFromFile['containsDomImport']; |
| 548 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; | 551 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; |
| 549 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { | 552 if (isWrappingRequired |
| 553 && !isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { | |
| 550 print('Warning for $filename: Browser tests require #library ' | 554 print('Warning for $filename: Browser tests require #library ' |
| 551 'in any file that uses #import, #source, or #resource'); | 555 'in any file that uses #import, #source, or #resource'); |
| 552 } | 556 } |
| 553 | 557 |
| 554 final String compiler = configuration['compiler']; | 558 final String compiler = configuration['compiler']; |
| 555 final String runtime = configuration['runtime']; | 559 final String runtime = configuration['runtime']; |
| 556 | 560 |
| 557 for (var vmOptions in getVmOptions(optionsFromFile)) { | 561 for (var vmOptions in getVmOptions(optionsFromFile)) { |
| 558 // Create a unique temporary directory for each set of vmOptions. | 562 // Create a unique temporary directory for each set of vmOptions. |
| 559 // TODO(dart:429): Replace separate replaceAlls with a RegExp when | 563 // TODO(dart:429): Replace separate replaceAlls with a RegExp when |
| 560 // replaceAll(RegExp, String) is implemented. | 564 // replaceAll(RegExp, String) is implemented. |
| 561 String optionsName = ''; | 565 String optionsName = ''; |
| 562 if (getVmOptions(optionsFromFile).length > 1) { | 566 if (getVmOptions(optionsFromFile).length > 1) { |
| 563 optionsName = Strings.join(vmOptions, '-').replaceAll('-','') | 567 optionsName = Strings.join(vmOptions, '-').replaceAll('-','') |
| 564 .replaceAll('=','') | 568 .replaceAll('=','') |
| 565 .replaceAll('/',''); | 569 .replaceAll('/',''); |
| 566 } | 570 } |
| 567 final String tempDir = createOutputDirectory(info.filePath, optionsName); | 571 final String tempDir = createOutputDirectory(info.filePath, optionsName); |
| 568 | 572 |
| 569 String dartWrapperFilename = '$tempDir/test.dart'; | 573 String dartWrapperFilename = '$tempDir/test.dart'; |
| 570 String compiledDartWrapperFilename = '$tempDir/test.js'; | 574 String compiledDartWrapperFilename = '$tempDir/test.js'; |
| 571 | 575 |
| 572 String htmlPath = '$tempDir/test.html'; | 576 String htmlPath = '$tempDir/test.html'; |
| 573 if (!isWebTest) { | 577 if (isWrappingRequired && !isWebTest) { |
| 574 // test.dart will import the dart test directly, if it is a library, | 578 // test.dart will import the dart test directly, if it is a library, |
| 575 // or indirectly through test_as_library.dart, if it is not. | 579 // or indirectly through test_as_library.dart, if it is not. |
| 576 Path dartLibraryFilename = filePath; | 580 Path dartLibraryFilename = filePath; |
| 577 if (!isLibraryDefinition) { | 581 if (!isLibraryDefinition) { |
| 578 dartLibraryFilename = new Path('test_as_library.dart'); | 582 dartLibraryFilename = new Path('test_as_library.dart'); |
| 579 File file = new File('$tempDir/$dartLibraryFilename'); | 583 File file = new File('$tempDir/$dartLibraryFilename'); |
| 580 RandomAccessFile dartLibrary = file.openSync(FileMode.WRITE); | 584 RandomAccessFile dartLibrary = file.openSync(FileMode.WRITE); |
| 581 dartLibrary.writeStringSync(wrapDartTestInLibrary(filePath)); | 585 dartLibrary.writeStringSync(wrapDartTestInLibrary(filePath)); |
| 582 dartLibrary.closeSync(); | 586 dartLibrary.closeSync(); |
| 583 } | 587 } |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1413 * $noCrash tests are expected to be flaky but not crash | 1417 * $noCrash tests are expected to be flaky but not crash |
| 1414 * $pass tests are expected to pass | 1418 * $pass tests are expected to pass |
| 1415 * $failOk tests are expected to fail that we won't fix | 1419 * $failOk tests are expected to fail that we won't fix |
| 1416 * $fail tests are expected to fail that we should fix | 1420 * $fail tests are expected to fail that we should fix |
| 1417 * $crash tests are expected to crash that we should fix | 1421 * $crash tests are expected to crash that we should fix |
| 1418 * $timeout tests are allowed to timeout | 1422 * $timeout tests are allowed to timeout |
| 1419 """; | 1423 """; |
| 1420 print(report); | 1424 print(report); |
| 1421 } | 1425 } |
| 1422 } | 1426 } |
| OLD | NEW |