OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Test infrastructure for testing pub. | 5 /// Test infrastructure for testing pub. |
6 /// | 6 /// |
7 /// Unlike typical unit tests, most pub tests are integration tests that stage | 7 /// Unlike typical unit tests, most pub tests are integration tests that stage |
8 /// some stuff on the file system, run pub, and then validate the results. This | 8 /// some stuff on the file system, run pub, and then validate the results. This |
9 /// library provides an API to build tests like that. | 9 /// library provides an API to build tests like that. |
10 import 'dart:async'; | 10 import 'dart:async'; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // infrastructure runs pub in verbose mode, which enables this. | 171 // infrastructure runs pub in verbose mode, which enables this. |
172 pub.stdout.expect(consumeWhile(startsWith("Loading"))); | 172 pub.stdout.expect(consumeWhile(startsWith("Loading"))); |
173 | 173 |
174 return pub; | 174 return pub; |
175 } | 175 } |
176 | 176 |
177 /// Defines an integration test. | 177 /// Defines an integration test. |
178 /// | 178 /// |
179 /// The [body] should schedule a series of operations which will be run | 179 /// The [body] should schedule a series of operations which will be run |
180 /// asynchronously. | 180 /// asynchronously. |
181 void integration(String description, void body()) { | 181 void integration(String description, void body(), |
| 182 {String testOn, |
| 183 Timeout timeout, |
| 184 skip, |
| 185 tags, |
| 186 Map<String, dynamic> onPlatform}) { |
182 test(description, () { | 187 test(description, () { |
183 _sandboxDir = createSystemTempDir(); | 188 _sandboxDir = createSystemTempDir(); |
184 d.defaultRoot = sandboxDir; | 189 d.defaultRoot = sandboxDir; |
185 currentSchedule.onComplete.schedule(() { | 190 currentSchedule.onComplete.schedule(() { |
186 try { | 191 try { |
187 deleteEntry(_sandboxDir); | 192 deleteEntry(_sandboxDir); |
188 } on ApplicationException catch (_) { | 193 } on ApplicationException catch (_) { |
189 // Silently swallow exceptions on Windows. If the test failed, there may | 194 // Silently swallow exceptions on Windows. If the test failed, there may |
190 // still be lingering processes that have files in the sandbox open, | 195 // still be lingering processes that have files in the sandbox open, |
191 // which will cause this to fail on Windows. | 196 // which will cause this to fail on Windows. |
192 if (!Platform.isWindows) rethrow; | 197 if (!Platform.isWindows) rethrow; |
193 } | 198 } |
194 }, 'deleting the sandbox directory'); | 199 }, 'deleting the sandbox directory'); |
195 | 200 |
196 // Schedule the test. | 201 // Schedule the test. |
197 body(); | 202 body(); |
198 }); | 203 }, |
| 204 testOn: testOn, |
| 205 timeout: timeout, |
| 206 skip: skip, |
| 207 onPlatform: onPlatform, |
| 208 tags: tags); |
199 } | 209 } |
200 | 210 |
201 /// Schedules renaming (moving) the directory at [from] to [to], both of which | 211 /// Schedules renaming (moving) the directory at [from] to [to], both of which |
202 /// are assumed to be relative to [sandboxDir]. | 212 /// are assumed to be relative to [sandboxDir]. |
203 void scheduleRename(String from, String to) { | 213 void scheduleRename(String from, String to) { |
204 schedule( | 214 schedule( |
205 () => renameDir( | 215 () => renameDir( |
206 p.join(sandboxDir, from), | 216 p.join(sandboxDir, from), |
207 p.join(sandboxDir, to)), | 217 p.join(sandboxDir, to)), |
208 'renaming $from to $to'); | 218 'renaming $from to $to'); |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 _lastMatcher.matches(item.last, matchState); | 767 _lastMatcher.matches(item.last, matchState); |
758 } | 768 } |
759 | 769 |
760 Description describe(Description description) { | 770 Description describe(Description description) { |
761 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 771 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
762 } | 772 } |
763 } | 773 } |
764 | 774 |
765 /// A [StreamMatcher] that matches multiple lines of output. | 775 /// A [StreamMatcher] that matches multiple lines of output. |
766 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 776 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
OLD | NEW |