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

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

Issue 219053003: Deprecate automatic generation of precompiled.js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comment Created 6 years, 8 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
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 336 }
337 337
338 /** 338 /**
339 * Create a directories for generated assets (tests, html files, 339 * Create a directories for generated assets (tests, html files,
340 * pubspec checkouts ...). 340 * pubspec checkouts ...).
341 */ 341 */
342 342
343 String createOutputDirectory(Path testPath, String optionsName) { 343 String createOutputDirectory(Path testPath, String optionsName) {
344 var checked = configuration['checked'] ? '-checked' : ''; 344 var checked = configuration['checked'] ? '-checked' : '';
345 var minified = configuration['minified'] ? '-minified' : ''; 345 var minified = configuration['minified'] ? '-minified' : '';
346 var csp = configuration['csp'] ? '-csp' : ''; 346 var csp = configuration['csp'] ? '-csp' : '';
ricow1 2014/04/01 10:37:58 there is no need to add this here now right?
Johnni Winther 2014/04/01 13:52:35 Apparently not.
347 var sdk = configuration['use_sdk'] ? '-sdk' : ''; 347 var sdk = configuration['use_sdk'] ? '-sdk' : '';
348 var packages = configuration['use_public_packages'] 348 var packages = configuration['use_public_packages']
349 ? '-public_packages' : ''; 349 ? '-public_packages' : '';
350 var dirName = "${configuration['compiler']}-${configuration['runtime']}" 350 var dirName = "${configuration['compiler']}-${configuration['runtime']}"
351 "$checked$minified$csp$packages$sdk"; 351 "$checked$minified$csp$packages$sdk";
352 return createGeneratedTestDirectoryHelper( 352 return createGeneratedTestDirectoryHelper(
353 "tests", dirName, testPath, optionsName); 353 "tests", dirName, testPath, optionsName);
354 } 354 }
355 355
356 String createCompilationOutputDirectory(Path testPath) { 356 String createCompilationOutputDirectory(Path testPath) {
357 var checked = configuration['checked'] ? '-checked' : ''; 357 var checked = configuration['checked'] ? '-checked' : '';
358 var minified = configuration['minified'] ? '-minified' : ''; 358 var minified = configuration['minified'] ? '-minified' : '';
359 var csp = configuration['csp'] ? '-csp' : '';
359 var sdk = configuration['use_sdk'] ? '-sdk' : ''; 360 var sdk = configuration['use_sdk'] ? '-sdk' : '';
360 var packages = configuration['use_public_packages'] 361 var packages = configuration['use_public_packages']
361 ? '-public_packages' : ''; 362 ? '-public_packages' : '';
362 var dirName = "${configuration['compiler']}$checked$minified$packages$sdk"; 363 var dirName = "${configuration['compiler']}"
364 "$checked$minified$csp$packages$sdk";
363 return createGeneratedTestDirectoryHelper( 365 return createGeneratedTestDirectoryHelper(
364 "compilations", dirName, testPath, ""); 366 "compilations", dirName, testPath, "");
365 } 367 }
366 368
367 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { 369 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) {
368 var relativeDir = directoryOfPubspecYaml.relativeTo(TestUtils.dartDir()); 370 var relativeDir = directoryOfPubspecYaml.relativeTo(TestUtils.dartDir());
369 var sdk = configuration['use_sdk'] ? '-sdk' : ''; 371 var sdk = configuration['use_sdk'] ? '-sdk' : '';
370 var pkg = configuration['use_public_packages'] 372 var pkg = configuration['use_public_packages']
371 ? 'public_packages' : 'repo_packages'; 373 ? 'public_packages' : 'repo_packages';
372 return createGeneratedTestDirectoryHelper( 374 return createGeneratedTestDirectoryHelper(
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 optionsName = vmOptions.join('-').replaceAll('-','') 1146 optionsName = vmOptions.join('-').replaceAll('-','')
1145 .replaceAll('=','') 1147 .replaceAll('=','')
1146 .replaceAll('/',''); 1148 .replaceAll('/','');
1147 } 1149 }
1148 final String compilationTempDir = 1150 final String compilationTempDir =
1149 createCompilationOutputDirectory(info.filePath); 1151 createCompilationOutputDirectory(info.filePath);
1150 final String tempDir = createOutputDirectory(info.filePath, optionsName); 1152 final String tempDir = createOutputDirectory(info.filePath, optionsName);
1151 1153
1152 String dartWrapperFilename = '$tempDir/test.dart'; 1154 String dartWrapperFilename = '$tempDir/test.dart';
1153 String compiledDartWrapperFilename = '$compilationTempDir/test.js'; 1155 String compiledDartWrapperFilename = '$compilationTempDir/test.js';
1154 String precompiledDartWrapperFilename =
1155 '$compilationTempDir/test.precompiled.js';
1156 1156
1157 String content = null; 1157 String content = null;
1158 Path dir = filePath.directoryPath; 1158 Path dir = filePath.directoryPath;
1159 String nameNoExt = filePath.filenameWithoutExtension; 1159 String nameNoExt = filePath.filenameWithoutExtension;
1160 1160
1161 Path pngPath = dir.append('$nameNoExt.png'); 1161 Path pngPath = dir.append('$nameNoExt.png');
1162 Path txtPath = dir.append('$nameNoExt.txt'); 1162 Path txtPath = dir.append('$nameNoExt.txt');
1163 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath(); 1163 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath();
1164 File customHtml = new File(customHtmlPath); 1164 File customHtml = new File(customHtmlPath);
1165 1165
(...skipping 28 matching lines...) Expand all
1194 var htmlContents = customHtml.readAsStringSync(); 1194 var htmlContents = customHtml.readAsStringSync();
1195 if (compiler == 'none') { 1195 if (compiler == 'none') {
1196 htmlContents = htmlContents.replaceAll('%TEST_SCRIPTS%', 1196 htmlContents = htmlContents.replaceAll('%TEST_SCRIPTS%',
1197 '<script type="application/dart" ' 1197 '<script type="application/dart" '
1198 'src="${_createUrlPathFromFile(filePath)}"></script>\n' 1198 'src="${_createUrlPathFromFile(filePath)}"></script>\n'
1199 '<script type="text/javascript" ' 1199 '<script type="text/javascript" '
1200 'src="/packages/browser/dart.js"></script>'); 1200 'src="/packages/browser/dart.js"></script>');
1201 } else { 1201 } else {
1202 compiledDartWrapperFilename = '$tempDir/$nameNoExt.js'; 1202 compiledDartWrapperFilename = '$tempDir/$nameNoExt.js';
1203 var jsFile = '$nameNoExt.js'; 1203 var jsFile = '$nameNoExt.js';
1204 if (configuration['csp']) {
1205 jsFile = '$nameNoExt.precompiled.js';
1206 }
1207 htmlContents = htmlContents.replaceAll('%TEST_SCRIPTS%', 1204 htmlContents = htmlContents.replaceAll('%TEST_SCRIPTS%',
1208 '<script src="$jsFile"></script>'); 1205 '<script src="$jsFile"></script>');
1209 } 1206 }
1210 new File(htmlPath).writeAsStringSync(htmlContents); 1207 new File(htmlPath).writeAsStringSync(htmlContents);
1211 } 1208 }
1212 } else { 1209 } else {
1213 htmlPath = '$tempDir/test.html'; 1210 htmlPath = '$tempDir/test.html';
1214 if (configuration['compiler'] != 'dart2js') { 1211 if (configuration['compiler'] != 'dart2js') {
1215 // test.dart will import the dart test. 1212 // test.dart will import the dart test.
1216 _createWrapperFile(dartWrapperFilename, filePath); 1213 _createWrapperFile(dartWrapperFilename, filePath);
1217 } else { 1214 } else {
1218 dartWrapperFilename = filename; 1215 dartWrapperFilename = filename;
1219 } 1216 }
1220 1217
1221 // Create the HTML file for the test. 1218 // Create the HTML file for the test.
1222 RandomAccessFile htmlTest = 1219 RandomAccessFile htmlTest =
1223 new File(htmlPath).openSync(mode: FileMode.WRITE); 1220 new File(htmlPath).openSync(mode: FileMode.WRITE);
1224 1221
1225 String scriptPath = dartWrapperFilename; 1222 String scriptPath = dartWrapperFilename;
1226 if (compiler != 'none') { 1223 if (compiler != 'none') {
1227 scriptPath = compiledDartWrapperFilename; 1224 scriptPath = compiledDartWrapperFilename;
1228 if (configuration['csp']) {
1229 scriptPath = precompiledDartWrapperFilename;
1230 }
1231 } 1225 }
1232 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); 1226 scriptPath = _createUrlPathFromFile(new Path(scriptPath));
1233 1227
1234 content = 1228 content =
1235 getHtmlContents(filename, scriptType, new Path("$scriptPath")); 1229 getHtmlContents(filename, scriptType, new Path("$scriptPath"));
1236 htmlTest.writeStringSync(content); 1230 htmlTest.writeStringSync(content);
1237 htmlTest.closeSync(); 1231 htmlTest.closeSync();
1238 } 1232 }
1239 1233
1240 if (compiler != 'none') { 1234 if (compiler != 'none') {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 String compiler, String dir, vmOptions, optionsFromFile) { 1322 String compiler, String dir, vmOptions, optionsFromFile) {
1329 assert (['dart2js', 'dart2dart'].contains(compiler)); 1323 assert (['dart2js', 'dart2dart'].contains(compiler));
1330 String executable = compilerPath; 1324 String executable = compilerPath;
1331 List<String> args = TestUtils.standardOptions(configuration); 1325 List<String> args = TestUtils.standardOptions(configuration);
1332 String packageRoot = 1326 String packageRoot =
1333 packageRootArgument(optionsFromFile['packageRoot']); 1327 packageRootArgument(optionsFromFile['packageRoot']);
1334 if (packageRoot != null) { 1328 if (packageRoot != null) {
1335 args.add(packageRoot); 1329 args.add(packageRoot);
1336 } 1330 }
1337 args.add('--out=$outputFile'); 1331 args.add('--out=$outputFile');
1332 if (configuration['csp']) args.add('--csp');
1338 args.add(inputFile); 1333 args.add(inputFile);
1339 args.addAll(optionsFromFile['sharedOptions']); 1334 args.addAll(optionsFromFile['sharedOptions']);
1340 if (executable.endsWith('.dart')) { 1335 if (executable.endsWith('.dart')) {
1341 // Run the compiler script via the Dart VM. 1336 // Run the compiler script via the Dart VM.
1342 args.insert(0, executable); 1337 args.insert(0, executable);
1343 executable = dartVmBinaryFileName; 1338 executable = dartVmBinaryFileName;
1344 } 1339 }
1345 return CommandBuilder.instance.getCompilationCommand( 1340 return CommandBuilder.instance.getCompilationCommand(
1346 compiler, outputFile, !useSdk, 1341 compiler, outputFile, !useSdk,
1347 dart2JsBootstrapDependencies, compilerPath, args, environmentOverrides); 1342 dart2JsBootstrapDependencies, compilerPath, args, environmentOverrides);
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
2205 * $pass tests are expected to pass 2200 * $pass tests are expected to pass
2206 * $failOk tests are expected to fail that we won't fix 2201 * $failOk tests are expected to fail that we won't fix
2207 * $fail tests are expected to fail that we should fix 2202 * $fail tests are expected to fail that we should fix
2208 * $crash tests are expected to crash that we should fix 2203 * $crash tests are expected to crash that we should fix
2209 * $timeout tests are allowed to timeout 2204 * $timeout tests are allowed to timeout
2210 * $compileErrorSkip tests are skipped on browsers due to compile-time error 2205 * $compileErrorSkip tests are skipped on browsers due to compile-time error
2211 """; 2206 """;
2212 print(report); 2207 print(report);
2213 } 2208 }
2214 } 2209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698