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

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

Issue 2949823003: Simplify enqueueBrowserTest(). (Closed)
Patch Set: Merge branch 'master' into simplify-enqueue-browser-test Created 3 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
« no previous file with comments | « no previous file | tools/testing/dart/utils.dart » ('j') | 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 } else { 745 } else {
746 createTestCase( 746 createTestCase(
747 filePath, 747 filePath,
748 filePath, 748 filePath,
749 optionsFromFile['hasCompileError'] as bool, 749 optionsFromFile['hasCompileError'] as bool,
750 optionsFromFile['hasRuntimeError'] as bool, 750 optionsFromFile['hasRuntimeError'] as bool,
751 hasStaticWarning: optionsFromFile['hasStaticWarning'] as bool); 751 hasStaticWarning: optionsFromFile['hasStaticWarning'] as bool);
752 } 752 }
753 } 753 }
754 754
755 static Path _findPubspecYamlFile(Path filePath) {
756 var root = TestUtils.dartDir;
757 assert("$filePath".startsWith("$root"));
758
759 // We start with the parent directory of [filePath] and go up until
760 // the root directory (excluding the root).
761 List<String> segments = filePath.directoryPath.relativeTo(root).segments();
762 while (segments.length > 0) {
763 var pubspecYamlPath = new Path(segments.join('/')).append('pubspec.yaml');
764 if (TestUtils.existsCache.doesFileExist(pubspecYamlPath.toNativePath())) {
765 return root.join(pubspecYamlPath);
766 }
767 segments.removeLast();
768 }
769
770 return null;
771 }
772
773 void enqueueTestCaseFromTestInformation(TestInformation info) { 755 void enqueueTestCaseFromTestInformation(TestInformation info) {
774 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, 756 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath,
775 multitestName: info.optionsFromFile['isMultitest'] as bool 757 multitestName: info.optionsFromFile['isMultitest'] as bool
776 ? info.multitestKey 758 ? info.multitestKey
777 : ""); 759 : "");
778 Set<Expectation> expectations = testExpectations.expectations(testName); 760 Set<Expectation> expectations = testExpectations.expectations(testName);
779 if (info is HtmlTestInformation) { 761 if (info is HtmlTestInformation) {
780 enqueueHtmlTest(info, testName, expectations); 762 _enqueueHtmlTest(info, testName, expectations);
781 return; 763 return;
782 } 764 }
783 765
784 var optionsFromFile = info.optionsFromFile; 766 var optionsFromFile = info.optionsFromFile;
785 767
786 // If this test is inside a package, we will check if there is a 768 // If this test is inside a package, we will check if there is a
787 // pubspec.yaml file and if so, create a custom package root for it. 769 // pubspec.yaml file and if so, create a custom package root for it.
788 Path packageRoot; 770 Path packageRoot;
789 Path packages; 771 Path packages;
790 772
(...skipping 24 matching lines...) Expand all
815 expectationsMap = <String, Set<Expectation>>{}; 797 expectationsMap = <String, Set<Expectation>>{};
816 for (var name in subtestNames) { 798 for (var name in subtestNames) {
817 var fullTestName = '$testName/$name'; 799 var fullTestName = '$testName/$name';
818 expectationsMap[fullTestName] = 800 expectationsMap[fullTestName] =
819 testExpectations.expectations(fullTestName); 801 testExpectations.expectations(fullTestName);
820 } 802 }
821 } else { 803 } else {
822 expectationsMap = {testName: expectations}; 804 expectationsMap = {testName: expectations};
823 } 805 }
824 806
825 enqueueBrowserTest( 807 _enqueueBrowserTest(
826 packageRoot, packages, info, testName, expectationsMap); 808 packageRoot, packages, info, testName, expectationsMap);
827 } else { 809 } else {
828 enqueueStandardTest(info, testName, expectations); 810 enqueueStandardTest(info, testName, expectations);
829 } 811 }
830 } 812 }
831 813
832 void enqueueStandardTest( 814 void enqueueStandardTest(
833 TestInformation info, String testName, Set<Expectation> expectations) { 815 TestInformation info, String testName, Set<Expectation> expectations) {
834 var commonArguments = 816 var commonArguments =
835 commonArgumentsFromFile(info.filePath, info.optionsFromFile); 817 commonArgumentsFromFile(info.filePath, info.optionsFromFile);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 * JavaScript. This function creates a working directory to hold the 997 * JavaScript. This function creates a working directory to hold the
1016 * JavaScript version of the test, and copies the appropriate framework 998 * JavaScript version of the test, and copies the appropriate framework
1017 * files to that directory. It creates a [BrowserTestCase], which has 999 * files to that directory. It creates a [BrowserTestCase], which has
1018 * two sequential steps to be run by the [ProcessQueue] when the test is 1000 * two sequential steps to be run by the [ProcessQueue] when the test is
1019 * executed: a compilation step and an execution step, both with the 1001 * executed: a compilation step and an execution step, both with the
1020 * appropriate executable and arguments. The [expectations] object can be 1002 * appropriate executable and arguments. The [expectations] object can be
1021 * either a Set<String> if the test is a regular test, or a Map<String 1003 * either a Set<String> if the test is a regular test, or a Map<String
1022 * subTestName, Set<String>> if we are running a browser multi-test (one 1004 * subTestName, Set<String>> if we are running a browser multi-test (one
1023 * compilation and many browser runs). 1005 * compilation and many browser runs).
1024 */ 1006 */
1025 void enqueueBrowserTest(Path packageRoot, Path packages, TestInformation info, 1007 void _enqueueBrowserTest(
1026 String testName, Map<String, Set<Expectation>> expectations) { 1008 Path packageRoot,
1009 Path packages,
1010 TestInformation info,
1011 String testName,
1012 Map<String, Set<Expectation>> expectations) {
1027 var badChars = new RegExp('[-=/]'); 1013 var badChars = new RegExp('[-=/]');
1028 var vmOptionsList = getVmOptions(info.optionsFromFile); 1014 var vmOptionsList = getVmOptions(info.optionsFromFile);
1029 var multipleOptions = vmOptionsList.length > 1; 1015 var multipleOptions = vmOptionsList.length > 1;
1030 for (var vmOptions in vmOptionsList) { 1016 for (var vmOptions in vmOptionsList) {
1031 var optionsName = 1017 var optionsName =
1032 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : ''; 1018 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : '';
1033 var tempDir = createOutputDirectory(info.filePath, optionsName); 1019 var tempDir = createOutputDirectory(info.filePath, optionsName);
1034 enqueueBrowserTestWithOptions(packageRoot, packages, info, testName, 1020 _enqueueBrowserTestWithOptions(packageRoot, packages, info, testName,
1035 expectations, vmOptions, tempDir); 1021 expectations, vmOptions, tempDir);
1036 } 1022 }
1037 } 1023 }
1038 1024
1039 void enqueueBrowserTestWithOptions( 1025 void _enqueueBrowserTestWithOptions(
1040 Path packageRoot, 1026 Path packageRoot,
1041 Path packages, 1027 Path packages,
1042 TestInformation info, 1028 TestInformation info,
1043 String testName, 1029 String testName,
1044 Map<String, Set<Expectation>> expectations, 1030 Map<String, Set<Expectation>> expectations,
1045 List<String> vmOptions, 1031 List<String> vmOptions,
1046 String tempDir) { 1032 String tempDir) {
1047 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] 1033 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot]
1048 // on to the browser (it may be test specific). 1034 // on to the browser (it may be test specific).
1049 var filePath = info.filePath; 1035 var filePath = info.filePath;
1050 var fileName = filePath.toString(); 1036 var fileName = filePath.toString();
1051 1037
1052 var optionsFromFile = info.optionsFromFile; 1038 var optionsFromFile = info.optionsFromFile;
1053 var compilationTempDir = createCompilationOutputDirectory(info.filePath); 1039 var compilationTempDir = createCompilationOutputDirectory(info.filePath);
1054 var dartWrapperFilename = '$tempDir/test.dart'; 1040 var dartWrapperFilename = '$tempDir/test.dart';
1055 var compiledDartWrapperFilename = '$compilationTempDir/test.js'; 1041 var compiledDartWrapperFilename = '$compilationTempDir/test.js';
1056 var dir = filePath.directoryPath; 1042 var dir = filePath.directoryPath;
1057 var nameNoExt = filePath.filenameWithoutExtension; 1043 var nameNoExt = filePath.filenameWithoutExtension;
1058 var customHtmlPath = dir.append('$nameNoExt.html').toNativePath(); 1044 var customHtmlPath = dir.append('$nameNoExt.html').toNativePath();
1059 var customHtml = new File(customHtmlPath); 1045 var customHtml = new File(customHtmlPath);
1060 1046
1061 // Construct the command(s) that compile all the inputs needed by the
1062 // browser test. For running Dart in DRT, this will be noop commands.
1063 var commands = <Command>[];
1064
1065 // Use existing HTML document if available. 1047 // Use existing HTML document if available.
1066 String htmlPath; 1048 String htmlPath;
1067 String content; 1049 String content;
1068 if (customHtml.existsSync()) { 1050 if (customHtml.existsSync()) {
1069 // If necessary, run the Polymer deploy steps. 1051 htmlPath = '$tempDir/test.html';
1070 // TODO(jmesserly): this should be generalized for any tests that 1052 dartWrapperFilename = filePath.toNativePath();
1071 // require Pub deploy, not just polymer.
1072 // TODO(rnystrom): This does not appear to be used any more. Remove.
1073 if (customHtml.readAsStringSync().contains('<!--polymer-test')) {
1074 if (configuration.compiler != Compiler.none) {
1075 commands.add(
1076 _polymerDeployCommand(customHtmlPath, tempDir, optionsFromFile));
1077 1053
1078 Path pubspecYamlFile = _findPubspecYamlFile(filePath); 1054 var htmlContents = customHtml.readAsStringSync();
1079 Path homeDir = 1055 if (configuration.compiler == Compiler.none) {
1080 (pubspecYamlFile == null) ? dir : pubspecYamlFile.directoryPath; 1056 var dartUrl = _createUrlPathFromFile(filePath);
1081 htmlPath = '$tempDir/${dir.relativeTo(homeDir)}/$nameNoExt.html'; 1057 var dartScript =
1082 dartWrapperFilename = '${htmlPath}_bootstrap.dart'; 1058 '<script type="application/dart" src="$dartUrl"></script>';
1083 compiledDartWrapperFilename = '$dartWrapperFilename.js'; 1059 var jsUrl = '/packages/browser/dart.js';
1084 } else { 1060 var jsScript = '<script type="text/javascript" src="$jsUrl"></script>';
1085 htmlPath = customHtmlPath; 1061 htmlContents =
1086 } 1062 htmlContents.replaceAll('%TEST_SCRIPTS%', '$dartScript\n$jsScript');
1087 } else { 1063 } else {
1088 htmlPath = '$tempDir/test.html'; 1064 compiledDartWrapperFilename = '$tempDir/$nameNoExt.js';
1089 dartWrapperFilename = filePath.toNativePath(); 1065 htmlContents = htmlContents.replaceAll(
1090 1066 '%TEST_SCRIPTS%', '<script src="$nameNoExt.js"></script>');
1091 var htmlContents = customHtml.readAsStringSync();
1092 if (configuration.compiler == Compiler.none) {
1093 var dartUrl = _createUrlPathFromFile(filePath);
1094 var dartScript =
1095 '<script type="application/dart" src="$dartUrl"></script>';
1096 var jsUrl = '/packages/browser/dart.js';
1097 var jsScript =
1098 '<script type="text/javascript" src="$jsUrl"></script>';
1099 htmlContents = htmlContents.replaceAll(
1100 '%TEST_SCRIPTS%', '$dartScript\n$jsScript');
1101 } else {
1102 compiledDartWrapperFilename = '$tempDir/$nameNoExt.js';
1103 var jsUrl = '$nameNoExt.js';
1104 htmlContents = htmlContents.replaceAll(
1105 '%TEST_SCRIPTS%', '<script src="$jsUrl"></script>');
1106 }
1107 new File(htmlPath).writeAsStringSync(htmlContents);
1108 } 1067 }
1068 new File(htmlPath).writeAsStringSync(htmlContents);
1109 } else { 1069 } else {
1110 htmlPath = '$tempDir/test.html'; 1070 htmlPath = '$tempDir/test.html';
1111 if (configuration.compiler != Compiler.dart2js && 1071 if (configuration.compiler != Compiler.dart2js &&
1112 configuration.compiler != Compiler.dartdevc) { 1072 configuration.compiler != Compiler.dartdevc) {
1113 // test.dart will import the dart test. 1073 // test.dart will import the dart test.
1114 _createWrapperFile(dartWrapperFilename, filePath); 1074 _createWrapperFile(dartWrapperFilename, filePath);
1115 } else { 1075 } else {
1116 dartWrapperFilename = fileName; 1076 dartWrapperFilename = fileName;
1117 } 1077 }
1118 1078
1119 // Create the HTML file for the test. 1079 // Create the HTML file for the test.
1120 var htmlTest = new File(htmlPath).openSync(mode: FileMode.WRITE);
1121
1122 var scriptPath = dartWrapperFilename; 1080 var scriptPath = dartWrapperFilename;
1123 if (configuration.compiler != Compiler.none) { 1081 if (configuration.compiler != Compiler.none) {
1124 scriptPath = compiledDartWrapperFilename; 1082 scriptPath = compiledDartWrapperFilename;
1125 } 1083 }
1126 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); 1084 scriptPath = _createUrlPathFromFile(new Path(scriptPath));
1127 1085
1128 if (configuration.compiler != Compiler.dartdevc) { 1086 if (configuration.compiler != Compiler.dartdevc) {
1129 content = getHtmlContents(fileName, scriptType, scriptPath); 1087 content = getHtmlContents(fileName, scriptType, scriptPath);
1130 } else { 1088 } else {
1131 var jsDir = new Path(compilationTempDir) 1089 var jsDir = new Path(compilationTempDir)
1132 .relativeTo(TestUtils.dartDir) 1090 .relativeTo(TestUtils.dartDir)
1133 .toString(); 1091 .toString();
1134 content = dartdevcHtml(nameNoExt, jsDir); 1092 content = dartdevcHtml(nameNoExt, jsDir);
1135 } 1093 }
1136 1094
1137 htmlTest.writeStringSync(content); 1095 new File(htmlPath).writeAsStringSync(content);
1138 htmlTest.closeSync();
1139 } 1096 }
1140 1097
1098 // Construct the command(s) that compile all the inputs needed by the
1099 // browser test. For running Dart in DRT, this will be noop commands.
1100 var commands = <Command>[];
1101
1141 switch (configuration.compiler) { 1102 switch (configuration.compiler) {
1142 case Compiler.dart2js: 1103 case Compiler.dart2js:
1143 commands.add(_dart2jsCompileCommand(dartWrapperFilename, 1104 commands.add(_dart2jsCompileCommand(dartWrapperFilename,
1144 compiledDartWrapperFilename, tempDir, optionsFromFile)); 1105 compiledDartWrapperFilename, tempDir, optionsFromFile));
1145 break; 1106 break;
1146 1107
1147 case Compiler.dartdevc: 1108 case Compiler.dartdevc:
1148 commands.add(_dartdevcCompileCommand(dartWrapperFilename, 1109 commands.add(_dartdevcCompileCommand(dartWrapperFilename,
1149 '$compilationTempDir/$nameNoExt.js', optionsFromFile)); 1110 '$compilationTempDir/$nameNoExt.js', optionsFromFile));
1150 break; 1111 break;
1151 1112
1152 case Compiler.none: 1113 case Compiler.none:
1153 break; 1114 break;
1154 1115
1155 default: 1116 default:
1156 assert(false); 1117 assert(false);
1157 } 1118 }
1158 1119
1159 // Some tests require compiling multiple input scripts. 1120 // Some tests require compiling multiple input scripts.
1160 var otherScripts = optionsFromFile['otherScripts'] as List<String>; 1121 for (var name in optionsFromFile['otherScripts'] as List<String>) {
1161 for (var name in otherScripts) {
1162 var namePath = new Path(name); 1122 var namePath = new Path(name);
1163 var fromPath = filePath.directoryPath.join(namePath); 1123 var fromPath = filePath.directoryPath.join(namePath);
1164 1124
1165 switch (configuration.compiler) { 1125 switch (configuration.compiler) {
1166 case Compiler.dart2js: 1126 case Compiler.dart2js:
1167 commands.add(_dart2jsCompileCommand(fromPath.toNativePath(), 1127 commands.add(_dart2jsCompileCommand(fromPath.toNativePath(),
1168 '$tempDir/${namePath.filename}.js', tempDir, optionsFromFile)); 1128 '$tempDir/${namePath.filename}.js', tempDir, optionsFromFile));
1169 break; 1129 break;
1170 1130
1171 case Compiler.dartdevc: 1131 case Compiler.dartdevc:
1172 commands.add(_dartdevcCompileCommand(fromPath.toNativePath(), 1132 commands.add(_dartdevcCompileCommand(fromPath.toNativePath(),
1173 '$tempDir/$nameNoExt.js', optionsFromFile)); 1133 '$tempDir/${namePath.filename}.js', optionsFromFile));
1174 break; 1134 break;
1175 1135
1176 default: 1136 default:
1177 assert(configuration.compiler == Compiler.none); 1137 assert(configuration.compiler == Compiler.none);
1178 } 1138 }
1179 1139
1180 if (configuration.compiler == Compiler.none) { 1140 if (configuration.compiler == Compiler.none) {
1181 // For the tests that require multiple input scripts but are not 1141 // For the tests that require multiple input scripts but are not
1182 // compiled, move the input scripts over with the script so they can 1142 // compiled, move the input scripts over with the script so they can
1183 // be accessed. 1143 // be accessed.
1184 var result = new File(fromPath.toNativePath()).readAsStringSync(); 1144 new File(fromPath.toNativePath())
1185 new File('$tempDir/${namePath.filename}').writeAsStringSync(result); 1145 .copySync('$tempDir/${namePath.filename}');
1186 } 1146 }
1187 } 1147 }
1188 1148
1189 // Variables for browser multi-tests. 1149 if (info.optionsFromFile['isMultiHtmlTest'] as bool) {
1190 var isMultitest = info.optionsFromFile['isMultiHtmlTest'] as bool; 1150 // Variables for browser multi-tests.
1191 var subtestNames = isMultitest 1151 var subtestNames = info.optionsFromFile['subtestNames'] as List<String>;
1192 ? (info.optionsFromFile['subtestNames'] as List<String>) 1152 for (var subtestName in subtestNames) {
1193 : <String>[null]; 1153 _enqueueSingleBrowserTest(commands, info, '$testName/$subtestName',
1194 for (var subtestName in subtestNames) { 1154 subtestName, expectations, vmOptions, htmlPath);
1195 // Construct the command that executes the browser test
1196 var commandSet = commands.toList();
1197
1198 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath));
1199 var fullHtmlPath =
1200 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString();
1201
1202 if (configuration.runtime == Runtime.drt) {
1203 var dartFlags = <String>[];
1204 var contentShellOptions = ['--no-timeout', '--run-layout-test'];
1205
1206 // Disable the GPU under Linux and Dartium. If the GPU is enabled,
1207 // Chrome may send a termination signal to a test. The test will be
1208 // terminated if a machine (bot) doesn't have a GPU or if a test is
1209 // still running after a certain period of time.
1210 if (configuration.system == System.linux &&
1211 configuration.runtime == Runtime.drt) {
1212 contentShellOptions.add('--disable-gpu');
1213 // TODO(terry): Roll 50 need this in conjection with disable-gpu.
1214 contentShellOptions.add('--disable-gpu-early-init');
1215 }
1216
1217 if (configuration.compiler == Compiler.none) {
1218 dartFlags.add('--ignore-unrecognized-flags');
1219 if (configuration.isChecked) {
1220 dartFlags.add('--enable_asserts');
1221 dartFlags.add("--enable_type_checks");
1222 }
1223 dartFlags.addAll(vmOptions);
1224 }
1225
1226 commandSet.add(Command.contentShell(contentShellFilename, fullHtmlPath,
1227 contentShellOptions, dartFlags, environmentOverrides));
1228 } else {
1229 commandSet.add(Command.browserTest(fullHtmlPath, configuration,
1230 retry: !isNegative(info)));
1231 } 1155 }
1232 1156 } else {
1233 // Create BrowserTestCase and queue it. 1157 _enqueueSingleBrowserTest(
1234 var fullTestName = isMultitest ? '$testName/$subtestName' : testName; 1158 commands, info, testName, null, expectations, vmOptions, htmlPath);
1235 var expectation = expectations[fullTestName];
1236 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet,
1237 configuration, expectation, info, isNegative(info), fullHtmlPath);
1238
1239 enqueueNewTestCase(testCase);
1240 } 1159 }
1241 } 1160 }
1242 1161
1243 void enqueueHtmlTest(HtmlTestInformation info, String testName, 1162 /// Enqueues a single browser test, or a single subtest of an HTML multitest.
1163 void _enqueueSingleBrowserTest(
1164 List<Command> commands,
1165 TestInformation info,
1166 String testName,
1167 String subtestName,
1168 Map<String, Set<Expectation>> expectations,
1169 List<String> vmOptions,
1170 String htmlPath) {
1171 // Construct the command that executes the browser test.
1172 commands = commands.toList();
1173
1174 var htmlPathSubtest = _createUrlPathFromFile(new Path(htmlPath));
1175 var fullHtmlPath =
1176 _getUriForBrowserTest(htmlPathSubtest, subtestName).toString();
1177
1178 if (configuration.runtime == Runtime.drt) {
1179 var dartFlags = <String>[];
1180 var contentShellOptions = ['--no-timeout', '--run-layout-test'];
1181
1182 // Disable the GPU under Linux and Dartium. If the GPU is enabled,
1183 // Chrome may send a termination signal to a test. The test will be
1184 // terminated if a machine (bot) doesn't have a GPU or if a test is
1185 // still running after a certain period of time.
1186 if (configuration.system == System.linux &&
1187 configuration.runtime == Runtime.drt) {
1188 contentShellOptions.add('--disable-gpu');
1189 // TODO(terry): Roll 50 need this in conjection with disable-gpu.
1190 contentShellOptions.add('--disable-gpu-early-init');
1191 }
1192
1193 if (configuration.compiler == Compiler.none) {
1194 dartFlags.add('--ignore-unrecognized-flags');
1195 if (configuration.isChecked) {
1196 dartFlags.add('--enable_asserts');
1197 dartFlags.add("--enable_type_checks");
1198 }
1199 dartFlags.addAll(vmOptions);
1200 }
1201
1202 commands.add(Command.contentShell(contentShellFilename, fullHtmlPath,
1203 contentShellOptions, dartFlags, environmentOverrides));
1204 } else {
1205 commands.add(Command.browserTest(fullHtmlPath, configuration,
1206 retry: !isNegative(info)));
1207 }
1208
1209 // Create BrowserTestCase and queue it.
1210 var expectation = expectations[testName];
1211 var testCase = new BrowserTestCase('$suiteName/$testName', commands,
1212 configuration, expectation, info, isNegative(info), fullHtmlPath);
1213
1214 enqueueNewTestCase(testCase);
1215 }
1216
1217 void _enqueueHtmlTest(HtmlTestInformation info, String testName,
1244 Set<Expectation> expectations) { 1218 Set<Expectation> expectations) {
1245 var compiler = configuration.compiler; 1219 var compiler = configuration.compiler;
1246 var runtime = configuration.runtime; 1220 var runtime = configuration.runtime;
1247 1221
1248 if (compiler == Compiler.dartdevc) { 1222 if (compiler == Compiler.dartdevc) {
1249 // TODO(rnystrom): Support this for dartdevc (#29919). 1223 // TODO(rnystrom): Support this for dartdevc (#29919).
1250 print("Ignoring $testName on dartdevc since HTML tests are not " 1224 print("Ignoring $testName on dartdevc since HTML tests are not "
1251 "implemented for that compiler yet."); 1225 "implemented for that compiler yet.");
1252 return; 1226 return;
1253 } 1227 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 1342
1369 return Command.compilation( 1343 return Command.compilation(
1370 Compiler.dartdevc.name, 1344 Compiler.dartdevc.name,
1371 outputFile, 1345 outputFile,
1372 configuration.compilerConfiguration.bootstrapDependencies(buildDir), 1346 configuration.compilerConfiguration.bootstrapDependencies(buildDir),
1373 compilerPath, 1347 compilerPath,
1374 args, 1348 args,
1375 environmentOverrides); 1349 environmentOverrides);
1376 } 1350 }
1377 1351
1378 /** Helper to create a Polymer deploy command for a single HTML file. */
1379 Command _polymerDeployCommand(String inputFile, String outputDir,
1380 Map<String, dynamic> optionsFromFile) {
1381 var args = <String>[];
1382 var packages = packagesArgument(optionsFromFile['packageRoot'] as String,
1383 optionsFromFile['packages'] as String);
1384 if (packages != null) args.add(packages);
1385 args
1386 ..add('package:polymer/deploy.dart')
1387 ..add('--test')
1388 ..add(inputFile)
1389 ..add('--out')
1390 ..add(outputDir)
1391 ..add('--file-filter')
1392 ..add('.svn');
1393 if (configuration.isCsp) args.add('--csp');
1394
1395 return Command.process(
1396 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides);
1397 }
1398
1399 String get scriptType { 1352 String get scriptType {
1400 switch (configuration.compiler) { 1353 switch (configuration.compiler) {
1401 case Compiler.none: 1354 case Compiler.none:
1402 return 'application/dart'; 1355 return 'application/dart';
1403 case Compiler.dart2js: 1356 case Compiler.dart2js:
1404 case Compiler.dart2analyzer: 1357 case Compiler.dart2analyzer:
1405 case Compiler.dartdevc: 1358 case Compiler.dartdevc:
1406 return 'text/javascript'; 1359 return 'text/javascript';
1407 default: 1360 default:
1408 print('Non-web runtime, so no scriptType for: ' 1361 print('Non-web runtime, so no scriptType for: '
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 1703
1751 /// Used for testing packages in on off settings, i.e., we pass in the actual 1704 /// Used for testing packages in on off settings, i.e., we pass in the actual
1752 /// directory that we want to test. 1705 /// directory that we want to test.
1753 class PKGTestSuite extends StandardTestSuite { 1706 class PKGTestSuite extends StandardTestSuite {
1754 PKGTestSuite(Configuration configuration, Path directoryPath) 1707 PKGTestSuite(Configuration configuration, Path directoryPath)
1755 : super(configuration, directoryPath.filename, directoryPath, 1708 : super(configuration, directoryPath.filename, directoryPath,
1756 ["$directoryPath/.status"], 1709 ["$directoryPath/.status"],
1757 isTestFilePredicate: (f) => f.endsWith('_test.dart'), 1710 isTestFilePredicate: (f) => f.endsWith('_test.dart'),
1758 recursive: true); 1711 recursive: true);
1759 1712
1760 void enqueueBrowserTest(Path packageRoot, packages, TestInformation info, 1713 void _enqueueBrowserTest(Path packageRoot, packages, TestInformation info,
1761 String testName, Map<String, Set<Expectation>> expectations) { 1714 String testName, Map<String, Set<Expectation>> expectations) {
1762 var filePath = info.filePath; 1715 var filePath = info.filePath;
1763 var dir = filePath.directoryPath; 1716 var dir = filePath.directoryPath;
1764 var nameNoExt = filePath.filenameWithoutExtension; 1717 var nameNoExt = filePath.filenameWithoutExtension;
1765 var customHtmlPath = dir.append('$nameNoExt.html'); 1718 var customHtmlPath = dir.append('$nameNoExt.html');
1766 var customHtml = new File(customHtmlPath.toNativePath()); 1719 var customHtml = new File(customHtmlPath.toNativePath());
1767 if (!customHtml.existsSync()) { 1720 if (!customHtml.existsSync()) {
1768 super.enqueueBrowserTest( 1721 super._enqueueBrowserTest(
1769 packageRoot, packages, info, testName, expectations); 1722 packageRoot, packages, info, testName, expectations);
1770 } else { 1723 } else {
1771 var relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); 1724 var relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir);
1772 var fullPath = _createUrlPathFromFile(customHtmlPath); 1725 var fullPath = _createUrlPathFromFile(customHtmlPath);
1773 1726
1774 var commands = [ 1727 var commands = [
1775 Command.browserTest(fullPath, configuration, retry: !isNegative(info)) 1728 Command.browserTest(fullPath, configuration, retry: !isNegative(info))
1776 ]; 1729 ];
1777 var testDisplayName = '$suiteName/$testName'; 1730 var testDisplayName = '$suiteName/$testName';
1778 enqueueNewTestCase(new BrowserTestCase( 1731 enqueueNewTestCase(new BrowserTestCase(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 1789
1837 bool isTestFile(String filename) { 1790 bool isTestFile(String filename) {
1838 // NOTE: We exclude tests and patch files for now. 1791 // NOTE: We exclude tests and patch files for now.
1839 return filename.endsWith(".dart") && 1792 return filename.endsWith(".dart") &&
1840 !filename.endsWith("_test.dart") && 1793 !filename.endsWith("_test.dart") &&
1841 !filename.contains("_internal/js_runtime/lib"); 1794 !filename.contains("_internal/js_runtime/lib");
1842 } 1795 }
1843 1796
1844 bool get listRecursively => true; 1797 bool get listRecursively => true;
1845 } 1798 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698