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

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

Issue 11359187: Allow tests to specify a package root. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
« dart/tests/html/url_test.dart ('K') | « dart/tools/make_links.py ('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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 */ 98 */
99 abstract class TestSuite { 99 abstract class TestSuite {
100 final Map configuration; 100 final Map configuration;
101 final String suiteName; 101 final String suiteName;
102 102
103 TestSuite(this.configuration, this.suiteName); 103 TestSuite(this.configuration, this.suiteName);
104 104
105 /** 105 /**
106 * The output directory for this suite's configuration. 106 * The output directory for this suite's configuration.
107 */ 107 */
108 String get buildDir { 108 String get buildDir => TestUtils.buildDir(configuration);
109 var mode = (configuration['mode'] == 'debug') ? 'Debug' : 'Release';
110 var arch = configuration['arch'].toUpperCase();
111 return "${TestUtils.outputDir(configuration)}$mode$arch";
112 }
113 109
114 /** 110 /**
115 * The path to the compiler for this suite's configuration. Returns `null` if 111 * The path to the compiler for this suite's configuration. Returns `null` if
116 * no compiler should be used. 112 * no compiler should be used.
117 */ 113 */
118 String get compilerPath { 114 String get compilerPath {
119 if (configuration['compiler'] == 'none') { 115 if (configuration['compiler'] == 'none') {
120 return null; // No separate compiler for dartium tests. 116 return null; // No separate compiler for dartium tests.
121 } 117 }
122 var name = '$buildDir/${compilerName}'; 118 var name = '$buildDir/${compilerName}';
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 args.add('--executable=$dartiumFilename'); 922 args.add('--executable=$dartiumFilename');
927 } 923 }
928 } else { 924 } else {
929 args = [ 925 args = [
930 dartDir.append('tools/testing/drt-trampoline.py').toNativePath(), 926 dartDir.append('tools/testing/drt-trampoline.py').toNativePath(),
931 dumpRenderTreeFilename, 927 dumpRenderTreeFilename,
932 '--no-timeout' 928 '--no-timeout'
933 ]; 929 ];
934 if (runtime == 'drt' && 930 if (runtime == 'drt' &&
935 (compiler == 'none' || compiler == 'dart2dart')) { 931 (compiler == 'none' || compiler == 'dart2dart')) {
936 var dartFlags = ['--ignore-unrecognized-flags']; 932 // TODO(ahe): DO NOT SUBMIT, DumpRenderTree hangs on package: import s.
ahe 2012/11/16 07:29:09 I have since learned that I should use an environm
933 var dartFlags = ['--ignore-unrecognized-flags', '--package-root=$bui ldDir/packages/'];
937 if (configuration["checked"]) { 934 if (configuration["checked"]) {
938 dartFlags.add('--enable_asserts'); 935 dartFlags.add('--enable_asserts');
939 dartFlags.add("--enable_type_checks"); 936 dartFlags.add("--enable_type_checks");
940 } 937 }
941 dartFlags.addAll(vmOptions); 938 dartFlags.addAll(vmOptions);
942 args.add('--dart-flags=${Strings.join(dartFlags, " ")}'); 939 args.add('--dart-flags=${Strings.join(dartFlags, " ")}');
943 } 940 }
944 args.add(fullHtmlPath); 941 args.add(fullHtmlPath);
945 if (expectedOutput != null) { 942 if (expectedOutput != null) {
946 args.add('--out-expectation=${expectedOutput.toNativePath()}'); 943 args.add('--out-expectation=${expectedOutput.toNativePath()}');
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 'MacOS/Chromium').toNativePath(); 1086 'MacOS/Chromium').toNativePath();
1090 } 1087 }
1091 return dartDir.append('client/tests/dartium/chrome').toNativePath(); 1088 return dartDir.append('client/tests/dartium/chrome').toNativePath();
1092 } 1089 }
1093 1090
1094 void completeHandler(TestCase testCase) { 1091 void completeHandler(TestCase testCase) {
1095 } 1092 }
1096 1093
1097 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { 1094 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) {
1098 List args = TestUtils.standardOptions(configuration); 1095 List args = TestUtils.standardOptions(configuration);
1096
1097 String packageRoot = optionsFromFile['packageRoot'];
1098 if (packageRoot == null) {
1099 packageRoot = "$buildDir/packages/";
1100 } else if (packageRoot == "none") {
1101 // Do not pass --packageRoot option.
1102 packageRoot = null;
1103 }
1104 if (packageRoot != null) {
1105 args.add("--package-root=$packageRoot");
1106 }
1107
1099 args.addAll(additionalOptions(filePath)); 1108 args.addAll(additionalOptions(filePath));
1100 if (configuration['compiler'] == 'dartc') { 1109 if (configuration['compiler'] == 'dartc') {
1101 args.add('--error_format'); 1110 args.add('--error_format');
1102 args.add('machine'); 1111 args.add('machine');
1103 } 1112 }
1104 1113
1105 bool isMultitest = optionsFromFile["isMultitest"]; 1114 bool isMultitest = optionsFromFile["isMultitest"];
1106 List<String> dartOptions = optionsFromFile["dartOptions"]; 1115 List<String> dartOptions = optionsFromFile["dartOptions"];
1107 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile); 1116 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile);
1108 Expect.isTrue(!isMultitest || dartOptions == null); 1117 Expect.isTrue(!isMultitest || dartOptions == null);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 * with the right name (touch test_name_test.png), running the test, and 1185 * with the right name (touch test_name_test.png), running the test, and
1177 * executing the copy command printed by the test script. 1186 * executing the copy command printed by the test script.
1178 * 1187 *
1179 * This method is static as the map is cached and shared amongst 1188 * This method is static as the map is cached and shared amongst
1180 * configurations, so it may not use [configuration]. 1189 * configurations, so it may not use [configuration].
1181 */ 1190 */
1182 static Map readOptionsFromFile(Path filePath) { 1191 static Map readOptionsFromFile(Path filePath) {
1183 RegExp testOptionsRegExp = const RegExp(r"// VMOptions=(.*)"); 1192 RegExp testOptionsRegExp = const RegExp(r"// VMOptions=(.*)");
1184 RegExp dartOptionsRegExp = const RegExp(r"// DartOptions=(.*)"); 1193 RegExp dartOptionsRegExp = const RegExp(r"// DartOptions=(.*)");
1185 RegExp otherScriptsRegExp = const RegExp(r"// OtherScripts=(.*)"); 1194 RegExp otherScriptsRegExp = const RegExp(r"// OtherScripts=(.*)");
1195 RegExp packageRootRegExp = const RegExp(r"// PackageRoot=(.*)");
1186 RegExp multiTestRegExp = const RegExp(r"/// [0-9][0-9]:(.*)"); 1196 RegExp multiTestRegExp = const RegExp(r"/// [0-9][0-9]:(.*)");
1187 RegExp multiHtmlTestRegExp = 1197 RegExp multiHtmlTestRegExp =
1188 const RegExp(r"useHtmlIndividualConfiguration()"); 1198 const RegExp(r"useHtmlIndividualConfiguration()");
1189 RegExp staticTypeRegExp = 1199 RegExp staticTypeRegExp =
1190 const RegExp(r"/// ([0-9][0-9]:){0,1}\s*static type warning"); 1200 const RegExp(r"/// ([0-9][0-9]:){0,1}\s*static type warning");
1191 RegExp compileTimeRegExp = 1201 RegExp compileTimeRegExp =
1192 const RegExp(r"/// ([0-9][0-9]:){0,1}\s*compile-time error"); 1202 const RegExp(r"/// ([0-9][0-9]:){0,1}\s*compile-time error");
1193 RegExp staticCleanRegExp = const RegExp(r"// @static-clean"); 1203 RegExp staticCleanRegExp = const RegExp(r"// @static-clean");
1194 RegExp leadingHashRegExp = const RegExp(r"^#", multiLine: true); 1204 RegExp leadingHashRegExp = const RegExp(r"^#", multiLine: true);
1195 RegExp isolateStubsRegExp = const RegExp(r"// IsolateStubs=(.*)"); 1205 RegExp isolateStubsRegExp = const RegExp(r"// IsolateStubs=(.*)");
(...skipping 14 matching lines...) Expand all
1210 while (offset != chars.length) { 1220 while (offset != chars.length) {
1211 offset += file.readListSync(chars, offset, chars.length - offset); 1221 offset += file.readListSync(chars, offset, chars.length - offset);
1212 } 1222 }
1213 file.closeSync(); 1223 file.closeSync();
1214 String contents = new String.fromCharCodes(chars); 1224 String contents = new String.fromCharCodes(chars);
1215 chars = null; 1225 chars = null;
1216 1226
1217 // Find the options in the file. 1227 // Find the options in the file.
1218 List<List> result = new List<List>(); 1228 List<List> result = new List<List>();
1219 List<String> dartOptions; 1229 List<String> dartOptions;
1230 String packageRoot;
1220 bool hasCompileError = contents.contains("@compile-error"); 1231 bool hasCompileError = contents.contains("@compile-error");
1221 bool hasRuntimeError = contents.contains("@runtime-error"); 1232 bool hasRuntimeError = contents.contains("@runtime-error");
1222 bool isStaticClean = false; 1233 bool isStaticClean = false;
1223 1234
1224 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); 1235 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
1225 for (var match in matches) { 1236 for (var match in matches) {
1226 result.add(match[1].split(' ').filter((e) => e != '')); 1237 result.add(match[1].split(' ').filter((e) => e != ''));
1227 } 1238 }
1228 if (result.isEmpty) result.add([]); 1239 if (result.isEmpty) result.add([]);
1229 1240
1230 matches = dartOptionsRegExp.allMatches(contents); 1241 matches = dartOptionsRegExp.allMatches(contents);
1231 for (var match in matches) { 1242 for (var match in matches) {
1232 if (dartOptions != null) { 1243 if (dartOptions != null) {
1233 throw new Exception( 1244 throw new Exception(
1234 'More than one "// DartOptions=" line in test $filePath'); 1245 'More than one "// DartOptions=" line in test $filePath');
1235 } 1246 }
1236 dartOptions = match[1].split(' ').filter((e) => e != ''); 1247 dartOptions = match[1].split(' ').filter((e) => e != '');
1237 } 1248 }
1238 1249
1250 matches = packageRootRegExp.allMatches(contents);
1251 for (var match in matches) {
1252 if (packageRoot != null) {
1253 throw new Exception(
1254 'More than one "// PackageRoot=" line in test $filePath');
1255 }
1256 packageRoot = match[1];
1257 }
1258
1239 matches = staticCleanRegExp.allMatches(contents); 1259 matches = staticCleanRegExp.allMatches(contents);
1240 for (var match in matches) { 1260 for (var match in matches) {
1241 if (isStaticClean) { 1261 if (isStaticClean) {
1242 throw new Exception( 1262 throw new Exception(
1243 'More than one "// @static-clean=" line in test $filePath'); 1263 'More than one "// @static-clean=" line in test $filePath');
1244 } 1264 }
1245 isStaticClean = true; 1265 isStaticClean = true;
1246 } 1266 }
1247 1267
1248 List<String> otherScripts = new List<String>(); 1268 List<String> otherScripts = new List<String>();
(...skipping 28 matching lines...) Expand all
1277 RegExp numTests = new RegExp(r"\s*[^/]\s*group\('[^,']*"); 1297 RegExp numTests = new RegExp(r"\s*[^/]\s*group\('[^,']*");
1278 List<String> subtestNames = []; 1298 List<String> subtestNames = [];
1279 Iterator matchesIter = numTests.allMatches(contents).iterator(); 1299 Iterator matchesIter = numTests.allMatches(contents).iterator();
1280 while(matchesIter.hasNext && isMultiHtmlTest) { 1300 while(matchesIter.hasNext && isMultiHtmlTest) {
1281 String fullMatch = matchesIter.next().group(0); 1301 String fullMatch = matchesIter.next().group(0);
1282 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1)); 1302 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1));
1283 } 1303 }
1284 1304
1285 return { "vmOptions": result, 1305 return { "vmOptions": result,
1286 "dartOptions": dartOptions, 1306 "dartOptions": dartOptions,
1307 "packageRoot": packageRoot,
1287 "hasCompileError": hasCompileError, 1308 "hasCompileError": hasCompileError,
1288 "hasRuntimeError": hasRuntimeError, 1309 "hasRuntimeError": hasRuntimeError,
1289 "isStaticClean" : isStaticClean, 1310 "isStaticClean" : isStaticClean,
1290 "otherScripts": otherScripts, 1311 "otherScripts": otherScripts,
1291 "isMultitest": isMultitest, 1312 "isMultitest": isMultitest,
1292 "isMultiHtmlTest": isMultiHtmlTest, 1313 "isMultiHtmlTest": isMultiHtmlTest,
1293 "subtestNames": subtestNames, 1314 "subtestNames": subtestNames,
1294 "containsLeadingHash": containsLeadingHash, 1315 "containsLeadingHash": containsLeadingHash,
1295 "isolateStubs": isolateStubs, 1316 "isolateStubs": isolateStubs,
1296 "containsDomImport": containsDomImport, 1317 "containsDomImport": containsDomImport,
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 ]; 1592 ];
1572 return BROWSERS.contains(runtime); 1593 return BROWSERS.contains(runtime);
1573 } 1594 }
1574 1595
1575 static bool isBrowserRuntime(String runtime) => 1596 static bool isBrowserRuntime(String runtime) =>
1576 runtime == 'drt' || TestUtils.usesWebDriver(runtime); 1597 runtime == 'drt' || TestUtils.usesWebDriver(runtime);
1577 1598
1578 static bool isJsCommandLineRuntime(String runtime) => 1599 static bool isJsCommandLineRuntime(String runtime) =>
1579 const ['d8', 'jsshell'].contains(runtime); 1600 const ['d8', 'jsshell'].contains(runtime);
1580 1601
1602 static String buildDir(Map configuration) {
1603 var mode = (configuration['mode'] == 'debug') ? 'Debug' : 'Release';
1604 var arch = configuration['arch'].toUpperCase();
1605 return "${TestUtils.outputDir(configuration)}$mode$arch";
1606 }
1581 } 1607 }
1582 1608
1583 class SummaryReport { 1609 class SummaryReport {
1584 static int total = 0; 1610 static int total = 0;
1585 static int skipped = 0; 1611 static int skipped = 0;
1586 static int noCrash = 0; 1612 static int noCrash = 0;
1587 static int pass = 0; 1613 static int pass = 0;
1588 static int failOk = 0; 1614 static int failOk = 0;
1589 static int fail = 0; 1615 static int fail = 0;
1590 static int crash = 0; 1616 static int crash = 0;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 * $pass tests are expected to pass 1657 * $pass tests are expected to pass
1632 * $failOk tests are expected to fail that we won't fix 1658 * $failOk tests are expected to fail that we won't fix
1633 * $fail tests are expected to fail that we should fix 1659 * $fail tests are expected to fail that we should fix
1634 * $crash tests are expected to crash that we should fix 1660 * $crash tests are expected to crash that we should fix
1635 * $timeout tests are allowed to timeout 1661 * $timeout tests are allowed to timeout
1636 * $compileErrorSkip tests are skipped on browsers due to compile-time error 1662 * $compileErrorSkip tests are skipped on browsers due to compile-time error
1637 """; 1663 """;
1638 print(report); 1664 print(report);
1639 } 1665 }
1640 } 1666 }
OLDNEW
« dart/tests/html/url_test.dart ('K') | « dart/tools/make_links.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698