| 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. Unlike typical unit tests, most pub | 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub |
| 6 /// tests are integration tests that stage some stuff on the file system, run | 6 /// tests are integration tests that stage some stuff on the file system, run |
| 7 /// pub, and then validate the results. This library provides an API to build | 7 /// pub, and then validate the results. This library provides an API to build |
| 8 /// tests like that. | 8 /// tests like that. |
| 9 library test_pub; | 9 library test_pub; |
| 10 | 10 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 /// directory. | 205 /// directory. |
| 206 final String appPath = "myapp"; | 206 final String appPath = "myapp"; |
| 207 | 207 |
| 208 /// The path of the packages directory in the mock app used for tests. Relative | 208 /// The path of the packages directory in the mock app used for tests. Relative |
| 209 /// to the sandbox directory. | 209 /// to the sandbox directory. |
| 210 final String packagesPath = "$appPath/packages"; | 210 final String packagesPath = "$appPath/packages"; |
| 211 | 211 |
| 212 /// Set to true when the current batch of scheduled events should be aborted. | 212 /// Set to true when the current batch of scheduled events should be aborted. |
| 213 bool _abortScheduled = false; | 213 bool _abortScheduled = false; |
| 214 | 214 |
| 215 /// The time (in milliseconds) to wait for the entire scheduled test to | |
| 216 /// complete. | |
| 217 final _TIMEOUT = 30000; | |
| 218 | |
| 219 /// Defines an integration test. The [body] should schedule a series of | 215 /// Defines an integration test. The [body] should schedule a series of |
| 220 /// operations which will be run asynchronously. | 216 /// operations which will be run asynchronously. |
| 221 void integration(String description, void body()) => | 217 void integration(String description, void body()) => |
| 222 _integration(description, body, test); | 218 _integration(description, body, test); |
| 223 | 219 |
| 224 /// Like [integration], but causes only this test to run. | 220 /// Like [integration], but causes only this test to run. |
| 225 void solo_integration(String description, void body()) => | 221 void solo_integration(String description, void body()) => |
| 226 _integration(description, body, solo_test); | 222 _integration(description, body, solo_test); |
| 227 | 223 |
| 228 void _integration(String description, void body(), [Function testFn]) { | 224 void _integration(String description, void body(), [Function testFn]) { |
| 229 testFn(description, () { | 225 testFn(description, () { |
| 226 // The windows bots are very slow, so we increase the default timeout. |
| 227 if (Platform.operatingSystem == "windows") { |
| 228 currentSchedule.timeout = new Duration(seconds: 10); |
| 229 } |
| 230 |
| 230 // Ensure the SDK version is always available. | 231 // Ensure the SDK version is always available. |
| 231 d.dir(sdkPath, [ | 232 d.dir(sdkPath, [ |
| 232 d.file('version', '0.1.2.3') | 233 d.file('version', '0.1.2.3') |
| 233 ]).create(); | 234 ]).create(); |
| 234 | 235 |
| 235 _sandboxDir = createTempDir(); | 236 _sandboxDir = createTempDir(); |
| 236 d.defaultRoot = sandboxDir; | 237 d.defaultRoot = sandboxDir; |
| 237 currentSchedule.onComplete.schedule(() => deleteEntry(_sandboxDir), | 238 currentSchedule.onComplete.schedule(() => deleteEntry(_sandboxDir), |
| 238 'deleting the sandbox directory'); | 239 'deleting the sandbox directory'); |
| 239 | 240 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 bool matches(item, MatchState matchState) { | 601 bool matches(item, MatchState matchState) { |
| 601 if (item is! Pair) return false; | 602 if (item is! Pair) return false; |
| 602 return _firstMatcher.matches(item.first, matchState) && | 603 return _firstMatcher.matches(item.first, matchState) && |
| 603 _lastMatcher.matches(item.last, matchState); | 604 _lastMatcher.matches(item.last, matchState); |
| 604 } | 605 } |
| 605 | 606 |
| 606 Description describe(Description description) { | 607 Description describe(Description description) { |
| 607 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 608 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 608 } | 609 } |
| 609 } | 610 } |
| OLD | NEW |