| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 expectations)); | 96 expectations)); |
| 97 | 97 |
| 98 receiveTestName.receive(testNameHandler); | 98 receiveTestName.receive(testNameHandler); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 void forEachTest(Function onTest, Map testCache, [Function onDone]) { | 102 void forEachTest(Function onTest, Map testCache, [Function onDone]) { |
| 103 doTest = onTest; | 103 doTest = onTest; |
| 104 doDone = (ignore) => (onDone != null) ? onDone() : null; | 104 doDone = (ignore) => (onDone != null) ? onDone() : null; |
| 105 | 105 |
| 106 var filesRead = 0; |
| 107 void statusFileRead() { |
| 108 filesRead++; |
| 109 if (filesRead == statusFilePaths.length) { |
| 110 receiveTestName = new ReceivePort(); |
| 111 new CCTestListerIsolate().spawn().then((port) { |
| 112 port.send(runnerPath, receiveTestName.toSendPort()); |
| 113 receiveTestName.receive(testNameHandler); |
| 114 }); |
| 115 } |
| 116 } |
| 117 |
| 106 testExpectations = | 118 testExpectations = |
| 107 new TestExpectations(complexMatching: complexStatusMatching()); | 119 new TestExpectations(complexMatching: complexStatusMatching()); |
| 108 for (var statusFilePath in statusFilePaths) { | 120 for (var statusFilePath in statusFilePaths) { |
| 109 ReadTestExpectationsInto(testExpectations, | 121 ReadTestExpectationsInto(testExpectations, |
| 110 statusFilePath, | 122 statusFilePath, |
| 111 configuration); | 123 configuration, |
| 124 statusFileRead); |
| 112 } | 125 } |
| 113 | |
| 114 receiveTestName = new ReceivePort(); | |
| 115 new CCTestListerIsolate().spawn().then((port) { | |
| 116 port.send(runnerPath, receiveTestName.toSendPort()); | |
| 117 receiveTestName.receive(testNameHandler); | |
| 118 }); | |
| 119 } | 126 } |
| 120 | 127 |
| 121 void completeHandler(TestCase testCase) { | 128 void completeHandler(TestCase testCase) { |
| 122 } | 129 } |
| 123 } | 130 } |
| 124 | 131 |
| 125 | 132 |
| 126 class TestInformation { | 133 class TestInformation { |
| 127 String filename; | 134 String filename; |
| 128 Map optionsFromFile; | 135 Map optionsFromFile; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 159 void complexStatusMatching() => false; | 166 void complexStatusMatching() => false; |
| 160 | 167 |
| 161 String shellPath() => TestUtils.dartShellFileName(configuration); | 168 String shellPath() => TestUtils.dartShellFileName(configuration); |
| 162 | 169 |
| 163 List<String> additionalOptions() => []; | 170 List<String> additionalOptions() => []; |
| 164 | 171 |
| 165 void forEachTest(Function onTest, Map testCache, [Function onDone = null]) { | 172 void forEachTest(Function onTest, Map testCache, [Function onDone = null]) { |
| 166 doTest = onTest; | 173 doTest = onTest; |
| 167 doDone = (onDone != null) ? onDone : (() => null); | 174 doDone = (onDone != null) ? onDone : (() => null); |
| 168 | 175 |
| 176 var filesRead = 0; |
| 177 void statusFileRead() { |
| 178 filesRead++; |
| 179 if (filesRead == statusFilePaths.length) { |
| 180 // Checked if we have already found and generated the tests for |
| 181 // this suite. |
| 182 if (!testCache.containsKey(suiteName)) { |
| 183 cachedTests = testCache[suiteName] = []; |
| 184 processDirectory(); |
| 185 } else { |
| 186 // We rely on enqueueing completing asynchronously so use a |
| 187 // timer to make it so. |
| 188 void enqueueCachedTests(Timer ignore) { |
| 189 for (var info in testCache[suiteName]) { |
| 190 enqueueTestCaseFromTestInformation(info); |
| 191 } |
| 192 doDone(); |
| 193 } |
| 194 new Timer(enqueueCachedTests, 0, false); |
| 195 } |
| 196 } |
| 197 } |
| 198 |
| 169 // Read test expectations from status files. | 199 // Read test expectations from status files. |
| 170 testExpectations = | 200 testExpectations = |
| 171 new TestExpectations(complexMatching: complexStatusMatching()); | 201 new TestExpectations(complexMatching: complexStatusMatching()); |
| 172 for (var statusFilePath in statusFilePaths) { | 202 for (var statusFilePath in statusFilePaths) { |
| 173 ReadTestExpectationsInto(testExpectations, | 203 ReadTestExpectationsInto(testExpectations, |
| 174 statusFilePath, | 204 statusFilePath, |
| 175 configuration); | 205 configuration, |
| 176 } | 206 statusFileRead); |
| 177 | |
| 178 // Checked if we have already found and generated the tests for | |
| 179 // this suite. | |
| 180 if (!testCache.containsKey(suiteName)) { | |
| 181 cachedTests = testCache[suiteName] = []; | |
| 182 processDirectory(); | |
| 183 } else { | |
| 184 // We rely on enqueueing completing asynchronously so use a | |
| 185 // timer to make it so. | |
| 186 void enqueueCachedTests(Timer ignore) { | |
| 187 for (var info in testCache[suiteName]) { | |
| 188 enqueueTestCaseFromTestInformation(info); | |
| 189 } | |
| 190 doDone(); | |
| 191 } | |
| 192 new Timer(enqueueCachedTests, 0, false); | |
| 193 } | 207 } |
| 194 } | 208 } |
| 195 | 209 |
| 196 void processDirectory() { | 210 void processDirectory() { |
| 197 directoryPath = getDirname(directoryPath); | 211 directoryPath = getDirname(directoryPath); |
| 198 Directory dir = new Directory(directoryPath); | 212 Directory dir = new Directory(directoryPath); |
| 199 dir.errorHandler = (s) { | 213 dir.errorHandler = (s) { |
| 200 throw s; | 214 throw s; |
| 201 }; | 215 }; |
| 202 dir.fileHandler = processFile; | 216 dir.fileHandler = processFile; |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 * $noCrash tests are expected to be flaky but not crash | 606 * $noCrash tests are expected to be flaky but not crash |
| 593 * $pass tests are expected to pass | 607 * $pass tests are expected to pass |
| 594 * $failOk tests are expected to fail that we won't fix | 608 * $failOk tests are expected to fail that we won't fix |
| 595 * $fail tests are expected to fail that we should fix | 609 * $fail tests are expected to fail that we should fix |
| 596 * $crash tests are expected to crash that we should fix | 610 * $crash tests are expected to crash that we should fix |
| 597 * $timeout tests are allowed to timeout\ | 611 * $timeout tests are allowed to timeout\ |
| 598 """; | 612 """; |
| 599 print(report); | 613 print(report); |
| 600 } | 614 } |
| 601 } | 615 } |
| OLD | NEW |