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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1094 return "/$PREFIX_BUILDDIR/$fileRelativeToBuildDir"; | 1094 return "/$PREFIX_BUILDDIR/$fileRelativeToBuildDir"; |
1095 } else if (fileString.startsWith(dartDir.toString())) { | 1095 } else if (fileString.startsWith(dartDir.toString())) { |
1096 var fileRelativeToDartDir = file.relativeTo(dartDir); | 1096 var fileRelativeToDartDir = file.relativeTo(dartDir); |
1097 return "/$PREFIX_DARTDIR/$fileRelativeToDartDir"; | 1097 return "/$PREFIX_DARTDIR/$fileRelativeToDartDir"; |
1098 } | 1098 } |
1099 // Unreachable | 1099 // Unreachable |
1100 print("Cannot create URL for path $file. Not in build or dart directory."); | 1100 print("Cannot create URL for path $file. Not in build or dart directory."); |
1101 exit(1); | 1101 exit(1); |
1102 } | 1102 } |
1103 | 1103 |
1104 String _getUriForBrowserTest(TestInformation info, | 1104 Uri _getUriForBrowserTest(String pathComponent, String subtestName) { |
1105 String pathComponent, | 1105 if (configuration['list']) { |
ricow1
2014/11/10 13:55:24
maybe copy over the existing comment and change th
| |
1106 subtestNames, | 1106 return Uri.parse('http://listing_the_tests_only'); |
1107 subtestIndex) { | |
1108 // Note: If we run test.py with the "--list" option, no http servers | |
1109 // will be started. So we use PORT/CROSS_ORIGIN_PORT instead of real ports. | |
1110 var serverPort = "PORT"; | |
1111 var crossOriginPort = "CROSS_ORIGIN_PORT"; | |
1112 if (!configuration['list']) { | |
1113 assert(configuration.containsKey('_servers_')); | |
1114 serverPort = configuration['_servers_'].port; | |
1115 crossOriginPort = configuration['_servers_'].crossOriginPort; | |
1116 } | 1107 } |
1117 | 1108 assert(configuration.containsKey('_servers_')); |
1118 var localIp = configuration['local_ip']; | 1109 int serverPort = configuration['_servers_'].port; |
1119 var url= 'http://$localIp:$serverPort$pathComponent' | 1110 int crossOriginPort = configuration['_servers_'].crossOriginPort; |
1120 '?crossOriginPort=$crossOriginPort'; | 1111 Map parameters = {'crossOriginPort': crossOriginPort.toString()}; |
1121 if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) { | 1112 if (subtestName != null) { |
1122 url= '${url}&group=${subtestNames[subtestIndex]}'; | 1113 parameters['group'] = subtestName; |
1123 } | 1114 } |
1124 return url; | 1115 return new Uri(scheme: 'http', |
1116 host: configuration['local_ip'], | |
1117 port: serverPort, | |
1118 path: pathComponent, | |
1119 queryParameters: parameters); | |
1125 } | 1120 } |
1126 | 1121 |
1127 void _createWrapperFile(String dartWrapperFilename, | 1122 void _createWrapperFile(String dartWrapperFilename, |
1128 Path localDartLibraryFilename) { | 1123 Path localDartLibraryFilename) { |
1129 File file = new File(dartWrapperFilename); | 1124 File file = new File(dartWrapperFilename); |
1130 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); | 1125 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); |
1131 | 1126 |
1132 var usePackageImport = localDartLibraryFilename.segments().contains("pkg"); | 1127 var usePackageImport = localDartLibraryFilename.segments().contains("pkg"); |
1133 var libraryPathComponent = _createUrlPathFromFile(localDartLibraryFilename); | 1128 var libraryPathComponent = _createUrlPathFromFile(localDartLibraryFilename); |
1134 var generatedSource = dartTestWrapper(libraryPathComponent); | 1129 var generatedSource = dartTestWrapper(libraryPathComponent); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1309 // For the tests that require multiple input scripts but are not | 1304 // For the tests that require multiple input scripts but are not |
1310 // compiled, move the input scripts over with the script so they can | 1305 // compiled, move the input scripts over with the script so they can |
1311 // be accessed. | 1306 // be accessed. |
1312 String result = new File(fromPath.toNativePath()).readAsStringSync(); | 1307 String result = new File(fromPath.toNativePath()).readAsStringSync(); |
1313 new File('$tempDir/$fileName').writeAsStringSync(result); | 1308 new File('$tempDir/$fileName').writeAsStringSync(result); |
1314 } | 1309 } |
1315 } | 1310 } |
1316 | 1311 |
1317 | 1312 |
1318 // Variables for browser multi-tests. | 1313 // Variables for browser multi-tests. |
1319 List<String> subtestNames = info.optionsFromFile['subtestNames']; | 1314 bool multitest = info.optionsFromFile['isMultiHtmlTest']; |
1320 int subtestIndex = 0; | 1315 List<String> subtestNames = |
1316 multitest ? info.optionsFromFile['subtestNames'] : [null]; | |
1317 for (String subtestName in subtestNames) { | |
1321 // Construct the command that executes the browser test | 1318 // Construct the command that executes the browser test |
1322 do { | |
1323 List<Command> commandSet = new List<Command>.from(commands); | 1319 List<Command> commandSet = new List<Command>.from(commands); |
1324 | 1320 |
1325 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); | 1321 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); |
1326 var fullHtmlPath = _getUriForBrowserTest( | 1322 var fullHtmlPath = |
1327 info, htmlPath_subtest, subtestNames, subtestIndex); | 1323 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); |
1328 | 1324 |
1329 List<String> args = <String>[]; | 1325 List<String> args = <String>[]; |
1330 | 1326 |
1331 if (runtime == "drt") { | 1327 if (runtime == "drt") { |
1332 var dartFlags = []; | 1328 var dartFlags = []; |
1333 var contentShellOptions = []; | 1329 var contentShellOptions = []; |
1334 | 1330 |
1335 contentShellOptions.add('--no-timeout'); | 1331 contentShellOptions.add('--no-timeout'); |
1336 contentShellOptions.add('--dump-render-tree'); | 1332 contentShellOptions.add('--dump-render-tree'); |
1337 | 1333 |
(...skipping 15 matching lines...) Expand all Loading... | |
1353 environmentOverrides)); | 1349 environmentOverrides)); |
1354 } else { | 1350 } else { |
1355 commandSet.add( | 1351 commandSet.add( |
1356 CommandBuilder.instance.getBrowserTestCommand( | 1352 CommandBuilder.instance.getBrowserTestCommand( |
1357 runtime, | 1353 runtime, |
1358 fullHtmlPath, | 1354 fullHtmlPath, |
1359 configuration)); | 1355 configuration)); |
1360 } | 1356 } |
1361 | 1357 |
1362 // Create BrowserTestCase and queue it. | 1358 // Create BrowserTestCase and queue it. |
1363 String testDisplayName = '$suiteName/$testName'; | 1359 var fullTestName = multitest ? '$testName/$subtestName' : testName; |
1364 var testCase; | 1360 var expectation = multitest ? expectations[fullTestName] : expectations; |
1365 if (info.optionsFromFile['isMultiHtmlTest']) { | 1361 var testCase = new BrowserTestCase( |
1366 testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}'; | 1362 '$suiteName/$fullTestName', |
1367 testCase = new BrowserTestCase( | |
1368 testDisplayName, | |
1369 commandSet, | 1363 commandSet, |
1370 configuration, | 1364 configuration, |
1371 expectations['$testName/${subtestNames[subtestIndex]}'], | 1365 expectation, |
1372 info, | 1366 info, |
1373 isNegative(info), | 1367 isNegative(info), |
1374 fullHtmlPath); | 1368 fullHtmlPath); |
1375 } else { | |
1376 testCase = new BrowserTestCase( | |
1377 testDisplayName, | |
1378 commandSet, | |
1379 configuration, | |
1380 expectations, | |
1381 info, | |
1382 isNegative(info), | |
1383 fullHtmlPath); | |
1384 } | |
1385 | 1369 |
1386 enqueueNewTestCase(testCase); | 1370 enqueueNewTestCase(testCase); |
1387 subtestIndex++; | 1371 } |
1388 } while (subtestIndex < subtestNames.length); | |
1389 } | 1372 } |
1390 | 1373 |
1391 void enqueueHtmlTest( | 1374 void enqueueHtmlTest( |
1392 HtmlTestInformation info, | 1375 HtmlTestInformation info, |
1393 String testName, | 1376 String testName, |
1394 expectations) { | 1377 expectations) { |
1395 final String compiler = configuration['compiler']; | 1378 final String compiler = configuration['compiler']; |
1396 final String runtime = configuration['runtime']; | 1379 final String runtime = configuration['runtime']; |
1397 // Html tests work only with the browser controller. | 1380 // Html tests work only with the browser controller. |
1398 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') { | 1381 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1435 // TODO(21514): Compile scripts into output directory. | 1418 // TODO(21514): Compile scripts into output directory. |
1436 Fail('HTML test scripts don\'t support dart2js yet'); | 1419 Fail('HTML test scripts don\'t support dart2js yet'); |
1437 break; | 1420 break; |
1438 } | 1421 } |
1439 } | 1422 } |
1440 } | 1423 } |
1441 final Uri htmlFile = tempUri.resolve(filePath.filename); | 1424 final Uri htmlFile = tempUri.resolve(filePath.filename); |
1442 new File.fromUri(htmlFile).writeAsStringSync(contents); | 1425 new File.fromUri(htmlFile).writeAsStringSync(contents); |
1443 | 1426 |
1444 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath())); | 1427 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath())); |
1445 var fullHtmlPath = _getUriForBrowserTest(info, htmlPath, null, null); | 1428 var fullHtmlPath = _getUriForBrowserTest(htmlPath, null).toString(); |
1446 var commands = [ | 1429 var commands = [ |
1447 CommandBuilder.instance.getBrowserHtmlTestCommand( | 1430 CommandBuilder.instance.getBrowserHtmlTestCommand( |
1448 runtime, | 1431 runtime, |
1449 fullHtmlPath, | 1432 fullHtmlPath, |
1450 configuration, | 1433 configuration, |
1451 info.expectedMessages)]; | 1434 info.expectedMessages)]; |
1452 String testDisplayName = '$suiteName/$testName'; | 1435 String testDisplayName = '$suiteName/$testName'; |
1453 var testCase = new BrowserTestCase( | 1436 var testCase = new BrowserTestCase( |
1454 testDisplayName, | 1437 testDisplayName, |
1455 commands, | 1438 commands, |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2491 * $pass tests are expected to pass | 2474 * $pass tests are expected to pass |
2492 * $failOk tests are expected to fail that we won't fix | 2475 * $failOk tests are expected to fail that we won't fix |
2493 * $fail tests are expected to fail that we should fix | 2476 * $fail tests are expected to fail that we should fix |
2494 * $crash tests are expected to crash that we should fix | 2477 * $crash tests are expected to crash that we should fix |
2495 * $timeout tests are allowed to timeout | 2478 * $timeout tests are allowed to timeout |
2496 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 2479 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
2497 """; | 2480 """; |
2498 print(report); | 2481 print(report); |
2499 } | 2482 } |
2500 } | 2483 } |
OLD | NEW |