| 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"); | 9 #import("multitest.dart"); |
| 10 | 10 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 124 } |
| 125 | 125 |
| 126 | 126 |
| 127 class StandardTestSuite implements TestSuite { | 127 class StandardTestSuite implements TestSuite { |
| 128 Map configuration; | 128 Map configuration; |
| 129 String suiteName; | 129 String suiteName; |
| 130 String directoryPath; | 130 String directoryPath; |
| 131 List<String> statusFilePaths; | 131 List<String> statusFilePaths; |
| 132 Function doTest; | 132 Function doTest; |
| 133 Function doDone; | 133 Function doDone; |
| 134 int activeMultitests = 0; | 134 int activeTestGenerators = 0; |
| 135 bool listingDone = false; | 135 bool listingDone = false; |
| 136 TestExpectations testExpectations; | 136 TestExpectations testExpectations; |
| 137 | 137 |
| 138 StandardTestSuite(Map this.configuration, | 138 StandardTestSuite(Map this.configuration, |
| 139 String this.suiteName, | 139 String this.suiteName, |
| 140 String this.directoryPath, | 140 String this.directoryPath, |
| 141 List<String> this.statusFilePaths); | 141 List<String> this.statusFilePaths); |
| 142 | 142 |
| 143 void isTestFile(String filename) => filename.endsWith("Test.dart"); | 143 void isTestFile(String filename) => filename.endsWith("Test.dart"); |
| 144 | 144 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 170 directoryPath = getDirname(directoryPath); | 170 directoryPath = getDirname(directoryPath); |
| 171 Directory dir = new Directory(directoryPath); | 171 Directory dir = new Directory(directoryPath); |
| 172 dir.errorHandler = (s) { | 172 dir.errorHandler = (s) { |
| 173 throw s; | 173 throw s; |
| 174 }; | 174 }; |
| 175 dir.fileHandler = processFile; | 175 dir.fileHandler = processFile; |
| 176 dir.doneHandler = directoryListingDone; | 176 dir.doneHandler = directoryListingDone; |
| 177 dir.list(recursive: listRecursively()); | 177 dir.list(recursive: listRecursively()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void processFile(String filename) { | 180 Function makeTestCaseCreator(Map optionsFromFile, int timeout) { |
| 181 if (!isTestFile(filename)) return; | 181 return (String filename, |
| 182 | 182 bool isNegative, |
| 183 // Only run the tests that match the pattern. | 183 [bool isNegativeIfChecked = false, |
| 184 RegExp pattern = configuration['selectors'][suiteName]; | 184 bool enableFatalTypeErrors = false]) { |
| 185 if (!pattern.hasMatch(filename)) return; | |
| 186 | |
| 187 var timeout = configuration['timeout']; | |
| 188 var optionsFromFile = optionsFromFile(filename); | |
| 189 | |
| 190 Function createTestCase(String filename, | |
| 191 bool isNegative, | |
| 192 [bool isNegativeIfChecked = false, | |
| 193 bool enableFatalTypeErrors = false]) { | |
| 194 // Look up expectations in status files using a modified file path. | 185 // Look up expectations in status files using a modified file path. |
| 195 String pathSeparator = new Platform().pathSeparator(); | 186 String pathSeparator = new Platform().pathSeparator(); |
| 196 String testName; | 187 String testName; |
| 197 int start = filename.lastIndexOf('src' + pathSeparator); | 188 int start = filename.lastIndexOf('src' + pathSeparator); |
| 198 if (start != -1) { | 189 if (start != -1) { |
| 199 testName = filename.substring(start + 4, filename.length - 5); | 190 testName = filename.substring(start + 4, filename.length - 5); |
| 200 } else if (optionsFromFile['isMultitest']) { | 191 } else if (optionsFromFile['isMultitest']) { |
| 201 start = filename.lastIndexOf(pathSeparator); | 192 start = filename.lastIndexOf(pathSeparator); |
| 202 int middle = filename.lastIndexOf('_'); | 193 int middle = filename.lastIndexOf('_'); |
| 203 testName = filename.substring(start + 1, middle) + pathSeparator + | 194 testName = filename.substring(start + 1, middle) + pathSeparator + |
| (...skipping 24 matching lines...) Expand all Loading... |
| 228 enableFatalTypeErrors); | 219 enableFatalTypeErrors); |
| 229 for (var args in argumentLists) { | 220 for (var args in argumentLists) { |
| 230 doTest(new TestCase(testName, | 221 doTest(new TestCase(testName, |
| 231 shellPath(), | 222 shellPath(), |
| 232 args, | 223 args, |
| 233 timeout, | 224 timeout, |
| 234 completeHandler, | 225 completeHandler, |
| 235 expectations, | 226 expectations, |
| 236 isNegative)); | 227 isNegative)); |
| 237 } | 228 } |
| 238 } | 229 }; |
| 230 } |
| 231 |
| 232 void processFile(String filename) { |
| 233 if (!isTestFile(filename)) return; |
| 234 |
| 235 // Only run the tests that match the pattern. |
| 236 RegExp pattern = configuration['selectors'][suiteName]; |
| 237 if (!pattern.hasMatch(filename)) return; |
| 238 |
| 239 var optionsFromFile = optionsFromFile(filename); |
| 240 var timeout = configuration['timeout']; |
| 241 Function createTestCase = makeTestCaseCreator(optionsFromFile, timeout); |
| 239 | 242 |
| 240 if (optionsFromFile['isMultitest']) { | 243 if (optionsFromFile['isMultitest']) { |
| 241 bool supportsFatalTypeErrors = (configuration['component'] == 'dartc'); | 244 bool supportsFatalTypeErrors = (configuration['component'] == 'dartc'); |
| 242 ++activeMultitests; | 245 ++activeTestGenerators; |
| 243 DoMultitest(filename, | 246 DoMultitest(filename, |
| 244 TestUtils.buildDir(configuration), | 247 TestUtils.buildDir(configuration), |
| 245 directoryPath, | 248 directoryPath, |
| 246 supportsFatalTypeErrors, | 249 supportsFatalTypeErrors, |
| 247 createTestCase, | 250 createTestCase, |
| 248 multitestDone); | 251 testGeneratorDone); |
| 249 } else { | 252 } else { |
| 250 createTestCase(filename, optionsFromFile['isNegative']); | 253 createTestCase(filename, optionsFromFile['isNegative']); |
| 251 } | 254 } |
| 252 } | 255 } |
| 253 | 256 |
| 254 void multitestDone() { | 257 void testGeneratorDone() { |
| 255 --activeMultitests; | 258 --activeTestGenerators; |
| 256 if (activeMultitests == 0 && listingDone) { | 259 if (activeTestGenerators == 0 && listingDone) { |
| 257 doDone(); | 260 doDone(); |
| 258 } | 261 } |
| 259 } | 262 } |
| 260 | 263 |
| 261 void directoryListingDone(ignore) { | 264 void directoryListingDone(ignore) { |
| 262 listingDone = true; | 265 listingDone = true; |
| 263 if (activeMultitests == 0) { | 266 if (activeTestGenerators == 0) { |
| 264 doDone(); | 267 doDone(); |
| 265 } | 268 } |
| 266 } | 269 } |
| 267 | 270 |
| 268 void completeHandler(TestCase testCase) { | 271 void completeHandler(TestCase testCase) { |
| 269 } | 272 } |
| 270 | 273 |
| 271 List<List<String>> argumentListsFromFile(String filename, | 274 List<List<String>> argumentListsFromFile(String filename, |
| 272 Map optionsFromFile, | 275 Map optionsFromFile, |
| 273 bool enableFatalTypeErrors) { | 276 bool enableFatalTypeErrors) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } | 308 } |
| 306 | 309 |
| 307 return result; | 310 return result; |
| 308 } | 311 } |
| 309 | 312 |
| 310 Map optionsFromFile(String filename) { | 313 Map optionsFromFile(String filename) { |
| 311 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); | 314 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); |
| 312 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); | 315 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); |
| 313 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)"); | 316 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)"); |
| 314 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true); | 317 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true); |
| 318 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)"); |
| 315 | 319 |
| 316 // Read the entire file into a byte buffer and transform it to a | 320 // Read the entire file into a byte buffer and transform it to a |
| 317 // String. This will treat the file as ascii but the only parts | 321 // String. This will treat the file as ascii but the only parts |
| 318 // we are interested in will be ascii in any case. | 322 // we are interested in will be ascii in any case. |
| 319 File file = new File(filename); | 323 File file = new File(filename); |
| 320 file.openSync(); | 324 file.openSync(); |
| 321 List chars = new List(file.lengthSync()); | 325 List chars = new List(file.lengthSync()); |
| 322 var offset = 0; | 326 var offset = 0; |
| 323 while (offset != chars.length) { | 327 while (offset != chars.length) { |
| 324 offset += file.readListSync(chars, offset, chars.length - offset); | 328 offset += file.readListSync(chars, offset, chars.length - offset); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 350 if (contents.contains("@compile-error") || | 354 if (contents.contains("@compile-error") || |
| 351 contents.contains("@runtime-error")) { | 355 contents.contains("@runtime-error")) { |
| 352 isNegative = true; | 356 isNegative = true; |
| 353 } else if (contents.contains("@dynamic-type-error") && | 357 } else if (contents.contains("@dynamic-type-error") && |
| 354 configuration['checked']) { | 358 configuration['checked']) { |
| 355 isNegative = true; | 359 isNegative = true; |
| 356 } | 360 } |
| 357 | 361 |
| 358 bool isMultitest = multiTestRegExp.hasMatch(contents); | 362 bool isMultitest = multiTestRegExp.hasMatch(contents); |
| 359 bool containsLeadingHash = leadingHashRegExp.hasMatch(contents); | 363 bool containsLeadingHash = leadingHashRegExp.hasMatch(contents); |
| 364 Match isolateMatch = isolateStubsRegExp.firstMatch(contents); |
| 365 String isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; |
| 360 | 366 |
| 361 return { "vmOptions": result, | 367 return { "vmOptions": result, |
| 362 "dartOptions": dartOptions, | 368 "dartOptions": dartOptions, |
| 363 "isNegative": isNegative, | 369 "isNegative": isNegative, |
| 364 "isMultitest": isMultitest, | 370 "isMultitest": isMultitest, |
| 365 "containsLeadingHash" : containsLeadingHash }; | 371 "containsLeadingHash" : containsLeadingHash, |
| 372 "isolateStubs" : isolateStubs }; |
| 366 } | 373 } |
| 367 } | 374 } |
| 368 | 375 |
| 369 | 376 |
| 370 class DartcCompilationTestSuite extends StandardTestSuite { | 377 class DartcCompilationTestSuite extends StandardTestSuite { |
| 371 List<String> _testDirs; | 378 List<String> _testDirs; |
| 372 int activityCount = 0; | 379 int activityCount = 0; |
| 373 | 380 |
| 374 DartcCompilationTestSuite(Map configuration, | 381 DartcCompilationTestSuite(Map configuration, |
| 375 String suiteName, | 382 String suiteName, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 * $noCrash tests are expected to be flaky but not crash | 539 * $noCrash tests are expected to be flaky but not crash |
| 533 * $pass tests are expected to pass | 540 * $pass tests are expected to pass |
| 534 * $failOk tests are expected to fail that we won't fix | 541 * $failOk tests are expected to fail that we won't fix |
| 535 * $fail tests are expected to fail that we should fix | 542 * $fail tests are expected to fail that we should fix |
| 536 * $crash tests are expected to crash that we should fix | 543 * $crash tests are expected to crash that we should fix |
| 537 * $timeout tests are allowed to timeout\ | 544 * $timeout tests are allowed to timeout\ |
| 538 """; | 545 """; |
| 539 print(report); | 546 print(report); |
| 540 } | 547 } |
| 541 } | 548 } |
| OLD | NEW |