| 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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 commands.add(CommandBuilder.instance.getMakeSymlinkCommand( | 949 commands.add(CommandBuilder.instance.getMakeSymlinkCommand( |
| 950 expectLink.toNativePath(), expectLinkTarget.toNativePath())); | 950 expectLink.toNativePath(), expectLinkTarget.toNativePath())); |
| 951 | 951 |
| 952 return {'commands': commands, 'package-root': newPackageRoot,}; | 952 return {'commands': commands, 'package-root': newPackageRoot,}; |
| 953 } | 953 } |
| 954 | 954 |
| 955 // If this test is inside a package, we will check if there is a | 955 // If this test is inside a package, we will check if there is a |
| 956 // pubspec.yaml file and if so, create a custom package root for it. | 956 // pubspec.yaml file and if so, create a custom package root for it. |
| 957 List<Command> baseCommands = <Command>[]; | 957 List<Command> baseCommands = <Command>[]; |
| 958 Path packageRoot; | 958 Path packageRoot; |
| 959 Path packages; |
| 959 if (configuration['use_repository_packages'] || | 960 if (configuration['use_repository_packages'] || |
| 960 configuration['use_public_packages']) { | 961 configuration['use_public_packages']) { |
| 961 Path pubspecYamlFile = _findPubspecYamlFile(filePath); | 962 Path pubspecYamlFile = _findPubspecYamlFile(filePath); |
| 962 if (pubspecYamlFile != null) { | 963 if (pubspecYamlFile != null) { |
| 963 var result = buildSpecialPackageRoot(pubspecYamlFile); | 964 var result = buildSpecialPackageRoot(pubspecYamlFile); |
| 964 baseCommands.addAll(result['commands']); | 965 baseCommands.addAll(result['commands']); |
| 965 packageRoot = result['package-root']; | 966 packageRoot = result['package-root']; |
| 966 if (optionsFromFile['packageRoot'] == null || | 967 if (optionsFromFile['packageRoot'] == null || |
| 967 optionsFromFile['packageRoot'] == "") { | 968 optionsFromFile['packageRoot'] == "") { |
| 968 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); | 969 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 988 if (info.optionsFromFile['isMultiHtmlTest']) { | 989 if (info.optionsFromFile['isMultiHtmlTest']) { |
| 989 // A browser multi-test has multiple expectations for one test file. | 990 // A browser multi-test has multiple expectations for one test file. |
| 990 // Find all the different sub-test expecations for one entire test file. | 991 // Find all the different sub-test expecations for one entire test file. |
| 991 List<String> subtestNames = info.optionsFromFile['subtestNames']; | 992 List<String> subtestNames = info.optionsFromFile['subtestNames']; |
| 992 Map<String, Set<Expectation>> multiHtmlTestExpectations = {}; | 993 Map<String, Set<Expectation>> multiHtmlTestExpectations = {}; |
| 993 for (String name in subtestNames) { | 994 for (String name in subtestNames) { |
| 994 String fullTestName = '$testName/$name'; | 995 String fullTestName = '$testName/$name'; |
| 995 multiHtmlTestExpectations[fullTestName] = | 996 multiHtmlTestExpectations[fullTestName] = |
| 996 testExpectations.expectations(fullTestName); | 997 testExpectations.expectations(fullTestName); |
| 997 } | 998 } |
| 998 enqueueBrowserTest(baseCommands, packageRoot, info, testName, | 999 enqueueBrowserTest(baseCommands, packageRoot, packages, info, testName, |
| 999 multiHtmlTestExpectations); | 1000 multiHtmlTestExpectations); |
| 1000 } else { | 1001 } else { |
| 1001 enqueueBrowserTest( | 1002 enqueueBrowserTest( |
| 1002 baseCommands, packageRoot, info, testName, expectations); | 1003 baseCommands, packageRoot, packages, info, testName, expectations); |
| 1003 } | 1004 } |
| 1004 } else { | 1005 } else { |
| 1005 enqueueStandardTest(baseCommands, info, testName, expectations); | 1006 enqueueStandardTest(baseCommands, info, testName, expectations); |
| 1006 } | 1007 } |
| 1007 } | 1008 } |
| 1008 | 1009 |
| 1009 void enqueueStandardTest(List<Command> baseCommands, TestInformation info, | 1010 void enqueueStandardTest(List<Command> baseCommands, TestInformation info, |
| 1010 String testName, Set<Expectation> expectations) { | 1011 String testName, Set<Expectation> expectations) { |
| 1011 var commonArguments = | 1012 var commonArguments = |
| 1012 commonArgumentsFromFile(info.filePath, info.optionsFromFile); | 1013 commonArgumentsFromFile(info.filePath, info.optionsFromFile); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 * JavaScript version of the test, and copies the appropriate framework | 1194 * JavaScript version of the test, and copies the appropriate framework |
| 1194 * files to that directory. It creates a [BrowserTestCase], which has | 1195 * files to that directory. It creates a [BrowserTestCase], which has |
| 1195 * two sequential steps to be run by the [ProcessQueue] when the test is | 1196 * two sequential steps to be run by the [ProcessQueue] when the test is |
| 1196 * executed: a compilation step and an execution step, both with the | 1197 * executed: a compilation step and an execution step, both with the |
| 1197 * appropriate executable and arguments. The [expectations] object can be | 1198 * appropriate executable and arguments. The [expectations] object can be |
| 1198 * either a Set<String> if the test is a regular test, or a Map<String | 1199 * either a Set<String> if the test is a regular test, or a Map<String |
| 1199 * subTestName, Set<String>> if we are running a browser multi-test (one | 1200 * subTestName, Set<String>> if we are running a browser multi-test (one |
| 1200 * compilation and many browser runs). | 1201 * compilation and many browser runs). |
| 1201 */ | 1202 */ |
| 1202 void enqueueBrowserTest(List<Command> baseCommands, Path packageRoot, | 1203 void enqueueBrowserTest(List<Command> baseCommands, Path packageRoot, |
| 1203 TestInformation info, String testName, expectations) { | 1204 Path packages, TestInformation info, String testName, expectations) { |
| 1204 RegExp badChars = new RegExp('[-=/]'); | 1205 RegExp badChars = new RegExp('[-=/]'); |
| 1205 List VmOptionsList = getVmOptions(info.optionsFromFile); | 1206 List VmOptionsList = getVmOptions(info.optionsFromFile); |
| 1206 bool multipleOptions = VmOptionsList.length > 1; | 1207 bool multipleOptions = VmOptionsList.length > 1; |
| 1207 for (var vmOptions in VmOptionsList) { | 1208 for (var vmOptions in VmOptionsList) { |
| 1208 String optionsName = | 1209 String optionsName = |
| 1209 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : ''; | 1210 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : ''; |
| 1210 String tempDir = createOutputDirectory(info.filePath, optionsName); | 1211 String tempDir = createOutputDirectory(info.filePath, optionsName); |
| 1211 enqueueBrowserTestWithOptions(baseCommands, packageRoot, info, testName, | 1212 enqueueBrowserTestWithOptions(baseCommands, packageRoot, packages, |
| 1212 expectations, vmOptions, tempDir); | 1213 info, testName, expectations, vmOptions, tempDir); |
| 1213 } | 1214 } |
| 1214 } | 1215 } |
| 1215 | 1216 |
| 1216 void enqueueBrowserTestWithOptions( | 1217 void enqueueBrowserTestWithOptions( |
| 1217 List<Command> baseCommands, | 1218 List<Command> baseCommands, |
| 1218 Path packageRoot, | 1219 Path packageRoot, |
| 1220 Path packages, |
| 1219 TestInformation info, | 1221 TestInformation info, |
| 1220 String testName, | 1222 String testName, |
| 1221 expectations, | 1223 expectations, |
| 1222 List<String> vmOptions, | 1224 List<String> vmOptions, |
| 1223 String tempDir) { | 1225 String tempDir) { |
| 1224 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] | 1226 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] |
| 1225 // on to the browser (it may be test specific). | 1227 // on to the browser (it may be test specific). |
| 1226 | 1228 |
| 1227 Path filePath = info.filePath; | 1229 Path filePath = info.filePath; |
| 1228 String filename = filePath.toString(); | 1230 String filename = filePath.toString(); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 if (dartOptions != null) { | 1579 if (dartOptions != null) { |
| 1578 args.addAll(dartOptions); | 1580 args.addAll(dartOptions); |
| 1579 } | 1581 } |
| 1580 | 1582 |
| 1581 return args; | 1583 return args; |
| 1582 } | 1584 } |
| 1583 | 1585 |
| 1584 String packagesArgument(String packageRootFromFile, | 1586 String packagesArgument(String packageRootFromFile, |
| 1585 String packagesFromFile) { | 1587 String packagesFromFile) { |
| 1586 if (packagesFromFile != null) { | 1588 if (packagesFromFile != null) { |
| 1587 return "--packages=$packagesFromFile"; | 1589 return '--packages=$packagesFromFile'; |
| 1590 } else if (packageRootFromFile != null && packageRootFromFile != 'none') { |
| 1591 return '--package-root=$packageRootFromFile'; |
| 1592 } else { |
| 1593 return null; |
| 1588 } | 1594 } |
| 1589 if (packageRootFromFile == "none") { | |
| 1590 return null; | |
| 1591 } | |
| 1592 packageRootFromFile ??= "$buildDir/packages/"; | |
| 1593 return "--package-root=$packageRootFromFile"; | |
| 1594 } | 1595 } |
| 1595 | 1596 |
| 1596 /** | 1597 /** |
| 1597 * Special options for individual tests are currently specified in various | 1598 * Special options for individual tests are currently specified in various |
| 1598 * ways: with comments directly in test files, by using certain imports, or by | 1599 * ways: with comments directly in test files, by using certain imports, or by |
| 1599 * creating additional files in the test directories. | 1600 * creating additional files in the test directories. |
| 1600 * | 1601 * |
| 1601 * Here is a list of options that are used by 'test.dart' today: | 1602 * Here is a list of options that are used by 'test.dart' today: |
| 1602 * - Flags can be passed to the vm or dartium process that runs the test by | 1603 * - Flags can be passed to the vm or dartium process that runs the test by |
| 1603 * adding a comment to the test file: | 1604 * adding a comment to the test file: |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 /// Used for testing packages in on off settings, i.e., we pass in the actual | 1837 /// Used for testing packages in on off settings, i.e., we pass in the actual |
| 1837 /// directory that we want to test. | 1838 /// directory that we want to test. |
| 1838 class PKGTestSuite extends StandardTestSuite { | 1839 class PKGTestSuite extends StandardTestSuite { |
| 1839 PKGTestSuite(Map configuration, Path directoryPath) | 1840 PKGTestSuite(Map configuration, Path directoryPath) |
| 1840 : super(configuration, directoryPath.filename, directoryPath, | 1841 : super(configuration, directoryPath.filename, directoryPath, |
| 1841 ["$directoryPath/.status"], | 1842 ["$directoryPath/.status"], |
| 1842 isTestFilePredicate: (f) => f.endsWith('_test.dart'), | 1843 isTestFilePredicate: (f) => f.endsWith('_test.dart'), |
| 1843 recursive: true); | 1844 recursive: true); |
| 1844 | 1845 |
| 1845 void enqueueBrowserTest(List<Command> baseCommands, Path packageRoot, | 1846 void enqueueBrowserTest(List<Command> baseCommands, Path packageRoot, |
| 1846 TestInformation info, String testName, expectations) { | 1847 packages, TestInformation info, String testName, expectations) { |
| 1847 String runtime = configuration['runtime']; | 1848 String runtime = configuration['runtime']; |
| 1848 Path filePath = info.filePath; | 1849 Path filePath = info.filePath; |
| 1849 Path dir = filePath.directoryPath; | 1850 Path dir = filePath.directoryPath; |
| 1850 String nameNoExt = filePath.filenameWithoutExtension; | 1851 String nameNoExt = filePath.filenameWithoutExtension; |
| 1851 Path customHtmlPath = dir.append('$nameNoExt.html'); | 1852 Path customHtmlPath = dir.append('$nameNoExt.html'); |
| 1852 File customHtml = new File(customHtmlPath.toNativePath()); | 1853 File customHtml = new File(customHtmlPath.toNativePath()); |
| 1853 if (!customHtml.existsSync()) { | 1854 if (!customHtml.existsSync()) { |
| 1854 super.enqueueBrowserTest( | 1855 super.enqueueBrowserTest( |
| 1855 baseCommands, packageRoot, info, testName, expectations); | 1856 baseCommands, packageRoot, packages, info, testName, expectations); |
| 1856 } else { | 1857 } else { |
| 1857 Path relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); | 1858 Path relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); |
| 1858 List<Command> commands = []..addAll(baseCommands); | 1859 List<Command> commands = []..addAll(baseCommands); |
| 1859 var fullPath = _createUrlPathFromFile(customHtmlPath); | 1860 var fullPath = _createUrlPathFromFile(customHtmlPath); |
| 1860 | 1861 |
| 1861 commands.add(CommandBuilder.instance.getBrowserTestCommand( | 1862 commands.add(CommandBuilder.instance.getBrowserTestCommand( |
| 1862 runtime, fullPath, configuration, !isNegative(info))); | 1863 runtime, fullPath, configuration, !isNegative(info))); |
| 1863 String testDisplayName = '$suiteName/$testName'; | 1864 String testDisplayName = '$suiteName/$testName'; |
| 1864 enqueueNewTestCase(new BrowserTestCase( | 1865 enqueueNewTestCase(new BrowserTestCase( |
| 1865 testDisplayName, | 1866 testDisplayName, |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2475 } | 2476 } |
| 2476 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { | 2477 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { |
| 2477 ++shortNameCounter; | 2478 ++shortNameCounter; |
| 2478 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); | 2479 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); |
| 2479 path = "short${shortNameCounter}_$pathEnd"; | 2480 path = "short${shortNameCounter}_$pathEnd"; |
| 2480 } | 2481 } |
| 2481 } | 2482 } |
| 2482 return path; | 2483 return path; |
| 2483 } | 2484 } |
| 2484 } | 2485 } |
| OLD | NEW |