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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 if (compilerConfiguration.hasCompiler) { | 1062 if (compilerConfiguration.hasCompiler) { |
1063 compileTimeArguments = compilerConfiguration.computeCompilerArguments( | 1063 compileTimeArguments = compilerConfiguration.computeCompilerArguments( |
1064 vmOptions, sharedOptions, args); | 1064 vmOptions, sharedOptions, args); |
1065 // Avoid doing this for analyzer. | 1065 // Avoid doing this for analyzer. |
1066 var path = info.filePath; | 1066 var path = info.filePath; |
1067 if (vmOptionsVarient != 0) { | 1067 if (vmOptionsVarient != 0) { |
1068 // Ensure a unique directory for each test case. | 1068 // Ensure a unique directory for each test case. |
1069 path = path.join(new Path(vmOptionsVarient.toString())); | 1069 path = path.join(new Path(vmOptionsVarient.toString())); |
1070 } | 1070 } |
1071 tempDir = createCompilationOutputDirectory(path); | 1071 tempDir = createCompilationOutputDirectory(path); |
| 1072 |
| 1073 List<String> otherResources = info.optionsFromFile['otherResources']; |
| 1074 for (String name in otherResources) { |
| 1075 Path namePath = new Path(name); |
| 1076 String fileName = namePath.filename; |
| 1077 Path fromPath = info.filePath.directoryPath.join(namePath); |
| 1078 new File('$tempDir/$name').parent.createSync(recursive: true); |
| 1079 new File(fromPath.toNativePath()).copySync('$tempDir/$name'); |
| 1080 } |
1072 } | 1081 } |
1073 | 1082 |
1074 CommandArtifact compilationArtifact = | 1083 CommandArtifact compilationArtifact = |
1075 compilerConfiguration.computeCompilationArtifact( | 1084 compilerConfiguration.computeCompilationArtifact( |
1076 buildDir, | 1085 buildDir, |
1077 tempDir, | 1086 tempDir, |
1078 CommandBuilder.instance, | 1087 CommandBuilder.instance, |
1079 compileTimeArguments, | 1088 compileTimeArguments, |
1080 environmentOverrides); | 1089 environmentOverrides); |
1081 commands.addAll(compilationArtifact.commands); | 1090 commands.addAll(compilationArtifact.commands); |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 * configurations, so it may not use [configuration]. | 1675 * configurations, so it may not use [configuration]. |
1667 */ | 1676 */ |
1668 Map readOptionsFromFile(Path filePath) { | 1677 Map readOptionsFromFile(Path filePath) { |
1669 if (filePath.segments().contains('co19')) { | 1678 if (filePath.segments().contains('co19')) { |
1670 return readOptionsFromCo19File(filePath); | 1679 return readOptionsFromCo19File(filePath); |
1671 } | 1680 } |
1672 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)"); | 1681 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)"); |
1673 RegExp sharedOptionsRegExp = new RegExp(r"// SharedOptions=(.*)"); | 1682 RegExp sharedOptionsRegExp = new RegExp(r"// SharedOptions=(.*)"); |
1674 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)"); | 1683 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)"); |
1675 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)"); | 1684 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)"); |
| 1685 RegExp otherResourcesRegExp = new RegExp(r"// OtherResources=(.*)"); |
1676 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)"); | 1686 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)"); |
1677 RegExp packagesRegExp = new RegExp(r"// Packages=(.*)"); | 1687 RegExp packagesRegExp = new RegExp(r"// Packages=(.*)"); |
1678 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)"); | 1688 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)"); |
1679 // TODO(gram) Clean these up once the old directives are not supported. | 1689 // TODO(gram) Clean these up once the old directives are not supported. |
1680 RegExp domImportRegExp = new RegExp( | 1690 RegExp domImportRegExp = new RegExp( |
1681 r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", | 1691 r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", |
1682 multiLine: true); | 1692 multiLine: true); |
1683 | 1693 |
1684 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); | 1694 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); |
1685 String contents = decodeUtf8(bytes); | 1695 String contents = decodeUtf8(bytes); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 packages = '${filePath.directoryPath.join(new Path(packages))}'; | 1755 packages = '${filePath.directoryPath.join(new Path(packages))}'; |
1746 } | 1756 } |
1747 } | 1757 } |
1748 | 1758 |
1749 List<String> otherScripts = new List<String>(); | 1759 List<String> otherScripts = new List<String>(); |
1750 matches = otherScriptsRegExp.allMatches(contents); | 1760 matches = otherScriptsRegExp.allMatches(contents); |
1751 for (var match in matches) { | 1761 for (var match in matches) { |
1752 otherScripts.addAll(match[1].split(' ').where((e) => e != '').toList()); | 1762 otherScripts.addAll(match[1].split(' ').where((e) => e != '').toList()); |
1753 } | 1763 } |
1754 | 1764 |
| 1765 List<String> otherResources = new List<String>(); |
| 1766 matches = otherResourcesRegExp.allMatches(contents); |
| 1767 for (var match in matches) { |
| 1768 otherResources.addAll(match[1].split(' ').where((e) => e != '').toList()); |
| 1769 } |
| 1770 |
1755 bool isMultitest = multiTestRegExp.hasMatch(contents); | 1771 bool isMultitest = multiTestRegExp.hasMatch(contents); |
1756 bool isMultiHtmlTest = multiHtmlTestRegExp.hasMatch(contents); | 1772 bool isMultiHtmlTest = multiHtmlTestRegExp.hasMatch(contents); |
1757 Match isolateMatch = isolateStubsRegExp.firstMatch(contents); | 1773 Match isolateMatch = isolateStubsRegExp.firstMatch(contents); |
1758 String isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; | 1774 String isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; |
1759 bool containsDomImport = domImportRegExp.hasMatch(contents); | 1775 bool containsDomImport = domImportRegExp.hasMatch(contents); |
1760 | 1776 |
1761 List<String> subtestNames = []; | 1777 List<String> subtestNames = []; |
1762 Iterator matchesIter = | 1778 Iterator matchesIter = |
1763 multiHtmlTestGroupRegExp.allMatches(contents).iterator; | 1779 multiHtmlTestGroupRegExp.allMatches(contents).iterator; |
1764 while (matchesIter.moveNext() && isMultiHtmlTest) { | 1780 while (matchesIter.moveNext() && isMultiHtmlTest) { |
1765 String fullMatch = matchesIter.current.group(0); | 1781 String fullMatch = matchesIter.current.group(0); |
1766 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1)); | 1782 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1)); |
1767 } | 1783 } |
1768 | 1784 |
1769 return { | 1785 return { |
1770 "vmOptions": result, | 1786 "vmOptions": result, |
1771 "sharedOptions": sharedOptions == null ? [] : sharedOptions, | 1787 "sharedOptions": sharedOptions == null ? [] : sharedOptions, |
1772 "dartOptions": dartOptions, | 1788 "dartOptions": dartOptions, |
1773 "packageRoot": packageRoot, | 1789 "packageRoot": packageRoot, |
1774 "packages": packages, | 1790 "packages": packages, |
1775 "hasCompileError": false, | 1791 "hasCompileError": false, |
1776 "hasRuntimeError": false, | 1792 "hasRuntimeError": false, |
1777 "hasStaticWarning": false, | 1793 "hasStaticWarning": false, |
1778 "otherScripts": otherScripts, | 1794 "otherScripts": otherScripts, |
| 1795 "otherResources": otherResources, |
1779 "isMultitest": isMultitest, | 1796 "isMultitest": isMultitest, |
1780 "isMultiHtmlTest": isMultiHtmlTest, | 1797 "isMultiHtmlTest": isMultiHtmlTest, |
1781 "subtestNames": subtestNames, | 1798 "subtestNames": subtestNames, |
1782 "isolateStubs": isolateStubs, | 1799 "isolateStubs": isolateStubs, |
1783 "containsDomImport": containsDomImport | 1800 "containsDomImport": containsDomImport |
1784 }; | 1801 }; |
1785 } | 1802 } |
1786 | 1803 |
1787 List<List<String>> getVmOptions(Map optionsFromFile) { | 1804 List<List<String>> getVmOptions(Map optionsFromFile) { |
1788 var COMPILERS = const ['none', 'precompiler', 'dart2app', 'dart2appjit']; | 1805 var COMPILERS = const ['none', 'precompiler', 'dart2app', 'dart2appjit']; |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2486 } | 2503 } |
2487 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { | 2504 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { |
2488 ++shortNameCounter; | 2505 ++shortNameCounter; |
2489 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); | 2506 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); |
2490 path = "short${shortNameCounter}_$pathEnd"; | 2507 path = "short${shortNameCounter}_$pathEnd"; |
2491 } | 2508 } |
2492 } | 2509 } |
2493 return path; | 2510 return path; |
2494 } | 2511 } |
2495 } | 2512 } |
OLD | NEW |