| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 | 124 |
| 125 class StandardTestSuite implements TestSuite { | 125 class StandardTestSuite implements TestSuite { |
| 126 Map configuration; | 126 Map configuration; |
| 127 String directoryPath; | 127 String directoryPath; |
| 128 List<String> statusFilePaths; | 128 List<String> statusFilePaths; |
| 129 Function doTest; | 129 Function doTest; |
| 130 Function doDone; | 130 Function doDone; |
| 131 int activeMultitests = 0; |
| 132 bool listingDone = false; |
| 131 String shellPath; | 133 String shellPath; |
| 132 TestExpectations testExpectations; | 134 TestExpectations testExpectations; |
| 133 | 135 |
| 134 StandardTestSuite(Map this.configuration, | 136 StandardTestSuite(Map this.configuration, |
| 135 String this.directoryPath, | 137 String this.directoryPath, |
| 136 List<String> this.statusFilePaths) { | 138 List<String> this.statusFilePaths) { |
| 137 shellPath = TestUtils.dartShellFileName(configuration) ; | 139 shellPath = TestUtils.dartShellFileName(configuration) ; |
| 138 } | 140 } |
| 139 | 141 |
| 140 | 142 |
| 141 void isTestFile(String filename) => filename.endsWith("Test.dart"); | 143 void isTestFile(String filename) => filename.endsWith("Test.dart"); |
| 142 | 144 |
| 143 void listRecursively() => false; | 145 void listRecursively() => false; |
| 144 | 146 |
| 145 void complexStatusMatching() => false; | 147 void complexStatusMatching() => false; |
| 146 | 148 |
| 147 List<String> additionalOptions() => []; | 149 List<String> additionalOptions() => []; |
| 148 | 150 |
| 149 void forEachTest(Function onTest, [Function onDone = null]) { | 151 void forEachTest(Function onTest, [Function onDone = null]) { |
| 150 doTest = onTest; | 152 doTest = onTest; |
| 151 doDone = (ignore) => (onDone != null) ? onDone() : null; | 153 doDone = (onDone != null) ? onDone : (() => null); |
| 152 | 154 |
| 153 // Read test expectations from status files. | 155 // Read test expectations from status files. |
| 154 testExpectations = | 156 testExpectations = |
| 155 new TestExpectations(complexMatching: complexStatusMatching()); | 157 new TestExpectations(complexMatching: complexStatusMatching()); |
| 156 for (var statusFilePath in statusFilePaths) { | 158 for (var statusFilePath in statusFilePaths) { |
| 157 ReadTestExpectationsInto(testExpectations, | 159 ReadTestExpectationsInto(testExpectations, |
| 158 statusFilePath, | 160 statusFilePath, |
| 159 configuration); | 161 configuration); |
| 160 } | 162 } |
| 161 | 163 |
| 162 processDirectory(); | 164 processDirectory(); |
| 163 } | 165 } |
| 164 | 166 |
| 165 void processDirectory() { | 167 void processDirectory() { |
| 166 directoryPath = getDirname(directoryPath); | 168 directoryPath = getDirname(directoryPath); |
| 167 Directory dir = new Directory(directoryPath); | 169 Directory dir = new Directory(directoryPath); |
| 168 dir.errorHandler = (s) { | 170 dir.errorHandler = (s) { |
| 169 throw s; | 171 throw s; |
| 170 }; | 172 }; |
| 171 dir.fileHandler = processFile; | 173 dir.fileHandler = processFile; |
| 172 dir.doneHandler = doDone; | 174 dir.doneHandler = directoryListingDone; |
| 173 dir.list(recursive: listRecursively()); | 175 dir.list(recursive: listRecursively()); |
| 174 } | 176 } |
| 175 | 177 |
| 176 void processFile(String filename) { | 178 void processFile(String filename) { |
| 177 if (!isTestFile(filename)) return; | 179 if (!isTestFile(filename)) return; |
| 178 | 180 |
| 179 // If patterns are given only list the files that match one of the | 181 // If patterns are given only list the files that match one of the |
| 180 // patterns. | 182 // patterns. |
| 181 var patterns = configuration['patterns']; | 183 var patterns = configuration['patterns']; |
| 182 if (!patterns.isEmpty() && | 184 if (!patterns.isEmpty() && |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 args, | 219 args, |
| 218 timeout, | 220 timeout, |
| 219 completeHandler, | 221 completeHandler, |
| 220 expectations, | 222 expectations, |
| 221 isNegative)); | 223 isNegative)); |
| 222 } | 224 } |
| 223 } | 225 } |
| 224 | 226 |
| 225 | 227 |
| 226 if (optionsFromFile['isMultitest']) { | 228 if (optionsFromFile['isMultitest']) { |
| 229 ++activeMultitests; |
| 227 DoMultitest(filename, | 230 DoMultitest(filename, |
| 228 TestUtils.buildDir(configuration), | 231 TestUtils.buildDir(configuration), |
| 229 directoryPath, | 232 directoryPath, |
| 230 createTestCase); | 233 createTestCase, |
| 234 multitestDone); |
| 231 } else { | 235 } else { |
| 232 createTestCase(filename, optionsFromFile['isNegative']); | 236 createTestCase(filename, optionsFromFile['isNegative']); |
| 233 } | 237 } |
| 234 } | 238 } |
| 235 | 239 |
| 240 void multitestDone() { |
| 241 --activeMultitests; |
| 242 if (activeMultitests == 0 && listingDone) { |
| 243 doDone(); |
| 244 } |
| 245 } |
| 246 |
| 247 void directoryListingDone(ignore) { |
| 248 listingDone = true; |
| 249 if (activeMultitests == 0) { |
| 250 doDone(); |
| 251 } |
| 252 } |
| 253 |
| 236 void completeHandler(TestCase testCase) { | 254 void completeHandler(TestCase testCase) { |
| 237 } | 255 } |
| 238 | 256 |
| 239 List<List<String>> argumentListsFromFile(String filename, | 257 List<List<String>> argumentListsFromFile(String filename, |
| 240 Map optionsFromFile) { | 258 Map optionsFromFile) { |
| 241 List args = TestUtils.standardOptions(configuration); | 259 List args = TestUtils.standardOptions(configuration); |
| 242 args.addAll(additionalOptions()); | 260 args.addAll(additionalOptions()); |
| 243 | 261 |
| 244 bool isMultitest = optionsFromFile["isMultitest"]; | 262 bool isMultitest = optionsFromFile["isMultitest"]; |
| 245 List<String> dartOptions = optionsFromFile["dartOptions"]; | 263 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 args.add("--enable_leg"); | 386 args.add("--enable_leg"); |
| 369 } | 387 } |
| 370 if (configuration["component"] == "dartc") { | 388 if (configuration["component"] == "dartc") { |
| 371 if (configuration["mode"] == "release") { | 389 if (configuration["mode"] == "release") { |
| 372 args.add("--optimize"); | 390 args.add("--optimize"); |
| 373 } | 391 } |
| 374 } | 392 } |
| 375 return args; | 393 return args; |
| 376 } | 394 } |
| 377 } | 395 } |
| OLD | NEW |