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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 completeHandler, | 743 completeHandler, |
| 744 expectations, | 744 expectations, |
| 745 isNegative: isNegative, | 745 isNegative: isNegative, |
| 746 info: info)); | 746 info: info)); |
| 747 } | 747 } |
| 748 } | 748 } |
| 749 | 749 |
| 750 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { | 750 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { |
| 751 switch (configuration['compiler']) { | 751 switch (configuration['compiler']) { |
| 752 case 'dart2js': | 752 case 'dart2js': |
| 753 var compiledFile = '$tempDir/out-${runtime}.js'; | |
| 754 var compiledShadowFile = '$tempDir/out_shadow.js'; | |
| 753 args = new List.from(args); | 755 args = new List.from(args); |
| 754 String tempDir = createOutputDirectory(info.filePath, ''); | 756 String tempDir = createOutputDirectory(info.filePath, ''); |
| 755 args.add('--out=$tempDir/out.js'); | 757 args.add('--out=$compiledFile'); |
| 756 | 758 |
| 757 List<Command> commands = | 759 List<Command> commands = |
| 758 <Command>[new CompilationCommand("$tempDir/out.js", | 760 <Command>[new CompilationCommand(compiledFile, |
| 761 compiledShadowFile, | |
| 759 !useSdk, | 762 !useSdk, |
| 760 dart2JsBootstrapDependencies, | 763 dart2JsBootstrapDependencies, |
| 761 compilerPath, | 764 compilerPath, |
| 762 args)]; | 765 args)]; |
| 763 if (info.hasCompileError) { | 766 if (info.hasCompileError) { |
| 764 // Do not attempt to run the compiled result. A compilation | 767 // Do not attempt to run the compiled result. A compilation |
| 765 // error should be reported by the compilation command. | 768 // error should be reported by the compilation command. |
| 766 } else if (configuration['runtime'] == 'd8') { | 769 } else if (configuration['runtime'] == 'd8') { |
| 767 commands.add(new Command(d8FileName, ['$tempDir/out.js'])); | 770 commands.add(new Command(d8FileName, ['$tempDir/out.js'])); |
| 768 } else if (configuration['runtime'] == 'jsshell') { | 771 } else if (configuration['runtime'] == 'jsshell') { |
| 769 commands.add(new Command(jsShellFileName, ['$tempDir/out.js'])); | 772 commands.add(new Command(jsShellFileName, ['$tempDir/out.js'])); |
| 770 } | 773 } |
| 771 return commands; | 774 return commands; |
| 772 | 775 |
| 773 case 'dart2dart': | 776 case 'dart2dart': |
| 777 var compiledFile = '$tempDir/out-${runtime}.dart'; | |
| 778 var compiledShadowFile = '$tempDir/out_shadow.dart'; | |
| 774 args = new List.from(args); | 779 args = new List.from(args); |
| 775 args.add('--output-type=dart'); | 780 args.add('--output-type=dart'); |
| 776 String tempDir = createOutputDirectory(info.filePath, ''); | 781 String tempDir = createOutputDirectory(info.filePath, ''); |
| 777 args.add('--out=$tempDir/out.dart'); | 782 args.add('--out=$tempDir/out.dart'); |
| 778 | 783 |
| 779 List<Command> commands = | 784 List<Command> commands = |
| 780 <Command>[new CompilationCommand("$tempDir/out.dart", | 785 <Command>[new CompilationCommand(compiledFile, |
| 786 compiledShadowFile, | |
| 781 !useSdk, | 787 !useSdk, |
| 782 dart2JsBootstrapDependencies, | 788 dart2JsBootstrapDependencies, |
| 783 compilerPath, | 789 compilerPath, |
| 784 args)]; | 790 args)]; |
| 785 if (info.hasCompileError) { | 791 if (info.hasCompileError) { |
| 786 // Do not attempt to run the compiled result. A compilation | 792 // Do not attempt to run the compiled result. A compilation |
| 787 // error should be reported by the compilation command. | 793 // error should be reported by the compilation command. |
| 788 } else if (configuration['runtime'] == 'vm') { | 794 } else if (configuration['runtime'] == 'vm') { |
| 789 // TODO(antonm): support checked. | 795 // TODO(antonm): support checked. |
| 790 var vmArguments = new List.from(vmOptions); | 796 var vmArguments = new List.from(vmOptions); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 924 // TODO(dart:429): Replace separate replaceAlls with a RegExp when | 930 // TODO(dart:429): Replace separate replaceAlls with a RegExp when |
| 925 // replaceAll(RegExp, String) is implemented. | 931 // replaceAll(RegExp, String) is implemented. |
| 926 String optionsName = ''; | 932 String optionsName = ''; |
| 927 if (getVmOptions(optionsFromFile).length > 1) { | 933 if (getVmOptions(optionsFromFile).length > 1) { |
| 928 optionsName = vmOptions.join('-').replaceAll('-','') | 934 optionsName = vmOptions.join('-').replaceAll('-','') |
| 929 .replaceAll('=','') | 935 .replaceAll('=','') |
| 930 .replaceAll('/',''); | 936 .replaceAll('/',''); |
| 931 } | 937 } |
| 932 final String tempDir = createOutputDirectory(info.filePath, optionsName); | 938 final String tempDir = createOutputDirectory(info.filePath, optionsName); |
| 933 | 939 |
| 934 String dartWrapperFilename = '$tempDir/test.dart'; | 940 String dartWrapperFilename = '$tempDir/test-${runtime}.dart'; |
| 935 String compiledDartWrapperFilename = '$tempDir/test.js'; | 941 String compiledDartWrapperFile = '$tempDir/test-${runtime}.js'; |
| 942 String compiledDartWrapperShadowFile = '$tempDir/test_shadow.js'; | |
| 936 | 943 |
| 937 String htmlPath = '$tempDir/test.html'; | 944 String htmlPath = '$tempDir/test-${runtime}.html'; |
| 938 if (isWrappingRequired && !isWebTest) { | 945 if (isWrappingRequired && !isWebTest) { |
| 939 // test.dart will import the dart test. | 946 // test.dart will import the dart test. |
| 940 _createWrapperFile(dartWrapperFilename, filePath); | 947 _createWrapperFile(dartWrapperFilename, filePath); |
| 941 } else { | 948 } else { |
| 942 dartWrapperFilename = filename; | 949 dartWrapperFilename = filename; |
| 943 } | 950 } |
| 944 String scriptPath = (compiler == 'none') ? | 951 String scriptPath = (compiler == 'none') ? |
| 945 dartWrapperFilename : compiledDartWrapperFilename; | 952 dartWrapperFilename : compiledDartWrapperFile; |
| 946 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); | 953 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); |
| 947 | 954 |
| 948 // Create the HTML file for the test. | 955 // Create the HTML file for the test. |
| 949 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE); | 956 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE); |
| 950 String content = null; | 957 String content = null; |
| 951 Path dir = filePath.directoryPath; | 958 Path dir = filePath.directoryPath; |
| 952 String nameNoExt = filePath.filenameWithoutExtension; | 959 String nameNoExt = filePath.filenameWithoutExtension; |
| 953 Path pngPath = dir.append('$nameNoExt.png'); | 960 Path pngPath = dir.append('$nameNoExt.png'); |
| 954 Path txtPath = dir.append('$nameNoExt.txt'); | 961 Path txtPath = dir.append('$nameNoExt.txt'); |
| 955 Path expectedOutput = null; | 962 Path expectedOutput = null; |
| 956 if (new File.fromPath(pngPath).existsSync()) { | 963 if (new File.fromPath(pngPath).existsSync()) { |
| 957 expectedOutput = pngPath; | 964 expectedOutput = pngPath; |
| 958 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath")); | 965 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath")); |
| 959 } else if (new File.fromPath(txtPath).existsSync()) { | 966 } else if (new File.fromPath(txtPath).existsSync()) { |
| 960 expectedOutput = txtPath; | 967 expectedOutput = txtPath; |
| 961 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath")); | 968 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath")); |
| 962 } else { | 969 } else { |
| 963 content = getHtmlContents(filename, scriptType, | 970 content = getHtmlContents(filename, scriptType, |
| 964 new Path("$scriptPath")); | 971 new Path("$scriptPath")); |
| 965 } | 972 } |
| 966 htmlTest.writeStringSync(content); | 973 htmlTest.writeStringSync(content); |
| 967 htmlTest.closeSync(); | 974 htmlTest.closeSync(); |
| 968 | 975 |
| 969 // Construct the command(s) that compile all the inputs needed by the | 976 // Construct the command(s) that compile all the inputs needed by the |
| 970 // browser test. For running Dart in DRT, this will be noop commands. | 977 // browser test. For running Dart in DRT, this will be noop commands. |
| 971 List<Command> commands = []; | 978 List<Command> commands = []; |
| 972 if (compiler != 'none') { | 979 if (compiler != 'none') { |
| 973 commands.add(_compileCommand( | 980 commands.add(_compileCommand( |
| 974 dartWrapperFilename, compiledDartWrapperFilename, | 981 dartWrapperFilename, compiledDartWrapperFile, |
| 975 compiler, tempDir, vmOptions, optionsFromFile)); | 982 compiledDartWrapperShadowFile, compiler, tempDir, vmOptions, |
| 983 optionsFromFile)); | |
| 976 } | 984 } |
| 977 | 985 |
| 978 // some tests require compiling multiple input scripts. | 986 // some tests require compiling multiple input scripts. |
| 979 List<String> otherScripts = optionsFromFile['otherScripts']; | 987 List<String> otherScripts = optionsFromFile['otherScripts']; |
| 980 for (String name in otherScripts) { | 988 for (String name in otherScripts) { |
| 981 Path namePath = new Path(name); | 989 Path namePath = new Path(name); |
| 982 String baseName = namePath.filenameWithoutExtension; | 990 String baseName = namePath.filenameWithoutExtension; |
| 983 Path fromPath = filePath.directoryPath.join(namePath); | 991 Path fromPath = filePath.directoryPath.join(namePath); |
| 984 if (compiler != 'none') { | 992 if (compiler != 'none') { |
| 985 assert(namePath.extension == 'dart'); | 993 assert(namePath.extension == 'dart'); |
| 994 // FIXME: This might be an issue | |
|
ricow1
2013/06/25 13:10:48
No fixmes
kustermann
2013/06/25 13:20:11
Done.
| |
| 995 var compiledFile = '$tempDir/$baseName.js'; | |
| 996 var compiledShadowFile = '$tempDir/${baseName}_shadow.js'; | |
| 997 | |
| 986 commands.add(_compileCommand( | 998 commands.add(_compileCommand( |
| 987 fromPath.toNativePath(), '$tempDir/$baseName.js', | 999 fromPath.toNativePath(), compiledFile, compiledShadowFile, |
| 988 compiler, tempDir, vmOptions, optionsFromFile)); | 1000 compiler, tempDir, vmOptions, optionsFromFile)); |
| 989 } | 1001 } |
| 990 if (compiler == 'none') { | 1002 if (compiler == 'none') { |
| 991 // For the tests that require multiple input scripts but are not | 1003 // For the tests that require multiple input scripts but are not |
| 992 // compiled, move the input scripts over with the script so they can | 1004 // compiled, move the input scripts over with the script so they can |
| 993 // be accessed. | 1005 // be accessed. |
| 994 String result = new File.fromPath(fromPath).readAsStringSync(); | 1006 String result = new File.fromPath(fromPath).readAsStringSync(); |
| 995 new File('$tempDir/$baseName.dart').writeAsStringSync(result); | 1007 new File('$tempDir/$baseName.dart').writeAsStringSync(result); |
| 996 } | 1008 } |
| 997 } | 1009 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1096 multitestParentTest.addObserver(testCase); | 1108 multitestParentTest.addObserver(testCase); |
| 1097 } | 1109 } |
| 1098 | 1110 |
| 1099 doTest(testCase); | 1111 doTest(testCase); |
| 1100 subtestIndex++; | 1112 subtestIndex++; |
| 1101 } while(subtestIndex < subtestNames.length); | 1113 } while(subtestIndex < subtestNames.length); |
| 1102 } | 1114 } |
| 1103 } | 1115 } |
| 1104 | 1116 |
| 1105 /** Helper to create a compilation command for a single input file. */ | 1117 /** Helper to create a compilation command for a single input file. */ |
| 1106 Command _compileCommand(String inputFile, String outputFile, | 1118 Command _compileCommand(String inputFile, String outputFile, String |
|
ricow1
2013/06/25 13:10:48
move String down
kustermann
2013/06/25 13:20:11
Done.
| |
| 1107 String compiler, String dir, vmOptions, optionsFromFile) { | 1119 shadowFile, String compiler, String dir, vmOptions, optionsFromFile) { |
| 1108 String executable = compilerPath; | 1120 String executable = compilerPath; |
| 1109 List<String> args = TestUtils.standardOptions(configuration); | 1121 List<String> args = TestUtils.standardOptions(configuration); |
| 1110 switch (compiler) { | 1122 switch (compiler) { |
| 1111 case 'dart2js': | 1123 case 'dart2js': |
| 1112 case 'dart2dart': | 1124 case 'dart2dart': |
| 1113 String packageRoot = | 1125 String packageRoot = |
| 1114 packageRootArgument(optionsFromFile['packageRoot']); | 1126 packageRootArgument(optionsFromFile['packageRoot']); |
| 1115 if (packageRoot != null) { | 1127 if (packageRoot != null) { |
| 1116 args.add(packageRoot); | 1128 args.add(packageRoot); |
| 1117 } | 1129 } |
| 1118 args.add('--out=$outputFile'); | 1130 args.add('--out=$outputFile'); |
| 1119 args.add(inputFile); | 1131 args.add(inputFile); |
| 1120 break; | 1132 break; |
| 1121 default: | 1133 default: |
| 1122 print('unimplemented compiler $compiler'); | 1134 print('unimplemented compiler $compiler'); |
| 1123 exit(1); | 1135 exit(1); |
| 1124 } | 1136 } |
| 1125 if (executable.endsWith('.dart')) { | 1137 if (executable.endsWith('.dart')) { |
| 1126 // Run the compiler script via the Dart VM. | 1138 // Run the compiler script via the Dart VM. |
| 1127 args.insert(0, executable); | 1139 args.insert(0, executable); |
| 1128 executable = dartShellFileName; | 1140 executable = dartShellFileName; |
| 1129 } | 1141 } |
| 1130 if (['dart2js', 'dart2dart'].contains(configuration['compiler'])) { | 1142 if (['dart2js', 'dart2dart'].contains(configuration['compiler'])) { |
| 1131 return new CompilationCommand(outputFile, | 1143 return new CompilationCommand(outputFile, |
| 1144 shadowFile, | |
| 1132 !useSdk, | 1145 !useSdk, |
| 1133 dart2JsBootstrapDependencies, | 1146 dart2JsBootstrapDependencies, |
| 1134 compilerPath, | 1147 compilerPath, |
| 1135 args); | 1148 args); |
| 1136 } | 1149 } |
| 1137 return new Command(executable, args); | 1150 return new Command(executable, args); |
| 1138 } | 1151 } |
| 1139 | 1152 |
| 1140 /** | 1153 /** |
| 1141 * Create a directory for the generated test. If a Dart language test | 1154 * Create a directory for the generated test. If a Dart language test |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1158 testUniqueName = '$testUniqueName-$optionsName'; | 1171 testUniqueName = '$testUniqueName-$optionsName'; |
| 1159 } | 1172 } |
| 1160 | 1173 |
| 1161 // Create '[build dir]/generated_tests/$compiler-$runtime/$testUniqueName', | 1174 // Create '[build dir]/generated_tests/$compiler-$runtime/$testUniqueName', |
| 1162 // including any intermediate directories that don't exist. | 1175 // including any intermediate directories that don't exist. |
| 1163 // If the tests are run in checked or minified mode we add that to the | 1176 // If the tests are run in checked or minified mode we add that to the |
| 1164 // '$compile-$runtime' directory name. | 1177 // '$compile-$runtime' directory name. |
| 1165 var checked = configuration['checked'] ? '-checked' : ''; | 1178 var checked = configuration['checked'] ? '-checked' : ''; |
| 1166 var minified = configuration['minified'] ? '-minified' : ''; | 1179 var minified = configuration['minified'] ? '-minified' : ''; |
| 1167 var csp = configuration['csp'] ? '-csp' : ''; | 1180 var csp = configuration['csp'] ? '-csp' : ''; |
| 1168 var dirName = "${configuration['compiler']}-${configuration['runtime']}" | 1181 var dirName = "${configuration['compiler']}" |
| 1169 "$checked$minified$csp"; | 1182 "$checked$minified$csp"; |
|
ricow1
2013/06/25 13:10:48
fits one line?
kustermann
2013/06/25 13:20:11
Done.
| |
| 1170 Path generatedTestPath = new Path(buildDir) | 1183 Path generatedTestPath = new Path(buildDir) |
| 1171 .append('generated_tests') | 1184 .append('generated_tests') |
| 1172 .append(dirName) | 1185 .append(dirName) |
| 1173 .append(testUniqueName); | 1186 .append(testUniqueName); |
| 1174 | 1187 |
| 1175 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); | 1188 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); |
| 1176 return new File.fromPath(generatedTestPath).fullPathSync() | 1189 return new File.fromPath(generatedTestPath).fullPathSync() |
| 1177 .replaceAll('\\', '/'); | 1190 .replaceAll('\\', '/'); |
| 1178 } | 1191 } |
| 1179 | 1192 |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1965 * $pass tests are expected to pass | 1978 * $pass tests are expected to pass |
| 1966 * $failOk tests are expected to fail that we won't fix | 1979 * $failOk tests are expected to fail that we won't fix |
| 1967 * $fail tests are expected to fail that we should fix | 1980 * $fail tests are expected to fail that we should fix |
| 1968 * $crash tests are expected to crash that we should fix | 1981 * $crash tests are expected to crash that we should fix |
| 1969 * $timeout tests are allowed to timeout | 1982 * $timeout tests are allowed to timeout |
| 1970 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1983 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1971 """; | 1984 """; |
| 1972 print(report); | 1985 print(report); |
| 1973 } | 1986 } |
| 1974 } | 1987 } |
| OLD | NEW |