Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(780)

Side by Side Diff: tools/testing/dart/test_suite.dart

Issue 15567002: Added support for running dart2js tests on android devices (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 */ 1675 */
1673 DateTime getLastModified(Uri uri) { 1676 DateTime getLastModified(Uri uri) {
1674 if (uri.scheme == "file") { 1677 if (uri.scheme == "file") {
1675 if (_cache.containsKey(uri.path)) { 1678 if (_cache.containsKey(uri.path)) {
1676 return _cache[uri.path]; 1679 return _cache[uri.path];
1677 } 1680 }
1678 var file = new File(new Path(uri.path).toNativePath()); 1681 var file = new File(new Path(uri.path).toNativePath());
1679 _cache[uri.path] = file.existsSync() ? file.lastModifiedSync() : null; 1682 _cache[uri.path] = file.existsSync() ? file.lastModifiedSync() : null;
1680 return _cache[uri.path]; 1683 return _cache[uri.path];
1681 } 1684 }
1682 return new Date.now(); 1685 return new DateTime.now();
1683 } 1686 }
1684 } 1687 }
1685 1688
1686 class TestUtils { 1689 class TestUtils {
1687 /** 1690 /**
1688 * The libraries in this directory relies on finding various files 1691 * The libraries in this directory relies on finding various files
1689 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If 1692 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If
1690 * the main script using 'test_suite.dart' is not there, the main 1693 * the main script using 'test_suite.dart' is not there, the main
1691 * script must set this to '.../dart/tools/test.dart'. 1694 * script must set this to '.../dart/tools/test.dart'.
1692 */ 1695 */
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 } 1808 }
1806 1809
1807 static bool usesWebDriver(String runtime) { 1810 static bool usesWebDriver(String runtime) {
1808 const BROWSERS = const [ 1811 const BROWSERS = const [
1809 'dartium', 1812 'dartium',
1810 'ie9', 1813 'ie9',
1811 'ie10', 1814 'ie10',
1812 'safari', 1815 'safari',
1813 'opera', 1816 'opera',
1814 'chrome', 1817 'chrome',
1815 'ff' 1818 'ff',
1819 'chromeOnAndroid',
1816 ]; 1820 ];
1817 return BROWSERS.contains(runtime); 1821 return BROWSERS.contains(runtime);
1818 } 1822 }
1819 1823
1820 static bool isBrowserRuntime(String runtime) => 1824 static bool isBrowserRuntime(String runtime) =>
1821 runtime == 'drt' || TestUtils.usesWebDriver(runtime); 1825 runtime == 'drt' || TestUtils.usesWebDriver(runtime);
1822 1826
1823 static bool isJsCommandLineRuntime(String runtime) => 1827 static bool isJsCommandLineRuntime(String runtime) =>
1824 const ['d8', 'jsshell'].contains(runtime); 1828 const ['d8', 'jsshell'].contains(runtime);
1825 1829
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 * $pass tests are expected to pass 1929 * $pass tests are expected to pass
1926 * $failOk tests are expected to fail that we won't fix 1930 * $failOk tests are expected to fail that we won't fix
1927 * $fail tests are expected to fail that we should fix 1931 * $fail tests are expected to fail that we should fix
1928 * $crash tests are expected to crash that we should fix 1932 * $crash tests are expected to crash that we should fix
1929 * $timeout tests are allowed to timeout 1933 * $timeout tests are allowed to timeout
1930 * $compileErrorSkip tests are skipped on browsers due to compile-time error 1934 * $compileErrorSkip tests are skipped on browsers due to compile-time error
1931 """; 1935 """;
1932 print(report); 1936 print(report);
1933 } 1937 }
1934 } 1938 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698