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

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

Issue 11777003: Make the "pub" and "pkg" test suites run Dart from the built SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « no previous file | 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 * Most TestSuites represent a directory or directory tree containing tests, 97 * Most TestSuites represent a directory or directory tree containing tests,
98 * and a status file containing the expected results when these tests are run. 98 * and a status file containing the expected results when these tests are run.
99 */ 99 */
100 abstract class TestSuite { 100 abstract class TestSuite {
101 final Map configuration; 101 final Map configuration;
102 final String suiteName; 102 final String suiteName;
103 103
104 TestSuite(this.configuration, this.suiteName); 104 TestSuite(this.configuration, this.suiteName);
105 105
106 /** 106 /**
107 * Whether or not binaries should be found in the root build directory or
108 * in the built SDK.
109 */
110 bool get useSdk {
Emily Fortuna 2013/01/04 21:39:10 can we add a little TODO here that says that we pl
Bob Nystrom 2013/01/04 22:29:45 Done.
111 // Some suites always use the SDK.
112 if (['pkg', 'pub'].contains(suiteName)) return true;
113
114 return configuration['use_sdk'];
115 }
116
117 /**
107 * The output directory for this suite's configuration. 118 * The output directory for this suite's configuration.
108 */ 119 */
109 String get buildDir => TestUtils.buildDir(configuration); 120 String get buildDir => TestUtils.buildDir(configuration);
110 121
111 /** 122 /**
112 * The path to the compiler for this suite's configuration. Returns `null` if 123 * The path to the compiler for this suite's configuration. Returns `null` if
113 * no compiler should be used. 124 * no compiler should be used.
114 */ 125 */
115 String get compilerPath { 126 String get compilerPath {
116 if (configuration['compiler'] == 'none') { 127 if (configuration['compiler'] == 'none') {
117 return null; // No separate compiler for dartium tests. 128 return null; // No separate compiler for dartium tests.
118 } 129 }
119 var name; 130 var name;
120 switch (configuration['compiler']) { 131 switch (configuration['compiler']) {
121 case 'dartc': 132 case 'dartc':
122 name = '$buildDir/$executableName'; 133 name = executablePath;
123 case 'dart2js': 134 case 'dart2js':
124 case 'dart2dart': 135 case 'dart2dart':
125 var prefix = 'sdk/bin/'; 136 var prefix = 'sdk/bin/';
126 String suffix = getExecutableSuffix(configuration['compiler']); 137 String suffix = getExecutableSuffix(configuration['compiler']);
127 if (configuration['host_checked']) { 138 if (configuration['host_checked']) {
128 // The script dart2js_developer is not included in the 139 // The script dart2js_developer is not included in the
129 // shipped SDK, that is the script is not installed in 140 // shipped SDK, that is the script is not installed in
130 // "$buildDir/dart-sdk/bin/" 141 // "$buildDir/dart-sdk/bin/"
131 name = '$prefix/dart2js_developer$suffix'; 142 name = '$prefix/dart2js_developer$suffix';
132 } else { 143 } else {
133 if (configuration['use_sdk']) { 144 if (configuration['use_sdk']) {
134 prefix = '$buildDir/dart-sdk/bin/'; 145 prefix = '$buildDir/dart-sdk/bin/';
135 } 146 }
136 name = '${prefix}dart2js$suffix'; 147 name = '${prefix}dart2js$suffix';
137 } 148 }
138 break; 149 break;
139 default: 150 default:
140 throw "Unknown compiler for: ${configuration['compiler']}"; 151 throw "Unknown compiler for: ${configuration['compiler']}";
141 } 152 }
142 if (!(new File(name)).existsSync() && !configuration['list']) { 153 if (!(new File(name)).existsSync() && !configuration['list']) {
143 throw "Executable '$name' does not exist"; 154 throw "Executable '$name' does not exist";
144 } 155 }
145 return name; 156 return name;
146 } 157 }
147 158
148 /** 159 /**
149 * The file name of the executable used to run this suite's tests. 160 * The path to the executable used to run this suite's tests.
150 */ 161 */
151 String get executableName { 162 String get executablePath {
152 String suffix = getExecutableSuffix(configuration['compiler']); 163 var suffix = getExecutableSuffix(configuration['compiler']);
153 switch (configuration['compiler']) { 164 switch (configuration['compiler']) {
154 case 'none': 165 case 'none':
155 return 'dart$suffix'; 166 if (useSdk) {
167 return '$buildDir/dart-sdk/bin/dart$suffix';
168 }
169 return '$buildDir/dart$suffix';
156 case 'dartc': 170 case 'dartc':
157 return 'analyzer/bin/dart_analyzer$suffix'; 171 return '$buildDir/analyzer/bin/dart_analyzer$suffix';
158 default: 172 default:
159 throw "Unknown executable for: ${configuration['compiler']}"; 173 throw "Unknown executable for: ${configuration['compiler']}";
160 } 174 }
161 } 175 }
162 176
163 /** 177 /**
164 * The file name of the d8 executable. 178 * The file name of the d8 executable.
165 */ 179 */
166 String get d8FileName { 180 String get d8FileName {
167 var suffix = getExecutableSuffix('d8'); 181 var suffix = getExecutableSuffix('d8');
168 var d8 = '$buildDir/d8$suffix'; 182 var d8 = '$buildDir/d8$suffix';
169 TestUtils.ensureExists(d8, configuration); 183 TestUtils.ensureExists(d8, configuration);
170 return d8; 184 return d8;
171 } 185 }
172 186
173 String get dartShellFileName { 187 String get dartShellFileName {
174 var name = configuration['dart']; 188 var name = configuration['dart'];
175 if (name == '') { 189 if (name == '') {
176 name = '$buildDir/$executableName'; 190 name = executablePath;
177 } 191 }
192
178 TestUtils.ensureExists(name, configuration); 193 TestUtils.ensureExists(name, configuration);
179 return name; 194 return name;
180 } 195 }
181 196
182 String get jsShellFileName { 197 String get jsShellFileName {
183 var executableSuffix = getExecutableSuffix('jsshell'); 198 var executableSuffix = getExecutableSuffix('jsshell');
184 var executable = 'jsshell$executableSuffix'; 199 var executable = 'jsshell$executableSuffix';
185 var jsshellDir = '${TestUtils.dartDir()}/tools/testing/bin'; 200 var jsshellDir = '${TestUtils.dartDir()}/tools/testing/bin';
186 return '$jsshellDir/$executable'; 201 return '$jsshellDir/$executable';
187 } 202 }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 final name = directory.filename; 443 final name = directory.filename;
429 444
430 return new StandardTestSuite(configuration, 445 return new StandardTestSuite(configuration,
431 name, directory, 446 name, directory,
432 ['$directory/$name.status', '$directory/${name}_dart2js.status'], 447 ['$directory/$name.status', '$directory/${name}_dart2js.status'],
433 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'), 448 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'),
434 recursive: true); 449 recursive: true);
435 } 450 }
436 451
437 Collection<Uri> get dart2JsBootstrapDependencies { 452 Collection<Uri> get dart2JsBootstrapDependencies {
438 if (!useDart2JsFromSdk) return []; 453 if (!useSdk) return [];
439 454
440 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join( 455 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join(
441 new Path('dart-sdk/lib/_internal/compiler/' 456 new Path('dart-sdk/lib/_internal/compiler/'
442 'implementation/dart2js.dart.snapshot'))).toString(); 457 'implementation/dart2js.dart.snapshot'))).toString();
443 return [new Uri.fromComponents(scheme: 'file', path: snapshotPath)]; 458 return [new Uri.fromComponents(scheme: 'file', path: snapshotPath)];
444 } 459 }
445 460
446 bool get useDart2JsFromSdk {
447 return configuration['use_sdk'];
448 }
449
450 /** 461 /**
451 * The default implementation assumes a file is a test if 462 * The default implementation assumes a file is a test if
452 * it ends in "Test.dart". 463 * it ends in "Test.dart".
453 */ 464 */
454 bool isTestFile(String filename) { 465 bool isTestFile(String filename) {
455 // Use the specified predicate, if provided. 466 // Use the specified predicate, if provided.
456 if (isTestFilePredicate != null) return isTestFilePredicate(filename); 467 if (isTestFilePredicate != null) return isTestFilePredicate(filename);
457 468
458 return filename.endsWith("Test.dart"); 469 return filename.endsWith("Test.dart");
459 } 470 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } 708 }
698 } 709 }
699 710
700 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { 711 List<Command> makeCommands(TestInformation info, var vmOptions, var args) {
701 switch (configuration['compiler']) { 712 switch (configuration['compiler']) {
702 case 'dart2js': 713 case 'dart2js':
703 args = new List.from(args); 714 args = new List.from(args);
704 String tempDir = createOutputDirectory(info.filePath, ''); 715 String tempDir = createOutputDirectory(info.filePath, '');
705 args.add('--out=$tempDir/out.js'); 716 args.add('--out=$tempDir/out.js');
706 717
707 List<Command> commands = 718 List<Command> commands =
708 <Command>[new CompilationCommand("$tempDir/out.js", 719 <Command>[new CompilationCommand("$tempDir/out.js",
709 !useDart2JsFromSdk, 720 !useSdk,
710 dart2JsBootstrapDependencies, 721 dart2JsBootstrapDependencies,
711 compilerPath, 722 compilerPath,
712 args)]; 723 args)];
713 if (info.hasCompileError) { 724 if (info.hasCompileError) {
714 // Do not attempt to run the compiled result. A compilation 725 // Do not attempt to run the compiled result. A compilation
715 // error should be reported by the compilation command. 726 // error should be reported by the compilation command.
716 } else if (configuration['runtime'] == 'd8') { 727 } else if (configuration['runtime'] == 'd8') {
717 commands.add(new Command(d8FileName, ['$tempDir/out.js'])); 728 commands.add(new Command(d8FileName, ['$tempDir/out.js']));
718 } else if (configuration['runtime'] == 'jsshell') { 729 } else if (configuration['runtime'] == 'jsshell') {
719 commands.add(new Command(jsShellFileName, ['$tempDir/out.js'])); 730 commands.add(new Command(jsShellFileName, ['$tempDir/out.js']));
720 } 731 }
721 return commands; 732 return commands;
722 733
723 case 'dart2dart': 734 case 'dart2dart':
724 args = new List.from(args); 735 args = new List.from(args);
725 args.add('--output-type=dart'); 736 args.add('--output-type=dart');
726 String tempDir = createOutputDirectory(info.filePath, ''); 737 String tempDir = createOutputDirectory(info.filePath, '');
727 args.add('--out=$tempDir/out.dart'); 738 args.add('--out=$tempDir/out.dart');
728 739
729 List<Command> commands = 740 List<Command> commands =
730 <Command>[new CompilationCommand("$tempDir/out.dart", 741 <Command>[new CompilationCommand("$tempDir/out.dart",
731 !useDart2JsFromSdk, 742 !useSdk,
732 dart2JsBootstrapDependencies, 743 dart2JsBootstrapDependencies,
733 compilerPath, 744 compilerPath,
734 args)]; 745 args)];
735 if (info.hasCompileError) { 746 if (info.hasCompileError) {
736 // Do not attempt to run the compiled result. A compilation 747 // Do not attempt to run the compiled result. A compilation
737 // error should be reported by the compilation command. 748 // error should be reported by the compilation command.
738 } else if (configuration['runtime'] == 'vm') { 749 } else if (configuration['runtime'] == 'vm') {
739 // TODO(antonm): support checked. 750 // TODO(antonm): support checked.
740 var vmArguments = new List.from(vmOptions); 751 var vmArguments = new List.from(vmOptions);
741 vmArguments.addAll([ 752 vmArguments.addAll([
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 } 926 }
916 927
917 // Variables for browser multi-tests. 928 // Variables for browser multi-tests.
918 List<String> subtestNames = info.optionsFromFile['subtestNames']; 929 List<String> subtestNames = info.optionsFromFile['subtestNames'];
919 TestCase multitestParentTest; 930 TestCase multitestParentTest;
920 int subtestIndex = 0; 931 int subtestIndex = 0;
921 // Construct the command that executes the browser test 932 // Construct the command that executes the browser test
922 do { 933 do {
923 List<Command> commandSet = new List<Command>.from(commands); 934 List<Command> commandSet = new List<Command>.from(commands);
924 if (subtestIndex != 0) { 935 if (subtestIndex != 0) {
925 // NOTE: The first time we enter this loop, all the compilation 936 // NOTE: The first time we enter this loop, all the compilation
926 // commands will be executed. On subsequent loop iterations, we 937 // commands will be executed. On subsequent loop iterations, we
927 // don't need to do any compilations. Thus we set "commandSet = []". 938 // don't need to do any compilations. Thus we set "commandSet = []".
928 commandSet = []; 939 commandSet = [];
929 } 940 }
930 941
931 List<String> args = <String>[]; 942 List<String> args = <String>[];
932 String fullHtmlPath = htmlPath.startsWith('http:') ? htmlPath : 943 String fullHtmlPath = htmlPath.startsWith('http:') ? htmlPath :
933 (htmlPath.startsWith('/') ? 944 (htmlPath.startsWith('/') ?
934 'file://$htmlPath' : 945 'file://$htmlPath' :
935 'file:///$htmlPath'); 946 'file:///$htmlPath');
936 if (info.optionsFromFile['isMultiHtmlTest'] 947 if (info.optionsFromFile['isMultiHtmlTest']
(...skipping 27 matching lines...) Expand all
964 dartFlags.add('--ignore-unrecognized-flags'); 975 dartFlags.add('--ignore-unrecognized-flags');
965 if (configuration["checked"]) { 976 if (configuration["checked"]) {
966 dartFlags.add('--enable_asserts'); 977 dartFlags.add('--enable_asserts');
967 dartFlags.add("--enable_type_checks"); 978 dartFlags.add("--enable_type_checks");
968 } 979 }
969 dartFlags.addAll(vmOptions); 980 dartFlags.addAll(vmOptions);
970 } 981 }
971 if (compiler == 'none') { 982 if (compiler == 'none') {
972 var packageRootPath = packageRoot(optionsFromFile['packageRoot']); 983 var packageRootPath = packageRoot(optionsFromFile['packageRoot']);
973 if (packageRootPath != null) { 984 if (packageRootPath != null) {
974 var absolutePath = 985 var absolutePath =
975 TestUtils.absolutePath(new Path(packageRootPath)); 986 TestUtils.absolutePath(new Path(packageRootPath));
976 packageRootUri = new Uri.fromComponents( 987 packageRootUri = new Uri.fromComponents(
977 scheme: 'file', 988 scheme: 'file',
978 path: absolutePath.toString()); 989 path: absolutePath.toString());
979 } 990 }
980 } 991 }
981 992
982 if (expectedOutput != null) { 993 if (expectedOutput != null) {
983 if (expectedOutput.toNativePath().endsWith('.png')) { 994 if (expectedOutput.toNativePath().endsWith('.png')) {
984 // pixel tests are specified by running DRT "foo.html'-p" 995 // pixel tests are specified by running DRT "foo.html'-p"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 default: 1051 default:
1041 Expect.fail('unimplemented compiler $compiler'); 1052 Expect.fail('unimplemented compiler $compiler');
1042 } 1053 }
1043 if (executable.endsWith('.dart')) { 1054 if (executable.endsWith('.dart')) {
1044 // Run the compiler script via the Dart VM. 1055 // Run the compiler script via the Dart VM.
1045 args.insertRange(0, 1, executable); 1056 args.insertRange(0, 1, executable);
1046 executable = dartShellFileName; 1057 executable = dartShellFileName;
1047 } 1058 }
1048 if (['dart2js', 'dart2dart'].contains(configuration['compiler'])) { 1059 if (['dart2js', 'dart2dart'].contains(configuration['compiler'])) {
1049 return new CompilationCommand(outputFile, 1060 return new CompilationCommand(outputFile,
1050 !useDart2JsFromSdk, 1061 !useSdk,
1051 dart2JsBootstrapDependencies, 1062 dart2JsBootstrapDependencies,
1052 compilerPath, 1063 compilerPath,
1053 args); 1064 args);
1054 } 1065 }
1055 return new Command(executable, args); 1066 return new Command(executable, args);
1056 } 1067 }
1057 1068
1058 /** 1069 /**
1059 * Create a directory for the generated test. If a Dart language test 1070 * Create a directory for the generated test. If a Dart language test
1060 * needs to be run in a browser, the Dart test needs to be embedded in 1071 * needs to be run in a browser, the Dart test needs to be embedded in
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 * $pass tests are expected to pass 1804 * $pass tests are expected to pass
1794 * $failOk tests are expected to fail that we won't fix 1805 * $failOk tests are expected to fail that we won't fix
1795 * $fail tests are expected to fail that we should fix 1806 * $fail tests are expected to fail that we should fix
1796 * $crash tests are expected to crash that we should fix 1807 * $crash tests are expected to crash that we should fix
1797 * $timeout tests are allowed to timeout 1808 * $timeout tests are allowed to timeout
1798 * $compileErrorSkip tests are skipped on browsers due to compile-time error 1809 * $compileErrorSkip tests are skipped on browsers due to compile-time error
1799 """; 1810 """;
1800 print(report); 1811 print(report);
1801 } 1812 }
1802 } 1813 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698