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