| 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 Map configuration, Path directory) { | 461 Map configuration, Path directory) { |
| 462 final name = directory.filename; | 462 final name = directory.filename; |
| 463 | 463 |
| 464 return new StandardTestSuite(configuration, | 464 return new StandardTestSuite(configuration, |
| 465 name, directory, | 465 name, directory, |
| 466 ['$directory/$name.status', '$directory/${name}_dart2js.status'], | 466 ['$directory/$name.status', '$directory/${name}_dart2js.status'], |
| 467 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'), | 467 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'), |
| 468 recursive: true); | 468 recursive: true); |
| 469 } | 469 } |
| 470 | 470 |
| 471 Collection<Uri> get dart2JsBootstrapDependencies { | 471 List<Uri> get dart2JsBootstrapDependencies { |
| 472 if (!useSdk) return []; | 472 if (!useSdk) return []; |
| 473 | 473 |
| 474 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join( | 474 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join( |
| 475 new Path('dart-sdk/bin/snapshots/' | 475 new Path('dart-sdk/bin/snapshots/' |
| 476 'utils_wrapper.dart.snapshot'))).toString(); | 476 'utils_wrapper.dart.snapshot'))).toString(); |
| 477 return [new Uri.fromComponents(scheme: 'file', path: snapshotPath)]; | 477 return [new Uri.fromComponents(scheme: 'file', path: snapshotPath)]; |
| 478 } | 478 } |
| 479 | 479 |
| 480 /** | 480 /** |
| 481 * The default implementation assumes a file is a test if | 481 * The default implementation assumes a file is a test if |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 // Note: If we run test.py with the "--list" option, no http servers | 846 // Note: If we run test.py with the "--list" option, no http servers |
| 847 // will be started. So we use PORT/CROSS_ORIGIN_PORT instead of real ports. | 847 // will be started. So we use PORT/CROSS_ORIGIN_PORT instead of real ports. |
| 848 var serverPort = "PORT"; | 848 var serverPort = "PORT"; |
| 849 var crossOriginPort = "CROSS_ORIGIN_PORT"; | 849 var crossOriginPort = "CROSS_ORIGIN_PORT"; |
| 850 if (!configuration['list']) { | 850 if (!configuration['list']) { |
| 851 assert(configuration.containsKey('_servers_')); | 851 assert(configuration.containsKey('_servers_')); |
| 852 serverPort = configuration['_servers_'].port; | 852 serverPort = configuration['_servers_'].port; |
| 853 crossOriginPort = configuration['_servers_'].crossOriginPort; | 853 crossOriginPort = configuration['_servers_'].crossOriginPort; |
| 854 } | 854 } |
| 855 | 855 |
| 856 var url= 'http://127.0.0.1:$serverPort$pathComponent' | 856 var local_ip = configuration['local_ip']; |
| 857 var url= 'http://$local_ip:$serverPort$pathComponent' |
| 857 '?crossOriginPort=$crossOriginPort'; | 858 '?crossOriginPort=$crossOriginPort'; |
| 858 if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) { | 859 if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) { |
| 859 url= '${url}&group=${subtestNames[subtestIndex]}'; | 860 url= '${url}&group=${subtestNames[subtestIndex]}'; |
| 860 } | 861 } |
| 861 return url; | 862 return url; |
| 862 } | 863 } |
| 863 | 864 |
| 864 void _createWrapperFile(String dartWrapperFilename, dartLibraryFilename) { | 865 void _createWrapperFile(String dartWrapperFilename, dartLibraryFilename) { |
| 865 File file = new File(dartWrapperFilename); | 866 File file = new File(dartWrapperFilename); |
| 866 RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE); | 867 RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE); |
| 867 | 868 |
| 868 var usePackageImport = dartLibraryFilename.segments().contains("pkg"); | 869 var usePackageImport = dartLibraryFilename.segments().contains("pkg"); |
| 869 var libraryPathComponent = _createUrlPathFromFile(dartLibraryFilename); | 870 var libraryPathComponent = _createUrlPathFromFile(dartLibraryFilename); |
| 870 dartWrapper.writeStringSync(dartTestWrapper(usePackageImport, | 871 dartWrapper.writeStringSync(dartTestWrapper(usePackageImport, |
| 871 libraryPathComponent)); | 872 libraryPathComponent)); |
| 872 dartWrapper.closeSync(); | 873 dartWrapper.closeSync(); |
| 873 } | 874 } |
| 874 | 875 |
| 876 |
| 875 /** | 877 /** |
| 876 * The [StandardTestSuite] has support for tests that | 878 * The [StandardTestSuite] has support for tests that |
| 877 * compile a test from Dart to JavaScript, and then run the resulting | 879 * compile a test from Dart to JavaScript, and then run the resulting |
| 878 * JavaScript. This function creates a working directory to hold the | 880 * JavaScript. This function creates a working directory to hold the |
| 879 * JavaScript version of the test, and copies the appropriate framework | 881 * JavaScript version of the test, and copies the appropriate framework |
| 880 * files to that directory. It creates a [BrowserTestCase], which has | 882 * files to that directory. It creates a [BrowserTestCase], which has |
| 881 * two sequential steps to be run by the [ProcessQueue] when the test is | 883 * two sequential steps to be run by the [ProcessQueue] when the test is |
| 882 * executed: a compilation step and an execution step, both with the | 884 * executed: a compilation step and an execution step, both with the |
| 883 * appropriate executable and arguments. The [expectations] object can be | 885 * appropriate executable and arguments. The [expectations] object can be |
| 884 * either a Set<String> if the test is a regular test, or a Map<String | 886 * either a Set<String> if the test is a regular test, or a Map<String |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 } | 970 } |
| 969 if (compiler == 'none') { | 971 if (compiler == 'none') { |
| 970 // For the tests that require multiple input scripts but are not | 972 // For the tests that require multiple input scripts but are not |
| 971 // compiled, move the input scripts over with the script so they can | 973 // compiled, move the input scripts over with the script so they can |
| 972 // be accessed. | 974 // be accessed. |
| 973 String result = new File.fromPath(fromPath).readAsStringSync(); | 975 String result = new File.fromPath(fromPath).readAsStringSync(); |
| 974 new File('$tempDir/$baseName.dart').writeAsStringSync(result); | 976 new File('$tempDir/$baseName.dart').writeAsStringSync(result); |
| 975 } | 977 } |
| 976 } | 978 } |
| 977 | 979 |
| 980 |
| 978 // Variables for browser multi-tests. | 981 // Variables for browser multi-tests. |
| 979 List<String> subtestNames = info.optionsFromFile['subtestNames']; | 982 List<String> subtestNames = info.optionsFromFile['subtestNames']; |
| 980 TestCase multitestParentTest; | 983 TestCase multitestParentTest; |
| 981 int subtestIndex = 0; | 984 int subtestIndex = 0; |
| 982 // Construct the command that executes the browser test | 985 // Construct the command that executes the browser test |
| 983 do { | 986 do { |
| 984 List<Command> commandSet = new List<Command>.from(commands); | 987 List<Command> commandSet = new List<Command>.from(commands); |
| 985 if (subtestIndex != 0) { | 988 if (subtestIndex != 0) { |
| 986 // NOTE: The first time we enter this loop, all the compilation | 989 // NOTE: The first time we enter this loop, all the compilation |
| 987 // commands will be executed. On subsequent loop iterations, we | 990 // commands will be executed. On subsequent loop iterations, we |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 */ | 1674 */ |
| 1672 DateTime getLastModified(Uri uri) { | 1675 DateTime getLastModified(Uri uri) { |
| 1673 if (uri.scheme == "file") { | 1676 if (uri.scheme == "file") { |
| 1674 if (_cache.containsKey(uri.path)) { | 1677 if (_cache.containsKey(uri.path)) { |
| 1675 return _cache[uri.path]; | 1678 return _cache[uri.path]; |
| 1676 } | 1679 } |
| 1677 var file = new File(new Path(uri.path).toNativePath()); | 1680 var file = new File(new Path(uri.path).toNativePath()); |
| 1678 _cache[uri.path] = file.existsSync() ? file.lastModifiedSync() : null; | 1681 _cache[uri.path] = file.existsSync() ? file.lastModifiedSync() : null; |
| 1679 return _cache[uri.path]; | 1682 return _cache[uri.path]; |
| 1680 } | 1683 } |
| 1681 return new Date.now(); | 1684 return new DateTime.now(); |
| 1682 } | 1685 } |
| 1683 } | 1686 } |
| 1684 | 1687 |
| 1685 class TestUtils { | 1688 class TestUtils { |
| 1686 /** | 1689 /** |
| 1687 * The libraries in this directory relies on finding various files | 1690 * The libraries in this directory relies on finding various files |
| 1688 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If | 1691 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If |
| 1689 * the main script using 'test_suite.dart' is not there, the main | 1692 * the main script using 'test_suite.dart' is not there, the main |
| 1690 * script must set this to '.../dart/tools/test.dart'. | 1693 * script must set this to '.../dart/tools/test.dart'. |
| 1691 */ | 1694 */ |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 } | 1807 } |
| 1805 | 1808 |
| 1806 static bool usesWebDriver(String runtime) { | 1809 static bool usesWebDriver(String runtime) { |
| 1807 const BROWSERS = const [ | 1810 const BROWSERS = const [ |
| 1808 'dartium', | 1811 'dartium', |
| 1809 'ie9', | 1812 'ie9', |
| 1810 'ie10', | 1813 'ie10', |
| 1811 'safari', | 1814 'safari', |
| 1812 'opera', | 1815 'opera', |
| 1813 'chrome', | 1816 'chrome', |
| 1814 'ff' | 1817 'ff', |
| 1818 'chromeOnAndroid', |
| 1815 ]; | 1819 ]; |
| 1816 return BROWSERS.contains(runtime); | 1820 return BROWSERS.contains(runtime); |
| 1817 } | 1821 } |
| 1818 | 1822 |
| 1819 static bool isBrowserRuntime(String runtime) => | 1823 static bool isBrowserRuntime(String runtime) => |
| 1820 runtime == 'drt' || TestUtils.usesWebDriver(runtime); | 1824 runtime == 'drt' || TestUtils.usesWebDriver(runtime); |
| 1821 | 1825 |
| 1822 static bool isJsCommandLineRuntime(String runtime) => | 1826 static bool isJsCommandLineRuntime(String runtime) => |
| 1823 const ['d8', 'jsshell'].contains(runtime); | 1827 const ['d8', 'jsshell'].contains(runtime); |
| 1824 | 1828 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1924 * $pass tests are expected to pass | 1928 * $pass tests are expected to pass |
| 1925 * $failOk tests are expected to fail that we won't fix | 1929 * $failOk tests are expected to fail that we won't fix |
| 1926 * $fail tests are expected to fail that we should fix | 1930 * $fail tests are expected to fail that we should fix |
| 1927 * $crash tests are expected to crash that we should fix | 1931 * $crash tests are expected to crash that we should fix |
| 1928 * $timeout tests are allowed to timeout | 1932 * $timeout tests are allowed to timeout |
| 1929 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1933 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1930 """; | 1934 """; |
| 1931 print(report); | 1935 print(report); |
| 1932 } | 1936 } |
| 1933 } | 1937 } |
| OLD | NEW |