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 library test_pub; | 10 library test_pub; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 _integration(description, body, test); | 374 _integration(description, body, test); |
375 | 375 |
376 /// Like [integration], but causes only this test to run. | 376 /// Like [integration], but causes only this test to run. |
377 void solo_integration(String description, void body()) => | 377 void solo_integration(String description, void body()) => |
378 _integration(description, body, solo_test); | 378 _integration(description, body, solo_test); |
379 | 379 |
380 void _integration(String description, void body(), [Function testFn]) { | 380 void _integration(String description, void body(), [Function testFn]) { |
381 testFn(description, () { | 381 testFn(description, () { |
382 _sandboxDir = createSystemTempDir(); | 382 _sandboxDir = createSystemTempDir(); |
383 d.defaultRoot = sandboxDir; | 383 d.defaultRoot = sandboxDir; |
384 currentSchedule.onComplete.schedule(() => deleteEntry(_sandboxDir), | 384 currentSchedule.onComplete.schedule(() { |
385 'deleting the sandbox directory'); | 385 try { |
| 386 deleteEntry(_sandboxDir); |
| 387 } on ApplicationException catch (_) { |
| 388 // Silently swallow exceptions on Windows. If the test failed, there may |
| 389 // still be lingering processes that have files in the sandbox open, |
| 390 // which will cause this to fail on Windows. |
| 391 if (!Platform.isWindows) rethrow; |
| 392 } |
| 393 }, 'deleting the sandbox directory'); |
386 | 394 |
387 // Schedule the test. | 395 // Schedule the test. |
388 body(); | 396 body(); |
389 }); | 397 }); |
390 } | 398 } |
391 | 399 |
392 /// Schedules renaming (moving) the directory at [from] to [to], both of which | 400 /// Schedules renaming (moving) the directory at [from] to [to], both of which |
393 /// are assumed to be relative to [sandboxDir]. | 401 /// are assumed to be relative to [sandboxDir]. |
394 void scheduleRename(String from, String to) { | 402 void scheduleRename(String from, String to) { |
395 schedule( | 403 schedule( |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 _lastMatcher.matches(item.last, matchState); | 999 _lastMatcher.matches(item.last, matchState); |
992 } | 1000 } |
993 | 1001 |
994 Description describe(Description description) { | 1002 Description describe(Description description) { |
995 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 1003 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
996 } | 1004 } |
997 } | 1005 } |
998 | 1006 |
999 /// A [StreamMatcher] that matches multiple lines of output. | 1007 /// A [StreamMatcher] that matches multiple lines of output. |
1000 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 1008 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
OLD | NEW |