| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 _integration(description, body, test); | 356 _integration(description, body, test); |
| 357 | 357 |
| 358 /// Like [integration], but causes only this test to run. | 358 /// Like [integration], but causes only this test to run. |
| 359 void solo_integration(String description, void body()) => | 359 void solo_integration(String description, void body()) => |
| 360 _integration(description, body, solo_test); | 360 _integration(description, body, solo_test); |
| 361 | 361 |
| 362 void _integration(String description, void body(), [Function testFn]) { | 362 void _integration(String description, void body(), [Function testFn]) { |
| 363 testFn(description, () { | 363 testFn(description, () { |
| 364 _sandboxDir = createSystemTempDir(); | 364 _sandboxDir = createSystemTempDir(); |
| 365 d.defaultRoot = sandboxDir; | 365 d.defaultRoot = sandboxDir; |
| 366 currentSchedule.onComplete.schedule(() => deleteEntry(_sandboxDir), | 366 currentSchedule.onComplete.schedule(() { |
| 367 'deleting the sandbox directory'); | 367 try { |
| 368 deleteEntry(_sandboxDir); |
| 369 } on ApplicationException catch (_) { |
| 370 // Silently swallow exceptions on Windows. If the test failed, there may |
| 371 // still be lingering processes that have files in the sandbox open, |
| 372 // which will cause this to fail on Windows. |
| 373 if (!Platform.isWindows) rethrow; |
| 374 } |
| 375 }, 'deleting the sandbox directory'); |
| 368 | 376 |
| 369 // Schedule the test. | 377 // Schedule the test. |
| 370 body(); | 378 body(); |
| 371 }); | 379 }); |
| 372 } | 380 } |
| 373 | 381 |
| 374 /// Schedules renaming (moving) the directory at [from] to [to], both of which | 382 /// Schedules renaming (moving) the directory at [from] to [to], both of which |
| 375 /// are assumed to be relative to [sandboxDir]. | 383 /// are assumed to be relative to [sandboxDir]. |
| 376 void scheduleRename(String from, String to) { | 384 void scheduleRename(String from, String to) { |
| 377 schedule( | 385 schedule( |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 _lastMatcher.matches(item.last, matchState); | 981 _lastMatcher.matches(item.last, matchState); |
| 974 } | 982 } |
| 975 | 983 |
| 976 Description describe(Description description) { | 984 Description describe(Description description) { |
| 977 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 985 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 978 } | 986 } |
| 979 } | 987 } |
| 980 | 988 |
| 981 /// A [StreamMatcher] that matches multiple lines of output. | 989 /// A [StreamMatcher] that matches multiple lines of output. |
| 982 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 990 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
| OLD | NEW |