Chromium Code Reviews| 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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 } | 769 } |
| 770 } | 770 } |
| 771 return negative; | 771 return negative; |
| 772 } | 772 } |
| 773 | 773 |
| 774 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { | 774 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { |
| 775 var compiler = configuration['compiler']; | 775 var compiler = configuration['compiler']; |
| 776 switch (compiler) { | 776 switch (compiler) { |
| 777 case 'dart2js': | 777 case 'dart2js': |
| 778 args = new List.from(args); | 778 args = new List.from(args); |
| 779 String tempDir = createOutputDirectory(info.filePath, ''); | 779 String tempDir = createCompilationOutputDirectory(info.filePath); |
| 780 args.add('--out=$tempDir/out.js'); | 780 args.add('--out=$tempDir/out.js'); |
| 781 | 781 |
| 782 var command = CommandBuilder.instance.getCompilationCommand( | 782 var command = CommandBuilder.instance.getCompilationCommand( |
| 783 compiler, "$tempDir/out.js", !useSdk, | 783 compiler, "$tempDir/out.js", !useSdk, |
| 784 dart2JsBootstrapDependencies, compilerPath, args, configurationDir); | 784 dart2JsBootstrapDependencies, compilerPath, args, configurationDir); |
| 785 | 785 |
| 786 List<Command> commands = <Command>[command]; | 786 List<Command> commands = <Command>[command]; |
| 787 if (info.hasCompileError) { | 787 if (info.hasCompileError) { |
| 788 // Do not attempt to run the compiled result. A compilation | 788 // Do not attempt to run the compiled result. A compilation |
| 789 // error should be reported by the compilation command. | 789 // error should be reported by the compilation command. |
| 790 } else if (configuration['runtime'] == 'd8') { | 790 } else if (configuration['runtime'] == 'd8') { |
| 791 commands.add(CommandBuilder.instance.getJSCommandlineCommand( | 791 commands.add(CommandBuilder.instance.getJSCommandlineCommand( |
| 792 "d8", d8FileName, ['$tempDir/out.js'], configurationDir)); | 792 "d8", d8FileName, ['$tempDir/out.js'], configurationDir)); |
| 793 } else if (configuration['runtime'] == 'jsshell') { | 793 } else if (configuration['runtime'] == 'jsshell') { |
| 794 commands.add(CommandBuilder.instance.getJSCommandlineCommand( | 794 commands.add(CommandBuilder.instance.getJSCommandlineCommand( |
| 795 "jsshell", jsShellFileName, ['$tempDir/out.js'], configurationDir)); | 795 "jsshell", jsShellFileName, ['$tempDir/out.js'], configurationDir)); |
| 796 } | 796 } |
| 797 return commands; | 797 return commands; |
| 798 | |
| 799 case 'dart2dart': | 798 case 'dart2dart': |
| 800 args = new List.from(args); | 799 args = new List.from(args); |
| 801 args.add('--output-type=dart'); | 800 args.add('--output-type=dart'); |
| 802 String tempDir = createOutputDirectory(info.filePath, ''); | 801 String tempDir = createCompilationOutputDirectory(info.filePath); |
| 803 args.add('--out=$tempDir/out.dart'); | 802 args.add('--out=$tempDir/out.dart'); |
| 804 | 803 |
| 805 List<Command> commands = | 804 List<Command> commands = |
| 806 <Command>[CommandBuilder.instance.getCompilationCommand( | 805 <Command>[CommandBuilder.instance.getCompilationCommand( |
| 807 compiler, "$tempDir/out.dart", !useSdk, | 806 compiler, "$tempDir/out.dart", !useSdk, |
| 808 dart2JsBootstrapDependencies, compilerPath, args, | 807 dart2JsBootstrapDependencies, compilerPath, args, |
| 809 configurationDir)]; | 808 configurationDir)]; |
| 810 if (info.hasCompileError) { | 809 if (info.hasCompileError) { |
| 811 // Do not attempt to run the compiled result. A compilation | 810 // Do not attempt to run the compiled result. A compilation |
| 812 // error should be reported by the compilation command. | 811 // error should be reported by the compilation command. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 for (var vmOptions in getVmOptions(optionsFromFile)) { | 953 for (var vmOptions in getVmOptions(optionsFromFile)) { |
| 955 // Create a unique temporary directory for each set of vmOptions. | 954 // Create a unique temporary directory for each set of vmOptions. |
| 956 // TODO(dart:429): Replace separate replaceAlls with a RegExp when | 955 // TODO(dart:429): Replace separate replaceAlls with a RegExp when |
| 957 // replaceAll(RegExp, String) is implemented. | 956 // replaceAll(RegExp, String) is implemented. |
| 958 String optionsName = ''; | 957 String optionsName = ''; |
| 959 if (getVmOptions(optionsFromFile).length > 1) { | 958 if (getVmOptions(optionsFromFile).length > 1) { |
| 960 optionsName = vmOptions.join('-').replaceAll('-','') | 959 optionsName = vmOptions.join('-').replaceAll('-','') |
| 961 .replaceAll('=','') | 960 .replaceAll('=','') |
| 962 .replaceAll('/',''); | 961 .replaceAll('/',''); |
| 963 } | 962 } |
| 963 final String compilationTempDir = | |
| 964 createCompilationOutputDirectory(info.filePath); | |
| 964 final String tempDir = createOutputDirectory(info.filePath, optionsName); | 965 final String tempDir = createOutputDirectory(info.filePath, optionsName); |
| 965 | 966 |
| 966 String dartWrapperFilename = '$tempDir/test.dart'; | 967 String dartWrapperFilename = '$tempDir/test.dart'; |
| 967 String compiledDartWrapperFilename = '$tempDir/test.js'; | 968 String compiledDartWrapperFilename = '$compilationTempDir/test.js'; |
| 968 String precompiledDartWrapperFilename = '$tempDir/test.precompiled.js'; | 969 String precompiledDartWrapperFilename = |
| 970 '$compilationTempDir/test.precompiled.js'; | |
| 969 | 971 |
| 970 String content = null; | 972 String content = null; |
| 971 Path dir = filePath.directoryPath; | 973 Path dir = filePath.directoryPath; |
| 972 String nameNoExt = filePath.filenameWithoutExtension; | 974 String nameNoExt = filePath.filenameWithoutExtension; |
| 973 | 975 |
| 974 Path pngPath = dir.append('$nameNoExt.png'); | 976 Path pngPath = dir.append('$nameNoExt.png'); |
| 975 Path txtPath = dir.append('$nameNoExt.txt'); | 977 Path txtPath = dir.append('$nameNoExt.txt'); |
| 976 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath(); | 978 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath(); |
| 977 File customHtml = new File(customHtmlPath); | 979 File customHtml = new File(customHtmlPath); |
| 978 | 980 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1214 if (!optionsName.isEmpty) { | 1216 if (!optionsName.isEmpty) { |
| 1215 testUniqueName = '$testUniqueName-$optionsName'; | 1217 testUniqueName = '$testUniqueName-$optionsName'; |
| 1216 } | 1218 } |
| 1217 | 1219 |
| 1218 // Create '[build dir]/generated_tests/$compiler-$runtime/$testUniqueName', | 1220 // Create '[build dir]/generated_tests/$compiler-$runtime/$testUniqueName', |
| 1219 // including any intermediate directories that don't exist. | 1221 // including any intermediate directories that don't exist. |
| 1220 // If the tests are run in checked or minified mode we add that to the | 1222 // If the tests are run in checked or minified mode we add that to the |
| 1221 // '$compile-$runtime' directory name. | 1223 // '$compile-$runtime' directory name. |
| 1222 var checked = configuration['checked'] ? '-checked' : ''; | 1224 var checked = configuration['checked'] ? '-checked' : ''; |
| 1223 var minified = configuration['minified'] ? '-minified' : ''; | 1225 var minified = configuration['minified'] ? '-minified' : ''; |
| 1224 var csp = configuration['csp'] ? '-csp' : ''; | 1226 var csp = configuration['csp'] ? '-csp' : ''; |
|
ricow1
2013/10/15 11:03:24
I guess we don't need this here either
kustermann
2013/10/15 11:50:23
Well, we do, because we the *html file lives in th
| |
| 1225 var dirName = "${configuration['compiler']}-${configuration['runtime']}" | 1227 var dirName = "${configuration['compiler']}-${configuration['runtime']}" |
| 1226 "$checked$minified$csp"; | 1228 "$checked$minified$csp"; |
| 1227 Path generatedTestPath = new Path(buildDir) | 1229 Path generatedTestPath = new Path(buildDir) |
| 1228 .append('generated_tests') | 1230 .append('generated_tests') |
| 1229 .append(dirName) | 1231 .append(dirName) |
| 1230 .append(testUniqueName); | 1232 .append(testUniqueName); |
| 1231 | 1233 |
| 1232 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); | 1234 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); |
| 1233 return new File(generatedTestPath.toNativePath()).fullPathSync() | 1235 return new File(generatedTestPath.toNativePath()).fullPathSync() |
| 1234 .replaceAll('\\', '/'); | 1236 .replaceAll('\\', '/'); |
| 1235 } | 1237 } |
| 1236 | 1238 |
| 1239 String createCompilationOutputDirectory(Path testPath) { | |
| 1240 Path relative = testPath.relativeTo(TestUtils.dartDir()); | |
|
ricow1
2013/10/15 11:03:24
how about extracting these 3 lines into a method a
kustermann
2013/10/15 11:50:23
Done.
| |
| 1241 relative = relative.directoryPath.append(relative.filenameWithoutExtension); | |
| 1242 String testUniqueName = relative.toString().replaceAll('/', '_'); | |
| 1243 | |
| 1244 // Create | |
| 1245 // '[build dir]/generated_compilations/$compiler-$flags/$testUniqueName', | |
| 1246 // including any intermediate directories that don't exist. | |
| 1247 var checked = configuration['checked'] ? '-checked' : ''; | |
| 1248 var minified = configuration['minified'] ? '-minified' : ''; | |
| 1249 var dirName = "${configuration['compiler']}$checked$minified"; | |
| 1250 Path generatedTestPath = new Path(buildDir) | |
| 1251 .append('generated_compilations') | |
| 1252 .append(dirName) | |
| 1253 .append(testUniqueName); | |
| 1254 | |
| 1255 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); | |
| 1256 return new File(generatedTestPath.toNativePath()).fullPathSync() | |
| 1257 .replaceAll('\\', '/'); | |
| 1258 } | |
| 1259 | |
| 1237 String get scriptType { | 1260 String get scriptType { |
| 1238 switch (configuration['compiler']) { | 1261 switch (configuration['compiler']) { |
| 1239 case 'none': | 1262 case 'none': |
| 1240 case 'dart2dart': | 1263 case 'dart2dart': |
| 1241 return 'application/dart'; | 1264 return 'application/dart'; |
| 1242 case 'dart2js': | 1265 case 'dart2js': |
| 1243 case 'dartanalyzer': | 1266 case 'dartanalyzer': |
| 1244 case 'dart2analyzer': | 1267 case 'dart2analyzer': |
| 1245 return 'text/javascript'; | 1268 return 'text/javascript'; |
| 1246 default: | 1269 default: |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2023 * $pass tests are expected to pass | 2046 * $pass tests are expected to pass |
| 2024 * $failOk tests are expected to fail that we won't fix | 2047 * $failOk tests are expected to fail that we won't fix |
| 2025 * $fail tests are expected to fail that we should fix | 2048 * $fail tests are expected to fail that we should fix |
| 2026 * $crash tests are expected to crash that we should fix | 2049 * $crash tests are expected to crash that we should fix |
| 2027 * $timeout tests are allowed to timeout | 2050 * $timeout tests are allowed to timeout |
| 2028 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 2051 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 2029 """; | 2052 """; |
| 2030 print(report); | 2053 print(report); |
| 2031 } | 2054 } |
| 2032 } | 2055 } |
| OLD | NEW |