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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 * A specialized [TestSuite] that runs tests written in C to unit test | 93 * A specialized [TestSuite] that runs tests written in C to unit test |
| 94 * the Dart virtual machine and its API. | 94 * the Dart virtual machine and its API. |
| 95 * | 95 * |
| 96 * The tests are compiled into a monolithic executable by the build step. | 96 * The tests are compiled into a monolithic executable by the build step. |
| 97 * The executable lists its tests when run with the --list command line flag. | 97 * The executable lists its tests when run with the --list command line flag. |
| 98 * Individual tests are run by specifying them on the command line. | 98 * Individual tests are run by specifying them on the command line. |
| 99 */ | 99 */ |
| 100 class CCTestSuite implements TestSuite { | 100 class CCTestSuite implements TestSuite { |
| 101 Map configuration; | 101 Map configuration; |
| 102 final String suiteName; | 102 final String suiteName; |
| 103 final String testPrefix; | |
| 103 String runnerPath; | 104 String runnerPath; |
| 104 final String dartDir; | 105 final String dartDir; |
| 105 List<String> statusFilePaths; | 106 List<String> statusFilePaths; |
| 106 Function doTest; | 107 Function doTest; |
| 107 Function doDone; | 108 Function doDone; |
| 108 ReceivePort receiveTestName; | 109 ReceivePort receiveTestName; |
| 109 TestExpectations testExpectations; | 110 TestExpectations testExpectations; |
| 110 | 111 |
| 111 CCTestSuite(Map this.configuration, | 112 CCTestSuite(Map this.configuration, |
| 112 String this.suiteName, | 113 String suiteAndPrefix, |
|
Ivan Posva
2012/05/02 20:05:15
The other option would be to pass an additional pa
Siggi Cherem (dart-lang)
2012/05/02 20:34:39
Done.
| |
| 113 String runnerName, | 114 String runnerName, |
| 114 List<String> this.statusFilePaths) | 115 List<String> this.statusFilePaths) |
| 115 : dartDir = TestUtils.dartDir() { | 116 : dartDir = TestUtils.dartDir(), |
| 117 suiteName = _suiteName(suiteAndPrefix), | |
|
Siggi Cherem (dart-lang)
2012/05/02 17:47:03
I'm not convinced this is the best approach to do
Ivan Posva
2012/05/02 20:05:15
Another option would be that the CCTestSuite expec
Siggi Cherem (dart-lang)
2012/05/02 20:34:39
Done.
| |
| 118 testPrefix = _testPrefix(suiteAndPrefix) { | |
| 116 runnerPath = TestUtils.buildDir(configuration) + '/' + runnerName; | 119 runnerPath = TestUtils.buildDir(configuration) + '/' + runnerName; |
| 117 } | 120 } |
| 118 | 121 |
| 119 void testNameHandler(String testName, ignore) { | 122 void testNameHandler(String testName, ignore) { |
| 120 if (testName == "") { | 123 if (testName == "") { |
| 121 receiveTestName.close(); | 124 receiveTestName.close(); |
| 122 doDone(true); | 125 doDone(true); |
| 123 } else { | 126 } else { |
| 124 // Only run the tests that match the pattern. Use the name | 127 // Only run the tests that match the pattern. Use the name |
| 125 // "suiteName/testName" for cc tests. | 128 // "suiteName/testName" for cc tests. |
| 126 RegExp pattern = configuration['selectors'][suiteName]; | 129 RegExp pattern = configuration['selectors'][suiteName]; |
| 127 String constructedName = '$suiteName/$testName'; | 130 String constructedName = '$suiteName/$testPrefix$testName'; |
| 128 if (!pattern.hasMatch(constructedName)) return; | 131 if (!pattern.hasMatch(constructedName)) return; |
| 129 | 132 |
| 130 var expectations = testExpectations.expectations(testName); | 133 var expectations = testExpectations.expectations( |
| 134 '$testPrefix$testName'); | |
| 131 | 135 |
| 132 if (configuration["report"]) { | 136 if (configuration["report"]) { |
| 133 SummaryReport.add(expectations); | 137 SummaryReport.add(expectations); |
| 134 } | 138 } |
| 135 | 139 |
| 136 if (expectations.contains(SKIP)) return; | 140 if (expectations.contains(SKIP)) return; |
| 137 | 141 |
| 138 // The cc test runner takes options after the name of the test | 142 // The cc test runner takes options after the name of the test |
| 139 // to run. | 143 // to run. |
| 140 var args = [testName]; | 144 var args = [testName]; |
| 141 args.addAll(TestUtils.standardOptions(configuration)); | 145 args.addAll(TestUtils.standardOptions(configuration)); |
| 142 | 146 |
| 143 doTest(new TestCase('$suiteName/$testName', | 147 doTest(new TestCase(constructedName, |
| 144 [new Command(runnerPath, args)], | 148 [new Command(runnerPath, args)], |
| 145 configuration, | 149 configuration, |
| 146 completeHandler, | 150 completeHandler, |
| 147 expectations)); | 151 expectations)); |
| 148 } | 152 } |
| 149 } | 153 } |
| 150 | 154 |
| 151 void forEachTest(Function onTest, Map testCache, String globalTempDir(), | 155 void forEachTest(Function onTest, Map testCache, String globalTempDir(), |
| 152 [Function onDone]) { | 156 [Function onDone]) { |
| 153 doTest = onTest; | 157 doTest = onTest; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 169 for (var statusFilePath in statusFilePaths) { | 173 for (var statusFilePath in statusFilePaths) { |
| 170 ReadTestExpectationsInto(testExpectations, | 174 ReadTestExpectationsInto(testExpectations, |
| 171 '$dartDir/$statusFilePath', | 175 '$dartDir/$statusFilePath', |
| 172 configuration, | 176 configuration, |
| 173 statusFileRead); | 177 statusFileRead); |
| 174 } | 178 } |
| 175 } | 179 } |
| 176 | 180 |
| 177 void completeHandler(TestCase testCase) { | 181 void completeHandler(TestCase testCase) { |
| 178 } | 182 } |
| 183 | |
| 184 /** | |
| 185 * Extract the suite name from a string that may include a test prefix, for | |
| 186 * instance return "suite" if s = "suite/prefix" or if s = "suite". | |
| 187 */ | |
| 188 static _suiteName(String s) { | |
| 189 int index = s.indexOf('/'); | |
| 190 if (index == -1) return s; | |
| 191 return s.substring(0, index); | |
| 192 } | |
| 193 | |
| 194 /** | |
| 195 * Returns a test prefix "prefix/" derived from a string of the form | |
| 196 * "suite/prefix". If no prefix is specified (e.g. s = "suite") return an | |
| 197 * empty string. | |
| 198 */ | |
| 199 static _testPrefix(String s) { | |
| 200 int index = s.indexOf('/'); | |
| 201 if (index == -1) return ''; | |
| 202 return '${s.substring(index + 1)}/'; | |
| 203 } | |
| 179 } | 204 } |
| 180 | 205 |
| 181 | 206 |
| 182 class TestInformation { | 207 class TestInformation { |
| 183 String filename; | 208 String filename; |
| 184 Map optionsFromFile; | 209 Map optionsFromFile; |
| 185 bool isNegative; | 210 bool isNegative; |
| 186 bool isNegativeIfChecked; | 211 bool isNegativeIfChecked; |
| 187 bool hasFatalTypeErrors; | 212 bool hasFatalTypeErrors; |
| 188 bool hasRuntimeErrors; | 213 bool hasRuntimeErrors; |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1394 * $noCrash tests are expected to be flaky but not crash | 1419 * $noCrash tests are expected to be flaky but not crash |
| 1395 * $pass tests are expected to pass | 1420 * $pass tests are expected to pass |
| 1396 * $failOk tests are expected to fail that we won't fix | 1421 * $failOk tests are expected to fail that we won't fix |
| 1397 * $fail tests are expected to fail that we should fix | 1422 * $fail tests are expected to fail that we should fix |
| 1398 * $crash tests are expected to crash that we should fix | 1423 * $crash tests are expected to crash that we should fix |
| 1399 * $timeout tests are allowed to timeout | 1424 * $timeout tests are allowed to timeout |
| 1400 """; | 1425 """; |
| 1401 print(report); | 1426 print(report); |
| 1402 } | 1427 } |
| 1403 } | 1428 } |
| OLD | NEW |