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

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

Issue 700753004: Refactor browser test enqueuing in test scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix errors. Created 6 years, 1 month 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 | « tests/html/no_linked_scripts_htmltest.html ('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 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 } 834 }
835 return null; 835 return null;
836 } 836 }
837 837
838 void enqueueTestCaseFromTestInformation(TestInformation info) { 838 void enqueueTestCaseFromTestInformation(TestInformation info) {
839 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, 839 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath,
840 multitestName: 840 multitestName:
841 info.optionsFromFile['isMultitest'] ? info.multitestKey : ""); 841 info.optionsFromFile['isMultitest'] ? info.multitestKey : "");
842 Set<Expectation> expectations = testExpectations.expectations(testName); 842 Set<Expectation> expectations = testExpectations.expectations(testName);
843 if (info is HtmlTestInformation) { 843 if (info is HtmlTestInformation) {
844 if (TestUtils.isBrowserRuntime(configuration['runtime'])) { 844 enqueueHtmlTest(info, testName, expectations);
845 enqueueBrowserTest([], null, info, testName, expectations);
846 }
847 return; 845 return;
848 } 846 }
849 var filePath = info.filePath; 847 var filePath = info.filePath;
850 var optionsFromFile = info.optionsFromFile; 848 var optionsFromFile = info.optionsFromFile;
851 849
852 Map buildSpecialPackageRoot(Path pubspecYamlFile) { 850 Map buildSpecialPackageRoot(Path pubspecYamlFile) {
853 var commands = <Command>[]; 851 var commands = <Command>[];
854 var packageDir = pubspecYamlFile.directoryPath; 852 var packageDir = pubspecYamlFile.directoryPath;
855 var packageName = packageDir.filename; 853 var packageName = packageDir.filename;
856 854
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 * JavaScript. This function creates a working directory to hold the 1142 * JavaScript. This function creates a working directory to hold the
1145 * JavaScript version of the test, and copies the appropriate framework 1143 * JavaScript version of the test, and copies the appropriate framework
1146 * files to that directory. It creates a [BrowserTestCase], which has 1144 * files to that directory. It creates a [BrowserTestCase], which has
1147 * two sequential steps to be run by the [ProcessQueue] when the test is 1145 * two sequential steps to be run by the [ProcessQueue] when the test is
1148 * executed: a compilation step and an execution step, both with the 1146 * executed: a compilation step and an execution step, both with the
1149 * appropriate executable and arguments. The [expectations] object can be 1147 * appropriate executable and arguments. The [expectations] object can be
1150 * either a Set<String> if the test is a regular test, or a Map<String 1148 * either a Set<String> if the test is a regular test, or a Map<String
1151 * subTestName, Set<String>> if we are running a browser multi-test (one 1149 * subTestName, Set<String>> if we are running a browser multi-test (one
1152 * compilation and many browser runs). 1150 * compilation and many browser runs).
1153 */ 1151 */
1154 void enqueueBrowserTest(List<Command> baseCommands, 1152 void enqueueBrowserTest(
1155 Path packageRoot, 1153 List<Command> baseCommands,
1156 TestInformation info, 1154 Path packageRoot,
1157 String testName, 1155 TestInformation info,
1158 expectations) { 1156 String testName,
1157 expectations) {
1158 RegExp badChars = new RegExp('[-=/]');
1159 List VmOptionsList = getVmOptions(info.optionsFromFile);
1160 bool multipleOptions = VmOptionsList.length > 1;
1161 for (var vmOptions in VmOptionsList) {
1162 String optionsName =
1163 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : '';
1164 String tempDir = createOutputDirectory(info.filePath, optionsName);
1165 enqueueBrowserTestWithOptions(
1166 baseCommands,
1167 packageRoot,
1168 info,
1169 testName,
1170 expectations,
1171 vmOptions,
1172 tempDir);
1173 }
1174 }
1175
1176
1177 void enqueueBrowserTestWithOptions(
1178 List<Command> baseCommands,
1179 Path packageRoot,
1180 TestInformation info,
1181 String testName,
1182 expectations,
1183 List<String> vmOptions,
1184 String tempDir) {
1159 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] 1185 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot]
1160 // on to the browser (it may be test specific). 1186 // on to the browser (it may be test specific).
1161 1187
1162 // TODO(kustermann/ricow): This method should be refactored.
1163 Map optionsFromFile = info.optionsFromFile;
1164 Path filePath = info.filePath; 1188 Path filePath = info.filePath;
1165 String filename = filePath.toString(); 1189 String filename = filePath.toString();
1166 1190
1167 final String compiler = configuration['compiler']; 1191 final String compiler = configuration['compiler'];
1168 final String runtime = configuration['runtime']; 1192 final String runtime = configuration['runtime'];
1169 1193 final Map optionsFromFile = info.optionsFromFile;
1170 if (info is HtmlTestInformation) { 1194
1171 final String tempDir = createOutputDirectory(info.filePath, ''); 1195 final String compilationTempDir =
1172 final Uri tempUri = new Uri.file('$tempDir/'); 1196 createCompilationOutputDirectory(info.filePath);
1173 final Uri htmlFile = tempUri.resolve(filePath.filename); 1197
1174 new File.fromUri(htmlFile).writeAsStringSync(htmlTest.getContents(info)); 1198 String dartWrapperFilename = '$tempDir/test.dart';
1175 1199 String compiledDartWrapperFilename = '$compilationTempDir/test.js';
1176 void createFailingTest(String message) { 1200
1177 var msg = "$message: ${info.filePath}"; 1201 String content = null;
1178 DebugLogger.warning(msg); 1202 Path dir = filePath.directoryPath;
1179 new File.fromUri(htmlFile).writeAsStringSync( 1203 String nameNoExt = filePath.filenameWithoutExtension;
1180 htmlTest.makeFailingHtmlFile(msg)); 1204
1181 } 1205 Path pngPath = dir.append('$nameNoExt.png');
1182 if (info.scripts.length > 0) { 1206 Path txtPath = dir.append('$nameNoExt.txt');
1183 Uri testUri = new Uri.file(filePath.toNativePath()); 1207 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath();
1184 for (String scriptPath in info.scripts) { 1208 File customHtml = new File(customHtmlPath);
1185 if (!scriptPath.endsWith('.dart') && !scriptPath.endsWith('.js')) { 1209
1186 createFailingTest( 1210 // Construct the command(s) that compile all the inputs needed by the
1187 'HTML test scripts must be dart or javascript: $scriptPath'); 1211 // browser test. For running Dart in DRT, this will be noop commands.
1188 break; 1212 List<Command> commands = []..addAll(baseCommands);
1189 } 1213
1190 Uri uri = Uri.parse(scriptPath); 1214 // Use existing HTML document if available.
1191 if (uri.isAbsolute) { 1215 String htmlPath;
1192 createFailingTest( 1216 if (customHtml.existsSync()) {
1193 'HTML test scripts must have relative paths: $scriptPath'); 1217 // If necessary, run the Polymer deploy steps.
1194 break; 1218 // TODO(jmesserly): this should be generalized for any tests that
1195 } 1219 // require Pub deploy, not just polymer.
1196 if (uri.pathSegments.length > 1) { 1220 if (customHtml.readAsStringSync().contains('<!--polymer-test')) {
1197 createFailingTest( 1221 if (compiler != 'none') {
1198 'HTML test scripts must be in test directory: $scriptPath'); 1222 commands.add(
1199 break; 1223 _polymerDeployCommand(customHtmlPath, tempDir, optionsFromFile));
1200 } 1224
1201 Uri script = testUri.resolveUri(uri); 1225 Path pubspecYamlFile = _findPubspecYamlFile(filePath);
1202 if (compiler == 'none' || scriptPath.endsWith('.js')) { 1226 Path homeDir =
1203 Uri copiedScript = tempUri.resolveUri(uri); 1227 (pubspecYamlFile == null) ? dir : pubspecYamlFile.directoryPath;
1204 new File.fromUri(copiedScript).writeAsStringSync( 1228 htmlPath = '$tempDir/${dir.relativeTo(homeDir)}/$nameNoExt.html';
1205 new File.fromUri(script).readAsStringSync()); 1229 dartWrapperFilename = '${htmlPath}_bootstrap.dart';
1206 } else { 1230 compiledDartWrapperFilename = '$dartWrapperFilename.js';
1207 // TODO(21514): Compile scripts into output directory.
1208 createFailingTest('HTML test scripts don\'t support dart2js yet');
1209 break;
1210 }
1211 }
1212 }
1213
1214 String testDisplayName = '$suiteName/$testName';
1215 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath()));
1216 var fullHtmlPath = _getUriForBrowserTest(info, htmlPath,
1217 null, null);
1218 var commands = [CommandBuilder.instance.getBrowserHtmlTestCommand(
1219 runtime, fullHtmlPath, configuration, info.expectedMessages)];
1220 var testCase = new BrowserTestCase(testDisplayName,
1221 commands, configuration, expectations,
1222 info, isNegative(info), fullHtmlPath);
1223 enqueueNewTestCase(testCase);
1224 return;
1225 }
1226
1227 for (var vmOptions in getVmOptions(optionsFromFile)) {
1228 // Create a unique temporary directory for each set of vmOptions.
1229 // TODO(dart:429): Replace separate replaceAlls with a RegExp when
1230 // replaceAll(RegExp, String) is implemented.
1231 String optionsName = '';
1232 if (getVmOptions(optionsFromFile).length > 1) {
1233 optionsName = vmOptions.join('-').replaceAll('-','')
1234 .replaceAll('=','')
1235 .replaceAll('/','');
1236 }
1237 final String compilationTempDir =
1238 createCompilationOutputDirectory(info.filePath);
1239 final String tempDir = createOutputDirectory(info.filePath, optionsName);
1240
1241 String dartWrapperFilename = '$tempDir/test.dart';
1242 String compiledDartWrapperFilename = '$compilationTempDir/test.js';
1243
1244 String content = null;
1245 Path dir = filePath.directoryPath;
1246 String nameNoExt = filePath.filenameWithoutExtension;
1247
1248 Path pngPath = dir.append('$nameNoExt.png');
1249 Path txtPath = dir.append('$nameNoExt.txt');
1250 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath();
1251 File customHtml = new File(customHtmlPath);
1252
1253 // Construct the command(s) that compile all the inputs needed by the
1254 // browser test. For running Dart in DRT, this will be noop commands.
1255 List<Command> commands = []..addAll(baseCommands);
1256
1257 // Use existing HTML document if available.
1258 String htmlPath;
1259 if (customHtml.existsSync()) {
1260 // If necessary, run the Polymer deploy steps.
1261 // TODO(jmesserly): this should be generalized for any tests that
1262 // require Pub deploy, not just polymer.
1263 if (customHtml.readAsStringSync().contains('<!--polymer-test')) {
1264 if (compiler != 'none') {
1265 commands.add(_polymerDeployCommand(
1266 customHtmlPath, tempDir, optionsFromFile));
1267
1268 Path pubspecYamlFile = _findPubspecYamlFile(filePath);
1269 Path homeDir = pubspecYamlFile == null ? dir :
1270 pubspecYamlFile.directoryPath;
1271 htmlPath = '$tempDir/${dir.relativeTo(homeDir)}/$nameNoExt.html';
1272 dartWrapperFilename = '${htmlPath}_bootstrap.dart';
1273 compiledDartWrapperFilename = '$dartWrapperFilename.js';
1274 } else {
1275 htmlPath = customHtmlPath;
1276 }
1277 } else { 1231 } else {
1278 htmlPath = '$tempDir/test.html'; 1232 htmlPath = customHtmlPath;
1279 dartWrapperFilename = filePath.toNativePath();
1280
1281 var htmlContents = customHtml.readAsStringSync();
1282 if (compiler == 'none') {
1283 htmlContents = htmlContents.replaceAll('%TEST_SCRIPTS%',
1284 '<script type="application/dart" '
1285 'src="${_createUrlPathFromFile(filePath)}"></script>\n'
1286 '<script type="text/javascript" '
1287 'src="/packages/browser/dart.js"></script>');
1288 } else {
1289 compiledDartWrapperFilename = '$tempDir/$nameNoExt.js';
1290 var jsFile = '$nameNoExt.js';
1291 htmlContents = htmlContents.replaceAll('%TEST_SCRIPTS%',
1292 '<script src="$jsFile"></script>');
1293 }
1294 new File(htmlPath).writeAsStringSync(htmlContents);
1295 } 1233 }
1296 } else { 1234 } else {
1297 htmlPath = '$tempDir/test.html'; 1235 htmlPath = '$tempDir/test.html';
1298 if (configuration['compiler'] != 'dart2js') { 1236 dartWrapperFilename = filePath.toNativePath();
1299 // test.dart will import the dart test. 1237
1300 _createWrapperFile(dartWrapperFilename, filePath); 1238 var htmlContents = customHtml.readAsStringSync();
1239 if (compiler == 'none') {
1240 var dartUrl = _createUrlPathFromFile(filePath);
1241 var dartScript =
1242 '<script type="application/dart" src="$dartUrl"></script>';
1243 var jsUrl = '/packages/browser/dart.js';
1244 var jsScript =
1245 '<script type="text/javascript" src="$jsUrl"></script>';
1246 htmlContents = htmlContents.replaceAll(
1247 '%TEST_SCRIPTS%', '$dartScript\n$jsScript');
1301 } else { 1248 } else {
1302 dartWrapperFilename = filename; 1249 compiledDartWrapperFilename = '$tempDir/$nameNoExt.js';
1303 } 1250 var jsUrl = '$nameNoExt.js';
1304 1251 htmlContents = htmlContents.replaceAll(
1305 // Create the HTML file for the test. 1252 '%TEST_SCRIPTS%', '<script src="$jsUrl"></script>');
1306 RandomAccessFile htmlTest = 1253 }
1307 new File(htmlPath).openSync(mode: FileMode.WRITE); 1254 new File(htmlPath).writeAsStringSync(htmlContents);
1308 1255 }
1309 String scriptPath = dartWrapperFilename; 1256 } else {
1310 if (compiler != 'none') { 1257 htmlPath = '$tempDir/test.html';
1311 scriptPath = compiledDartWrapperFilename; 1258 if (configuration['compiler'] != 'dart2js') {
1312 } 1259 // test.dart will import the dart test.
1313 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); 1260 _createWrapperFile(dartWrapperFilename, filePath);
1314 1261 } else {
1315 content = 1262 dartWrapperFilename = filename;
1316 getHtmlContents(filename, scriptType, new Path("$scriptPath")); 1263 }
1317 htmlTest.writeStringSync(content); 1264
1318 htmlTest.closeSync(); 1265 // Create the HTML file for the test.
1319 } 1266 RandomAccessFile htmlTest =
1320 1267 new File(htmlPath).openSync(mode: FileMode.WRITE);
1268
1269 String scriptPath = dartWrapperFilename;
1321 if (compiler != 'none') { 1270 if (compiler != 'none') {
1322 commands.add(_compileCommand( 1271 scriptPath = compiledDartWrapperFilename;
1323 dartWrapperFilename, compiledDartWrapperFilename, 1272 }
1324 compiler, tempDir, vmOptions, optionsFromFile)); 1273 scriptPath = _createUrlPathFromFile(new Path(scriptPath));
1325 } 1274
1326 1275 content = getHtmlContents(filename, scriptType, new Path("$scriptPath"));
1327 // some tests require compiling multiple input scripts. 1276 htmlTest.writeStringSync(content);
1328 List<String> otherScripts = optionsFromFile['otherScripts']; 1277 htmlTest.closeSync();
1329 for (String name in otherScripts) { 1278 }
1330 Path namePath = new Path(name); 1279
1331 String fileName = namePath.filename; 1280 if (compiler != 'none') {
1332 Path fromPath = filePath.directoryPath.join(namePath); 1281 commands.add(
1333 if (compiler != 'none') { 1282 _compileCommand(
1334 assert(namePath.extension == 'dart'); 1283 dartWrapperFilename,
1335 commands.add(_compileCommand( 1284 compiledDartWrapperFilename,
1336 fromPath.toNativePath(), '$tempDir/$fileName.js', 1285 compiler,
1337 compiler, tempDir, vmOptions, optionsFromFile)); 1286 tempDir,
1338 } 1287 vmOptions,
1339 if (compiler == 'none') { 1288 optionsFromFile));
1340 // For the tests that require multiple input scripts but are not 1289 }
1341 // compiled, move the input scripts over with the script so they can 1290
1342 // be accessed. 1291 // some tests require compiling multiple input scripts.
1343 String result = new File(fromPath.toNativePath()).readAsStringSync(); 1292 List<String> otherScripts = optionsFromFile['otherScripts'];
1344 new File('$tempDir/$fileName').writeAsStringSync(result); 1293 for (String name in otherScripts) {
1345 } 1294 Path namePath = new Path(name);
1346 } 1295 String fileName = namePath.filename;
1347 1296 Path fromPath = filePath.directoryPath.join(namePath);
1348 1297 if (compiler != 'none') {
1349 // Variables for browser multi-tests. 1298 assert(namePath.extension == 'dart');
1350 List<String> subtestNames = info.optionsFromFile['subtestNames']; 1299 commands.add(
1351 int subtestIndex = 0; 1300 _compileCommand(
1352 // Construct the command that executes the browser test 1301 fromPath.toNativePath(),
1353 do { 1302 '$tempDir/$fileName.js',
1354 List<Command> commandSet = new List<Command>.from(commands); 1303 compiler,
1355 1304 tempDir,
1356 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); 1305 vmOptions,
1357 var fullHtmlPath = _getUriForBrowserTest(info, htmlPath_subtest, 1306 optionsFromFile));
1358 subtestNames, subtestIndex); 1307 }
1359 1308 if (compiler == 'none') {
1360 List<String> args = <String>[]; 1309 // For the tests that require multiple input scripts but are not
1361 1310 // compiled, move the input scripts over with the script so they can
1362 if (runtime == "drt") { 1311 // be accessed.
1363 var dartFlags = []; 1312 String result = new File(fromPath.toNativePath()).readAsStringSync();
1364 var contentShellOptions = []; 1313 new File('$tempDir/$fileName').writeAsStringSync(result);
1365 1314 }
1366 contentShellOptions.add('--no-timeout'); 1315 }
1367 contentShellOptions.add('--dump-render-tree'); 1316
1368 1317
1369 if (compiler == 'none' || compiler == 'dart2dart') { 1318 // Variables for browser multi-tests.
1370 dartFlags.add('--ignore-unrecognized-flags'); 1319 List<String> subtestNames = info.optionsFromFile['subtestNames'];
1371 if (configuration["checked"]) { 1320 int subtestIndex = 0;
1372 dartFlags.add('--enable_asserts'); 1321 // Construct the command that executes the browser test
1373 dartFlags.add("--enable_type_checks"); 1322 do {
1374 } 1323 List<Command> commandSet = new List<Command>.from(commands);
1375 dartFlags.addAll(vmOptions); 1324
1325 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath));
1326 var fullHtmlPath = _getUriForBrowserTest(
1327 info, htmlPath_subtest, subtestNames, subtestIndex);
1328
1329 List<String> args = <String>[];
1330
1331 if (runtime == "drt") {
1332 var dartFlags = [];
1333 var contentShellOptions = [];
1334
1335 contentShellOptions.add('--no-timeout');
1336 contentShellOptions.add('--dump-render-tree');
1337
1338 if (compiler == 'none' || compiler == 'dart2dart') {
1339 dartFlags.add('--ignore-unrecognized-flags');
1340 if (configuration["checked"]) {
1341 dartFlags.add('--enable_asserts');
1342 dartFlags.add("--enable_type_checks");
1376 } 1343 }
1377 1344 dartFlags.addAll(vmOptions);
1378 commandSet.add(CommandBuilder.instance.getContentShellCommand( 1345 }
1379 contentShellFilename, fullHtmlPath, contentShellOptions, 1346
1380 dartFlags, environmentOverrides)); 1347 commandSet.add(
1348 CommandBuilder.instance.getContentShellCommand(
1349 contentShellFilename,
1350 fullHtmlPath,
1351 contentShellOptions,
1352 dartFlags,
1353 environmentOverrides));
1354 } else {
1355 commandSet.add(
1356 CommandBuilder.instance.getBrowserTestCommand(
1357 runtime,
1358 fullHtmlPath,
1359 configuration));
1360 }
1361
1362 // Create BrowserTestCase and queue it.
1363 String testDisplayName = '$suiteName/$testName';
1364 var testCase;
1365 if (info.optionsFromFile['isMultiHtmlTest']) {
1366 testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}';
1367 testCase = new BrowserTestCase(
1368 testDisplayName,
1369 commandSet,
1370 configuration,
1371 expectations['$testName/${subtestNames[subtestIndex]}'],
1372 info,
1373 isNegative(info),
1374 fullHtmlPath);
1375 } else {
1376 testCase = new BrowserTestCase(
1377 testDisplayName,
1378 commandSet,
1379 configuration,
1380 expectations,
1381 info,
1382 isNegative(info),
1383 fullHtmlPath);
1384 }
1385
1386 enqueueNewTestCase(testCase);
1387 subtestIndex++;
1388 } while (subtestIndex < subtestNames.length);
ricow1 2014/11/10 11:46:35 maybe change this to a for loop (because the body
1389 }
1390
1391 void enqueueHtmlTest(
1392 HtmlTestInformation info,
1393 String testName,
1394 expectations) {
1395 final String compiler = configuration['compiler'];
1396 final String runtime = configuration['runtime'];
1397 // Html tests work only with the browser controller.
1398 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') {
1399 return;
1400 }
1401
1402 final Path filePath = info.filePath;
1403 final String tempDir = createOutputDirectory(filePath, '');
1404 final Uri tempUri = new Uri.file('$tempDir/');
1405 String contents = htmlTest.getContents(info);
1406
1407 void Fail(String message) {
1408 var msg = "$message: ${info.filePath}";
1409 DebugLogger.warning(msg);
1410 contents = htmlTest.makeFailingHtmlFile(msg);
1411 }
1412
1413 if (info.scripts.length > 0) {
1414 Uri testUri = new Uri.file(filePath.toNativePath());
1415 for (String scriptPath in info.scripts) {
1416 if (!scriptPath.endsWith('.dart') && !scriptPath.endsWith('.js')) {
1417 Fail('HTML test scripts must be dart or javascript: $scriptPath');
1418 break;
1419 }
1420 Uri uri = Uri.parse(scriptPath);
1421 if (uri.isAbsolute) {
1422 Fail('HTML test scripts must have relative paths: $scriptPath');
1423 break;
1424 }
1425 if (uri.pathSegments.length > 1) {
1426 Fail('HTML test scripts must be in test directory: $scriptPath');
1427 break;
1428 }
1429 Uri script = testUri.resolveUri(uri);
1430 if (compiler == 'none' || scriptPath.endsWith('.js')) {
1431 Uri copiedScript = tempUri.resolveUri(uri);
1432 new File.fromUri(copiedScript).writeAsStringSync(
1433 new File.fromUri(script).readAsStringSync());
1381 } else { 1434 } else {
1382 commandSet.add(CommandBuilder.instance.getBrowserTestCommand( 1435 // TODO(21514): Compile scripts into output directory.
1383 runtime, fullHtmlPath, configuration)); 1436 Fail('HTML test scripts don\'t support dart2js yet');
1384 } 1437 break;
1385 1438 }
1386 // Create BrowserTestCase and queue it. 1439 }
1387 String testDisplayName = '$suiteName/$testName'; 1440 }
1388 var testCase; 1441 final Uri htmlFile = tempUri.resolve(filePath.filename);
1389 if (info.optionsFromFile['isMultiHtmlTest']) { 1442 new File.fromUri(htmlFile).writeAsStringSync(contents);
1390 testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}'; 1443
1391 testCase = new BrowserTestCase(testDisplayName, 1444 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath()));
1392 commandSet, configuration, 1445 var fullHtmlPath = _getUriForBrowserTest(info, htmlPath, null, null);
1393 expectations['$testName/${subtestNames[subtestIndex]}'], 1446 var commands = [
1394 info, isNegative(info), fullHtmlPath); 1447 CommandBuilder.instance.getBrowserHtmlTestCommand(
1395 } else { 1448 runtime,
1396 testCase = new BrowserTestCase(testDisplayName, 1449 fullHtmlPath,
1397 commandSet, configuration, expectations, 1450 configuration,
1398 info, isNegative(info), fullHtmlPath); 1451 info.expectedMessages)];
1399 } 1452 String testDisplayName = '$suiteName/$testName';
1400 1453 var testCase = new BrowserTestCase(
1401 enqueueNewTestCase(testCase); 1454 testDisplayName,
1402 subtestIndex++; 1455 commands,
1403 } while(subtestIndex < subtestNames.length); 1456 configuration,
1404 } 1457 expectations,
1458 info,
1459 isNegative(info),
1460 fullHtmlPath);
1461 enqueueNewTestCase(testCase);
1462 return;
1405 } 1463 }
1406 1464
1407 /** Helper to create a compilation command for a single input file. */ 1465 /** Helper to create a compilation command for a single input file. */
1408 Command _compileCommand(String inputFile, String outputFile, 1466 Command _compileCommand(String inputFile, String outputFile,
1409 String compiler, String dir, vmOptions, optionsFromFile) { 1467 String compiler, String dir, vmOptions, optionsFromFile) {
1410 assert (['dart2js', 'dart2dart'].contains(compiler)); 1468 assert (['dart2js', 'dart2dart'].contains(compiler));
1411 String executable = compilerPath; 1469 String executable = compilerPath;
1412 List<String> args = TestUtils.standardOptions(configuration); 1470 List<String> args = TestUtils.standardOptions(configuration);
1413 String packageRoot = 1471 String packageRoot =
1414 packageRootArgument(optionsFromFile['packageRoot']); 1472 packageRootArgument(optionsFromFile['packageRoot']);
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 * $pass tests are expected to pass 2491 * $pass tests are expected to pass
2434 * $failOk tests are expected to fail that we won't fix 2492 * $failOk tests are expected to fail that we won't fix
2435 * $fail tests are expected to fail that we should fix 2493 * $fail tests are expected to fail that we should fix
2436 * $crash tests are expected to crash that we should fix 2494 * $crash tests are expected to crash that we should fix
2437 * $timeout tests are allowed to timeout 2495 * $timeout tests are allowed to timeout
2438 * $compileErrorSkip tests are skipped on browsers due to compile-time error 2496 * $compileErrorSkip tests are skipped on browsers due to compile-time error
2439 """; 2497 """;
2440 print(report); 2498 print(report);
2441 } 2499 }
2442 } 2500 }
OLDNEW
« no previous file with comments | « tests/html/no_linked_scripts_htmltest.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698