Chromium Code Reviews| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 | 173 |
| 174 class TestInformation { | 174 class TestInformation { |
| 175 String filename; | 175 String filename; |
| 176 Map optionsFromFile; | 176 Map optionsFromFile; |
| 177 bool isNegative; | 177 bool isNegative; |
| 178 bool isNegativeIfChecked; | 178 bool isNegativeIfChecked; |
| 179 bool hasFatalTypeErrors; | 179 bool hasFatalTypeErrors; |
| 180 bool hasRuntimeErrors; | |
| 180 | 181 |
| 181 TestInformation(this.filename, this.optionsFromFile, this.isNegative, | 182 TestInformation(this.filename, this.optionsFromFile, this.isNegative, |
| 182 this.isNegativeIfChecked, this.hasFatalTypeErrors); | 183 this.isNegativeIfChecked, this.hasFatalTypeErrors, |
| 184 this.hasRuntimeErrors); | |
| 183 } | 185 } |
| 184 | 186 |
| 185 | 187 |
| 186 /** | 188 /** |
| 187 * A standard [TestSuite] implementation that searches for tests in a | 189 * A standard [TestSuite] implementation that searches for tests in a |
| 188 * directory, and creates [TestCase]s that compile and/or run them. | 190 * directory, and creates [TestCase]s that compile and/or run them. |
| 189 */ | 191 */ |
| 190 class StandardTestSuite implements TestSuite { | 192 class StandardTestSuite implements TestSuite { |
| 191 Map configuration; | 193 Map configuration; |
| 192 String suiteName; | 194 String suiteName; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 // See if there's a 'src' directory inside the 'tests' one. | 291 // See if there's a 'src' directory inside the 'tests' one. |
| 290 int testsStart = filename.lastIndexOf('tests/'); | 292 int testsStart = filename.lastIndexOf('tests/'); |
| 291 int start = filename.lastIndexOf('src/'); | 293 int start = filename.lastIndexOf('src/'); |
| 292 if (start > testsStart) { | 294 if (start > testsStart) { |
| 293 testName = filename.substring(start + 4, filename.length - 5); | 295 testName = filename.substring(start + 4, filename.length - 5); |
| 294 } else if (optionsFromFile['isMultitest']) { | 296 } else if (optionsFromFile['isMultitest']) { |
| 295 start = filename.lastIndexOf('/'); | 297 start = filename.lastIndexOf('/'); |
| 296 int middle = filename.lastIndexOf('_'); | 298 int middle = filename.lastIndexOf('_'); |
| 297 testName = filename.substring(start + 1, middle) + '/' + | 299 testName = filename.substring(start + 1, middle) + '/' + |
| 298 filename.substring(middle + 1, filename.length - 5); | 300 filename.substring(middle + 1, filename.length - 5); |
| 301 if ((configuration['component'] == 'dartc') && info.hasRuntimeErrors) { | |
| 302 isNegative = false; | |
| 303 } | |
|
Bill Hesse
2012/02/24 13:58:36
I think this could be moved to line 345, since run
ngeoffray
2012/02/24 14:08:10
Done.
| |
| 299 } else { | 304 } else { |
| 300 // This case is hit by the dartc client compilation | 305 // This case is hit by the dartc client compilation |
| 301 // tests. These tests are pretty broken compared to the | 306 // tests. These tests are pretty broken compared to the |
| 302 // rest. They use the .dart suffix in the status files. They | 307 // rest. They use the .dart suffix in the status files. They |
| 303 // find tests in weird ways (testing that they contain "#"). | 308 // find tests in weird ways (testing that they contain "#"). |
| 304 // They need to be redone. | 309 // They need to be redone. |
| 305 // TODO(1058): This does not work on Windows. | 310 // TODO(1058): This does not work on Windows. |
| 306 start = filename.indexOf(directoryPath); | 311 start = filename.indexOf(directoryPath); |
| 307 if (start != -1) { | 312 if (start != -1) { |
| 308 testName = filename.substring(start + directoryPath.length + 1); | 313 testName = filename.substring(start + directoryPath.length + 1); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 338 // errors with a flag and treat tests that have fatal type | 343 // errors with a flag and treat tests that have fatal type |
| 339 // errors as negative. | 344 // errors as negative. |
| 340 var enableFatalTypeErrors = | 345 var enableFatalTypeErrors = |
| 341 (info.hasFatalTypeErrors && configuration['component'] == 'dartc'); | 346 (info.hasFatalTypeErrors && configuration['component'] == 'dartc'); |
| 342 var argumentLists = argumentListsFromFile(filename, | 347 var argumentLists = argumentListsFromFile(filename, |
| 343 optionsFromFile, | 348 optionsFromFile, |
| 344 enableFatalTypeErrors); | 349 enableFatalTypeErrors); |
| 345 isNegative = isNegative || | 350 isNegative = isNegative || |
| 346 (configuration['checked'] && info.isNegativeIfChecked) || | 351 (configuration['checked'] && info.isNegativeIfChecked) || |
| 347 enableFatalTypeErrors; | 352 enableFatalTypeErrors; |
| 348 | 353 |
|
Bill Hesse
2012/02/24 13:58:36
It could be put down here, at the other place isNe
| |
| 349 for (var args in argumentLists) { | 354 for (var args in argumentLists) { |
| 350 doTest(new TestCase('$suiteName/$testName', | 355 doTest(new TestCase('$suiteName/$testName', |
| 351 shellPath(), | 356 shellPath(), |
| 352 args, | 357 args, |
| 353 configuration, | 358 configuration, |
| 354 completeHandler, | 359 completeHandler, |
| 355 expectations, | 360 expectations, |
| 356 isNegative)); | 361 isNegative)); |
| 357 } | 362 } |
| 358 } | 363 } |
| 359 } | 364 } |
| 360 | 365 |
| 361 Function makeTestCaseCreator(Map optionsFromFile) { | 366 Function makeTestCaseCreator(Map optionsFromFile) { |
| 362 return (String filename, | 367 return (String filename, |
| 363 bool isNegative, | 368 bool isNegative, |
| 364 [bool isNegativeIfChecked = false, | 369 [bool isNegativeIfChecked = false, |
| 365 bool hasFatalTypeErrors = false]) { | 370 bool hasFatalTypeErrors = false, |
| 371 bool hasRuntimeErrors = false]) { | |
| 366 // Cache the test information for each test case. | 372 // Cache the test information for each test case. |
| 367 var info = new TestInformation(filename, | 373 var info = new TestInformation(filename, |
| 368 optionsFromFile, | 374 optionsFromFile, |
| 369 isNegative, | 375 isNegative, |
| 370 isNegativeIfChecked, | 376 isNegativeIfChecked, |
| 371 hasFatalTypeErrors); | 377 hasFatalTypeErrors, |
| 378 hasRuntimeErrors); | |
| 372 cachedTests.add(info); | 379 cachedTests.add(info); |
| 373 enqueueTestCaseFromTestInformation(info); | 380 enqueueTestCaseFromTestInformation(info); |
| 374 }; | 381 }; |
| 375 } | 382 } |
| 376 | 383 |
| 377 void processFile(String filename) { | 384 void processFile(String filename) { |
| 378 if (!isTestFile(filename)) return; | 385 if (!isTestFile(filename)) return; |
| 379 | 386 |
| 380 // Only run the tests that match the pattern. | 387 // Only run the tests that match the pattern. |
| 381 RegExp pattern = configuration['selectors'][suiteName]; | 388 RegExp pattern = configuration['selectors'][suiteName]; |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1126 * $noCrash tests are expected to be flaky but not crash | 1133 * $noCrash tests are expected to be flaky but not crash |
| 1127 * $pass tests are expected to pass | 1134 * $pass tests are expected to pass |
| 1128 * $failOk tests are expected to fail that we won't fix | 1135 * $failOk tests are expected to fail that we won't fix |
| 1129 * $fail tests are expected to fail that we should fix | 1136 * $fail tests are expected to fail that we should fix |
| 1130 * $crash tests are expected to crash that we should fix | 1137 * $crash tests are expected to crash that we should fix |
| 1131 * $timeout tests are allowed to timeout | 1138 * $timeout tests are allowed to timeout |
| 1132 """; | 1139 """; |
| 1133 print(report); | 1140 print(report); |
| 1134 } | 1141 } |
| 1135 } | 1142 } |
| OLD | NEW |