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

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

Issue 17570018: Do not compile tests for different browsers separately (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | « tools/testing/dart/test_runner.dart ('k') | 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 // NOTE: There is a tiny chance that this file will be accessed
995 // by two concurrent dart2js compile commands.
996 var compiledFile = '$tempDir/$baseName.js';
997 var compiledShadowFile = '$tempDir/${baseName}_shadow.js';
998
986 commands.add(_compileCommand( 999 commands.add(_compileCommand(
987 fromPath.toNativePath(), '$tempDir/$baseName.js', 1000 fromPath.toNativePath(), compiledFile, compiledShadowFile,
988 compiler, tempDir, vmOptions, optionsFromFile)); 1001 compiler, tempDir, vmOptions, optionsFromFile));
989 } 1002 }
990 if (compiler == 'none') { 1003 if (compiler == 'none') {
991 // For the tests that require multiple input scripts but are not 1004 // For the tests that require multiple input scripts but are not
992 // compiled, move the input scripts over with the script so they can 1005 // compiled, move the input scripts over with the script so they can
993 // be accessed. 1006 // be accessed.
994 String result = new File.fromPath(fromPath).readAsStringSync(); 1007 String result = new File.fromPath(fromPath).readAsStringSync();
995 new File('$tempDir/$baseName.dart').writeAsStringSync(result); 1008 new File('$tempDir/$baseName.dart').writeAsStringSync(result);
996 } 1009 }
997 } 1010 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 } 1110 }
1098 1111
1099 doTest(testCase); 1112 doTest(testCase);
1100 subtestIndex++; 1113 subtestIndex++;
1101 } while(subtestIndex < subtestNames.length); 1114 } while(subtestIndex < subtestNames.length);
1102 } 1115 }
1103 } 1116 }
1104 1117
1105 /** Helper to create a compilation command for a single input file. */ 1118 /** Helper to create a compilation command for a single input file. */
1106 Command _compileCommand(String inputFile, String outputFile, 1119 Command _compileCommand(String inputFile, String outputFile,
1107 String compiler, String dir, vmOptions, optionsFromFile) { 1120 String shadowFile, String compiler, String dir, vmOptions,
1121 optionsFromFile) {
1108 String executable = compilerPath; 1122 String executable = compilerPath;
1109 List<String> args = TestUtils.standardOptions(configuration); 1123 List<String> args = TestUtils.standardOptions(configuration);
1110 switch (compiler) { 1124 switch (compiler) {
1111 case 'dart2js': 1125 case 'dart2js':
1112 case 'dart2dart': 1126 case 'dart2dart':
1113 String packageRoot = 1127 String packageRoot =
1114 packageRootArgument(optionsFromFile['packageRoot']); 1128 packageRootArgument(optionsFromFile['packageRoot']);
1115 if (packageRoot != null) { 1129 if (packageRoot != null) {
1116 args.add(packageRoot); 1130 args.add(packageRoot);
1117 } 1131 }
1118 args.add('--out=$outputFile'); 1132 args.add('--out=$outputFile');
1119 args.add(inputFile); 1133 args.add(inputFile);
1120 break; 1134 break;
1121 default: 1135 default:
1122 print('unimplemented compiler $compiler'); 1136 print('unimplemented compiler $compiler');
1123 exit(1); 1137 exit(1);
1124 } 1138 }
1125 if (executable.endsWith('.dart')) { 1139 if (executable.endsWith('.dart')) {
1126 // Run the compiler script via the Dart VM. 1140 // Run the compiler script via the Dart VM.
1127 args.insert(0, executable); 1141 args.insert(0, executable);
1128 executable = dartShellFileName; 1142 executable = dartShellFileName;
1129 } 1143 }
1130 if (['dart2js', 'dart2dart'].contains(configuration['compiler'])) { 1144 if (['dart2js', 'dart2dart'].contains(configuration['compiler'])) {
1131 return new CompilationCommand(outputFile, 1145 return new CompilationCommand(outputFile,
1146 shadowFile,
1132 !useSdk, 1147 !useSdk,
1133 dart2JsBootstrapDependencies, 1148 dart2JsBootstrapDependencies,
1134 compilerPath, 1149 compilerPath,
1135 args); 1150 args);
1136 } 1151 }
1137 return new Command(executable, args); 1152 return new Command(executable, args);
1138 } 1153 }
1139 1154
1140 /** 1155 /**
1141 * Create a directory for the generated test. If a Dart language test 1156 * Create a directory for the generated test. If a Dart language test
(...skipping 16 matching lines...) Expand all
1158 testUniqueName = '$testUniqueName-$optionsName'; 1173 testUniqueName = '$testUniqueName-$optionsName';
1159 } 1174 }
1160 1175
1161 // Create '[build dir]/generated_tests/$compiler-$runtime/$testUniqueName', 1176 // Create '[build dir]/generated_tests/$compiler-$runtime/$testUniqueName',
1162 // including any intermediate directories that don't exist. 1177 // including any intermediate directories that don't exist.
1163 // If the tests are run in checked or minified mode we add that to the 1178 // If the tests are run in checked or minified mode we add that to the
1164 // '$compile-$runtime' directory name. 1179 // '$compile-$runtime' directory name.
1165 var checked = configuration['checked'] ? '-checked' : ''; 1180 var checked = configuration['checked'] ? '-checked' : '';
1166 var minified = configuration['minified'] ? '-minified' : ''; 1181 var minified = configuration['minified'] ? '-minified' : '';
1167 var csp = configuration['csp'] ? '-csp' : ''; 1182 var csp = configuration['csp'] ? '-csp' : '';
1168 var dirName = "${configuration['compiler']}-${configuration['runtime']}" 1183 var dirName = "${configuration['compiler']}$checked$minified$csp";
1169 "$checked$minified$csp";
1170 Path generatedTestPath = new Path(buildDir) 1184 Path generatedTestPath = new Path(buildDir)
1171 .append('generated_tests') 1185 .append('generated_tests')
1172 .append(dirName) 1186 .append(dirName)
1173 .append(testUniqueName); 1187 .append(testUniqueName);
1174 1188
1175 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); 1189 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath);
1176 return new File.fromPath(generatedTestPath).fullPathSync() 1190 return new File.fromPath(generatedTestPath).fullPathSync()
1177 .replaceAll('\\', '/'); 1191 .replaceAll('\\', '/');
1178 } 1192 }
1179 1193
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 * $pass tests are expected to pass 1979 * $pass tests are expected to pass
1966 * $failOk tests are expected to fail that we won't fix 1980 * $failOk tests are expected to fail that we won't fix
1967 * $fail tests are expected to fail that we should fix 1981 * $fail tests are expected to fail that we should fix
1968 * $crash tests are expected to crash that we should fix 1982 * $crash tests are expected to crash that we should fix
1969 * $timeout tests are allowed to timeout 1983 * $timeout tests are allowed to timeout
1970 * $compileErrorSkip tests are skipped on browsers due to compile-time error 1984 * $compileErrorSkip tests are skipped on browsers due to compile-time error
1971 """; 1985 """;
1972 print(report); 1986 print(report);
1973 } 1987 }
1974 } 1988 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698