| 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 var listCompleter = new Completer(); | 585 var listCompleter = new Completer(); |
| 586 group.add(listCompleter.future); | 586 group.add(listCompleter.future); |
| 587 | 587 |
| 588 var lister = dir.list(recursive: listRecursively); | 588 var lister = dir.list(recursive: listRecursively); |
| 589 lister.onFile = (file) => enqueueFile(file, group); | 589 lister.onFile = (file) => enqueueFile(file, group); |
| 590 lister.onDone = listCompleter.complete; | 590 lister.onDone = listCompleter.complete; |
| 591 } | 591 } |
| 592 | 592 |
| 593 void enqueueFile(String filename, FutureGroup group) { | 593 void enqueueFile(String filename, FutureGroup group) { |
| 594 if (!isTestFile(filename)) return; | 594 if (!isTestFile(filename)) return; |
| 595 Path filePath = new Path.fromNative(filename); | 595 Path filePath = new Path(filename); |
| 596 | 596 |
| 597 // Only run the tests that match the pattern. | 597 // Only run the tests that match the pattern. |
| 598 RegExp pattern = configuration['selectors'][suiteName]; | 598 RegExp pattern = configuration['selectors'][suiteName]; |
| 599 if (!pattern.hasMatch('$filePath')) return; | 599 if (!pattern.hasMatch('$filePath')) return; |
| 600 if (filePath.filename.endsWith('test_config.dart')) return; | 600 if (filePath.filename.endsWith('test_config.dart')) return; |
| 601 | 601 |
| 602 var optionsFromFile = readOptionsFromFile(filePath); | 602 var optionsFromFile = readOptionsFromFile(filePath); |
| 603 CreateTest createTestCase = makeTestCaseCreator(optionsFromFile); | 603 CreateTest createTestCase = makeTestCaseCreator(optionsFromFile); |
| 604 | 604 |
| 605 if (optionsFromFile['isMultitest']) { | 605 if (optionsFromFile['isMultitest']) { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 if (new File.fromPath(pngPath).existsSync()) { | 903 if (new File.fromPath(pngPath).existsSync()) { |
| 904 expectedOutput = pngPath; | 904 expectedOutput = pngPath; |
| 905 // TODO(efortuna): Unify path libraries in test.dart. | 905 // TODO(efortuna): Unify path libraries in test.dart. |
| 906 content = getHtmlLayoutContents(scriptType, pathLib.relative(scriptPath, | 906 content = getHtmlLayoutContents(scriptType, pathLib.relative(scriptPath, |
| 907 from: pathLib.dirname(htmlPath))); | 907 from: pathLib.dirname(htmlPath))); |
| 908 } else if (new File.fromPath(txtPath).existsSync()) { | 908 } else if (new File.fromPath(txtPath).existsSync()) { |
| 909 expectedOutput = txtPath; | 909 expectedOutput = txtPath; |
| 910 content = getHtmlLayoutContents(scriptType, pathLib.relative(scriptPath, | 910 content = getHtmlLayoutContents(scriptType, pathLib.relative(scriptPath, |
| 911 from: pathLib.dirname(htmlPath))); | 911 from: pathLib.dirname(htmlPath))); |
| 912 } else { | 912 } else { |
| 913 final htmlLocation = new Path.fromNative(htmlPath); | 913 final htmlLocation = new Path(htmlPath); |
| 914 content = getHtmlContents( | 914 content = getHtmlContents( |
| 915 filename, | 915 filename, |
| 916 dartDir.append('pkg/unittest/test_controller.js') | 916 dartDir.append('pkg/unittest/test_controller.js') |
| 917 .relativeTo(htmlLocation), | 917 .relativeTo(htmlLocation), |
| 918 dartDir.append('pkg/browser/lib/dart.js').relativeTo(htmlLocation), | 918 dartDir.append('pkg/browser/lib/dart.js').relativeTo(htmlLocation), |
| 919 scriptType, | 919 scriptType, |
| 920 new Path.fromNative(scriptPath).relativeTo(htmlLocation)); | 920 new Path(scriptPath).relativeTo(htmlLocation)); |
| 921 } | 921 } |
| 922 htmlTest.writeStringSync(content); | 922 htmlTest.writeStringSync(content); |
| 923 htmlTest.closeSync(); | 923 htmlTest.closeSync(); |
| 924 | 924 |
| 925 // Construct the command(s) that compile all the inputs needed by the | 925 // Construct the command(s) that compile all the inputs needed by the |
| 926 // browser test. For running Dart in DRT, this will be noop commands. | 926 // browser test. For running Dart in DRT, this will be noop commands. |
| 927 List<Command> commands = []; | 927 List<Command> commands = []; |
| 928 if (compiler != 'none') { | 928 if (compiler != 'none') { |
| 929 commands.add(_compileCommand( | 929 commands.add(_compileCommand( |
| 930 dartWrapperFilename, compiledDartWrapperFilename, | 930 dartWrapperFilename, compiledDartWrapperFilename, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 // Create '[build dir]/generated_tests/$compiler-$runtime/$testUniqueName', | 1103 // Create '[build dir]/generated_tests/$compiler-$runtime/$testUniqueName', |
| 1104 // including any intermediate directories that don't exist. | 1104 // including any intermediate directories that don't exist. |
| 1105 // If the tests are run in checked or minified mode we add that to the | 1105 // If the tests are run in checked or minified mode we add that to the |
| 1106 // '$compile-$runtime' directory name. | 1106 // '$compile-$runtime' directory name. |
| 1107 var checked = configuration['checked'] ? '-checked' : ''; | 1107 var checked = configuration['checked'] ? '-checked' : ''; |
| 1108 var minified = configuration['minified'] ? '-minified' : ''; | 1108 var minified = configuration['minified'] ? '-minified' : ''; |
| 1109 var dirName = "${configuration['compiler']}-${configuration['runtime']}" | 1109 var dirName = "${configuration['compiler']}-${configuration['runtime']}" |
| 1110 "$checked$minified"; | 1110 "$checked$minified"; |
| 1111 Path generatedTestPath = new Path.fromNative(dartDir.toNativePath()) | 1111 Path generatedTestPath = new Path(dartDir.toNativePath()) |
| 1112 .append(buildDir) | 1112 .append(buildDir) |
| 1113 .append('generated_tests') | 1113 .append('generated_tests') |
| 1114 .append(dirName) | 1114 .append(dirName) |
| 1115 .append(testUniqueName); | 1115 .append(testUniqueName); |
| 1116 | 1116 |
| 1117 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); | 1117 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); |
| 1118 return new File.fromPath(generatedTestPath).fullPathSync() | 1118 return new File.fromPath(generatedTestPath).fullPathSync() |
| 1119 .replaceAll('\\', '/'); | 1119 .replaceAll('\\', '/'); |
| 1120 } | 1120 } |
| 1121 | 1121 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 class DartcCompilationTestSuite extends StandardTestSuite { | 1442 class DartcCompilationTestSuite extends StandardTestSuite { |
| 1443 List<String> _testDirs; | 1443 List<String> _testDirs; |
| 1444 | 1444 |
| 1445 DartcCompilationTestSuite(Map configuration, | 1445 DartcCompilationTestSuite(Map configuration, |
| 1446 String suiteName, | 1446 String suiteName, |
| 1447 String directoryPath, | 1447 String directoryPath, |
| 1448 List<String> this._testDirs, | 1448 List<String> this._testDirs, |
| 1449 List<String> expectations) | 1449 List<String> expectations) |
| 1450 : super(configuration, | 1450 : super(configuration, |
| 1451 suiteName, | 1451 suiteName, |
| 1452 new Path.fromNative(directoryPath), | 1452 new Path(directoryPath), |
| 1453 expectations); | 1453 expectations); |
| 1454 | 1454 |
| 1455 List<String> additionalOptions(Path filePath) { | 1455 List<String> additionalOptions(Path filePath) { |
| 1456 return ['--fatal-warnings', '--fatal-type-errors']; | 1456 return ['--fatal-warnings', '--fatal-type-errors']; |
| 1457 } | 1457 } |
| 1458 | 1458 |
| 1459 Future enqueueTests() { | 1459 Future enqueueTests() { |
| 1460 var group = new FutureGroup(); | 1460 var group = new FutureGroup(); |
| 1461 | 1461 |
| 1462 for (String testDir in _testDirs) { | 1462 for (String testDir in _testDirs) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 class TestUtils { | 1611 class TestUtils { |
| 1612 /** | 1612 /** |
| 1613 * The libraries in this directory relies on finding various files | 1613 * The libraries in this directory relies on finding various files |
| 1614 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If | 1614 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If |
| 1615 * the main script using 'test_suite.dart' is not there, the main | 1615 * the main script using 'test_suite.dart' is not there, the main |
| 1616 * script must set this to '.../dart/tools/test.dart'. | 1616 * script must set this to '.../dart/tools/test.dart'. |
| 1617 */ | 1617 */ |
| 1618 static String testScriptPath = new Options().script; | 1618 static String testScriptPath = new Options().script; |
| 1619 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); | 1619 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); |
| 1620 static Path currentWorkingDirectory = | 1620 static Path currentWorkingDirectory = |
| 1621 new Path.fromNative(new Directory.current().path); | 1621 new Path(new Directory.current().path); |
| 1622 /** | 1622 /** |
| 1623 * Creates a directory using a [relativePath] to an existing | 1623 * Creates a directory using a [relativePath] to an existing |
| 1624 * [base] directory if that [relativePath] does not already exist. | 1624 * [base] directory if that [relativePath] does not already exist. |
| 1625 */ | 1625 */ |
| 1626 static Directory mkdirRecursive(Path base, Path relativePath) { | 1626 static Directory mkdirRecursive(Path base, Path relativePath) { |
| 1627 if (relativePath.isAbsolute) { | 1627 if (relativePath.isAbsolute) { |
| 1628 base = new Path('/'); | 1628 base = new Path('/'); |
| 1629 } | 1629 } |
| 1630 Directory dir = new Directory.fromPath(base); | 1630 Directory dir = new Directory.fromPath(base); |
| 1631 Expect.isTrue(dir.existsSync(), | 1631 Expect.isTrue(dir.existsSync(), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 } else if (system == 'macos') { | 1690 } else if (system == 'macos') { |
| 1691 result = 'xcodebuild/'; | 1691 result = 'xcodebuild/'; |
| 1692 } else if (system == 'windows') { | 1692 } else if (system == 'windows') { |
| 1693 result = 'build/'; | 1693 result = 'build/'; |
| 1694 } | 1694 } |
| 1695 return result; | 1695 return result; |
| 1696 } | 1696 } |
| 1697 | 1697 |
| 1698 static Path dartDir() { | 1698 static Path dartDir() { |
| 1699 File scriptFile = new File(testScriptPath); | 1699 File scriptFile = new File(testScriptPath); |
| 1700 Path scriptPath = new Path.fromNative(scriptFile.fullPathSync()); | 1700 Path scriptPath = new Path(scriptFile.fullPathSync()); |
| 1701 return scriptPath.directoryPath.directoryPath; | 1701 return scriptPath.directoryPath.directoryPath; |
| 1702 } | 1702 } |
| 1703 | 1703 |
| 1704 static List<String> standardOptions(Map configuration) { | 1704 static List<String> standardOptions(Map configuration) { |
| 1705 List args = ["--ignore-unrecognized-flags"]; | 1705 List args = ["--ignore-unrecognized-flags"]; |
| 1706 if (configuration["checked"]) { | 1706 if (configuration["checked"]) { |
| 1707 args.add('--enable_asserts'); | 1707 args.add('--enable_asserts'); |
| 1708 args.add("--enable_type_checks"); | 1708 args.add("--enable_type_checks"); |
| 1709 } | 1709 } |
| 1710 String compiler = configuration["compiler"]; | 1710 String compiler = configuration["compiler"]; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 * $pass tests are expected to pass | 1839 * $pass tests are expected to pass |
| 1840 * $failOk tests are expected to fail that we won't fix | 1840 * $failOk tests are expected to fail that we won't fix |
| 1841 * $fail tests are expected to fail that we should fix | 1841 * $fail tests are expected to fail that we should fix |
| 1842 * $crash tests are expected to crash that we should fix | 1842 * $crash tests are expected to crash that we should fix |
| 1843 * $timeout tests are allowed to timeout | 1843 * $timeout tests are allowed to timeout |
| 1844 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1844 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1845 """; | 1845 """; |
| 1846 print(report); | 1846 print(report); |
| 1847 } | 1847 } |
| 1848 } | 1848 } |
| OLD | NEW |