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

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

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