Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #library("test_suite"); | 5 #library("test_suite"); |
| 6 | 6 |
| 7 #import("status_file_parser.dart"); | 7 #import("status_file_parser.dart"); |
| 8 #import("test_runner.dart"); | 8 #import("test_runner.dart"); |
| 9 #import("multitest.dart"); | |
| 10 | |
| 9 | 11 |
| 10 interface TestSuite { | 12 interface TestSuite { |
| 11 void forEachTest(Function onTest, [Function onDone]); | 13 void forEachTest(Function onTest, [Function onDone]); |
| 12 } | 14 } |
| 13 | 15 |
| 14 | 16 |
| 15 class CCTestListerIsolate extends Isolate { | 17 class CCTestListerIsolate extends Isolate { |
| 16 CCTestListerIsolate() : super.heavy(); | 18 CCTestListerIsolate() : super.heavy(); |
| 17 | 19 |
| 18 void main() { | 20 void main() { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 if (!isTestFile(filename)) return; | 175 if (!isTestFile(filename)) return; |
| 174 | 176 |
| 175 // If patterns are given only list the files that match one of the | 177 // If patterns are given only list the files that match one of the |
| 176 // patterns. | 178 // patterns. |
| 177 var patterns = configuration['patterns']; | 179 var patterns = configuration['patterns']; |
| 178 if (!patterns.isEmpty() && | 180 if (!patterns.isEmpty() && |
| 179 !patterns.some((re) => re.hasMatch(filename))) { | 181 !patterns.some((re) => re.hasMatch(filename))) { |
| 180 return; | 182 return; |
| 181 } | 183 } |
| 182 | 184 |
| 183 int start = filename.lastIndexOf('src' + new Platform().pathSeparator()); | |
| 184 String testName = filename.substring(start + 4, filename.length - 5); | |
| 185 Set<String> expectations = testExpectations.expectations(testName); | |
| 186 | 185 |
| 187 if (expectations.contains(SKIP)) return; | 186 var timeout = configuration['timeout']; |
| 187 var optionsFromFile = optionsFromFile(filename); | |
| 188 | 188 |
| 189 var optionsFromFile = optionsFromFile(filename); | 189 Function doTestBound(filename, isNegative, isNegativeIfChecked) { |
|
Bill Hesse
2011/11/29 16:38:56
Name changed to createTestCase(). Not uploaded ye
Mads Ager (google)
2011/11/30 09:11:23
We could use a named optional argument for isNegat
Bill Hesse
2011/11/30 10:01:39
Done.
| |
| 190 var isNegative = optionsFromFile['isNegative']; | 190 // Look up expectations in status files using a modified file path. |
| 191 var argumentLists = argumentListsFromFile(filename, optionsFromFile); | 191 String pathSeparator = new Platform().pathSeparator(); |
| 192 var timeout = configuration['timeout']; | 192 String testName; |
| 193 int start = filename.lastIndexOf('src' + pathSeparator); | |
| 194 if (start != -1) { | |
| 195 testName = filename.substring(start + 4, filename.length - 5); | |
| 196 } else { | |
| 197 start = filename.lastIndexOf(pathSeparator); | |
| 198 int middle = filename.lastIndexOf('_'); | |
|
Mads Ager (google)
2011/11/30 09:11:23
This will end up biting us because it is specific
Bill Hesse
2011/11/30 10:01:39
This only applies to multitests, because all other
| |
| 199 testName = filename.substring(start + 1, middle) + pathSeparator + | |
| 200 filename.substring(middle + 1, filename.length - 5); | |
| 201 } | |
| 202 Set<String> expectations = testExpectations.expectations(testName); | |
| 193 | 203 |
| 194 for (var args in argumentLists) { | 204 if (expectations.contains(SKIP)) return; |
| 195 doTest(new TestCase(testName, | 205 |
| 196 shellPath, | 206 isNegative = isNegative || |
| 197 args, | 207 (configuration['checked'] && isNegativeIfChecked); |
| 198 timeout, | 208 var argumentLists = argumentListsFromFile(filename, optionsFromFile); |
| 199 completeHandler, | 209 for (var args in argumentLists) { |
| 200 expectations, | 210 doTest(new TestCase(testName, |
| 201 isNegative)); | 211 shellPath, |
| 212 args, | |
| 213 timeout, | |
| 214 completeHandler, | |
| 215 expectations, | |
| 216 isNegative)); | |
| 217 } | |
| 218 } | |
| 219 | |
| 220 | |
| 221 if (optionsFromFile['isMultitest']) { | |
| 222 DoMultitest(filename, doTestBound); | |
| 223 } else { | |
| 224 var isNegative = optionsFromFile['isNegative']; | |
| 225 doTestBound(filename, isNegative, false); | |
| 202 } | 226 } |
| 203 } | 227 } |
| 204 | 228 |
| 205 void completeHandler(TestCase testCase) { | 229 void completeHandler(TestCase testCase) { |
| 206 } | 230 } |
| 207 | 231 |
| 208 | 232 |
| 209 List<List<String>> argumentListsFromFile(String filename, | 233 List<List<String>> argumentListsFromFile(String filename, |
| 210 Map optionsFromFile) { | 234 Map optionsFromFile) { |
| 211 List args = TestUtils.standardOptions(configuration); | 235 List args = TestUtils.standardOptions(configuration); |
| 212 | 236 |
| 237 bool isMultitest = optionsFromFile["isMultitest"]; | |
| 213 List<String> dartOptions = optionsFromFile["dartOptions"]; | 238 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 239 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; | |
| 240 Expect.isTrue(!isMultitest || dartOptions == null); | |
| 214 args.addAll(dartOptions == null ? [filename] : dartOptions); | 241 args.addAll(dartOptions == null ? [filename] : dartOptions); |
| 215 | 242 |
| 216 var result = new List<List<String>>(); | 243 var result = new List<List<String>>(); |
| 217 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; | |
| 218 if (vmOptionsList.isEmpty()) { | 244 if (vmOptionsList.isEmpty()) { |
| 245 Expect.fail("empty vmOptionsList"); | |
|
Mads Ager (google)
2011/11/30 09:11:23
Remove this case completely and just replace with
| |
| 219 result.add(args); | 246 result.add(args); |
| 220 } else { | 247 } else { |
| 221 for (var vmOptions in vmOptionsList) { | 248 for (var vmOptions in vmOptionsList) { |
| 249 if (isMultitest) { | |
| 250 // Make copy of vmOptions, since we will modify it at each iteration. | |
| 251 vmOptions = new List<String>.from(vmOptions); | |
| 252 } | |
| 222 vmOptions.addAll(args); | 253 vmOptions.addAll(args); |
| 223 result.add(vmOptions); | 254 result.add(vmOptions); |
| 224 } | 255 } |
| 225 } | 256 } |
| 226 | 257 |
| 227 return result; | 258 return result; |
| 228 } | 259 } |
| 229 | 260 |
| 230 Map optionsFromFile(String filename) { | 261 Map optionsFromFile(String filename) { |
| 231 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); | 262 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 247 | 278 |
| 248 // Find the options in the file. | 279 // Find the options in the file. |
| 249 List<List> result = new List<List>(); | 280 List<List> result = new List<List>(); |
| 250 List<String> dartOptions; | 281 List<String> dartOptions; |
| 251 bool isNegative = false; | 282 bool isNegative = false; |
| 252 | 283 |
| 253 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); | 284 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); |
| 254 for (var match in matches) { | 285 for (var match in matches) { |
| 255 result.add(match[1].split(' ').filter((e) => e != '')); | 286 result.add(match[1].split(' ').filter((e) => e != '')); |
| 256 } | 287 } |
| 288 if (result.isEmpty()) result.add([]); | |
| 257 | 289 |
| 258 matches = dartOptionsRegExp.allMatches(contents); | 290 matches = dartOptionsRegExp.allMatches(contents); |
| 259 for (var match in matches) { | 291 for (var match in matches) { |
| 260 if (dartOptions != null) { | 292 if (dartOptions != null) { |
| 261 throw new Exception( | 293 throw new Exception( |
| 262 'More than one "// DartOptions=" line in test $filename'); | 294 'More than one "// DartOptions=" line in test $filename'); |
| 263 } | 295 } |
| 264 dartOptions = match[1].split(' ').filter((e) => e != ''); | 296 dartOptions = match[1].split(' ').filter((e) => e != ''); |
| 265 } | 297 } |
| 266 | 298 |
| 267 if (contents.contains("@compile-error") || | 299 if (contents.contains("@compile-error") || |
| 268 contents.contains("@runtime-error")) { | 300 contents.contains("@runtime-error")) { |
| 269 isNegative = true; | 301 isNegative = true; |
| 270 } else if (contents.contains("@dynamic-type-error") && | 302 } else if (contents.contains("@dynamic-type-error") && |
| 271 configuration['checked']) { | 303 configuration['checked']) { |
| 272 isNegative = true; | 304 isNegative = true; |
| 273 } | 305 } |
| 274 | 306 |
| 307 bool isMultitest = contents.contains("///"); | |
| 308 | |
| 275 return { "vmOptions": result, | 309 return { "vmOptions": result, |
| 276 "dartOptions": dartOptions, | 310 "dartOptions": dartOptions, |
| 277 "isNegative" : isNegative }; | 311 "isNegative": isNegative, |
| 312 "isMultitest": isMultitest}; | |
| 278 } | 313 } |
| 279 } | 314 } |
| 280 | 315 |
| 281 | 316 |
| 282 class TestUtils { | 317 class TestUtils { |
| 283 static String executableName(Map configuration) { | 318 static String executableName(Map configuration) { |
| 284 String postfix = | 319 String postfix = |
| 285 (new Platform().operatingSystem() == 'windows') ? '.exe' : ''; | 320 (new Platform().operatingSystem() == 'windows') ? '.exe' : ''; |
| 286 switch (configuration['component']) { | 321 switch (configuration['component']) { |
| 287 case 'vm': | 322 case 'vm': |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 args.add("--enable_leg"); | 365 args.add("--enable_leg"); |
| 331 } | 366 } |
| 332 if (configuration["component"] == "dartc") { | 367 if (configuration["component"] == "dartc") { |
| 333 if (configuration["mode"] == "release") { | 368 if (configuration["mode"] == "release") { |
| 334 args.add("--optimize"); | 369 args.add("--optimize"); |
| 335 } | 370 } |
| 336 } | 371 } |
| 337 return args; | 372 return args; |
| 338 } | 373 } |
| 339 } | 374 } |
| OLD | NEW |