| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 |
| 11 import 'dart:async'; | 11 import 'dart:async'; |
| 12 import 'dart:collection' show Queue; | 12 import 'dart:collection' show Queue; |
| 13 import 'dart:io'; | 13 import 'dart:io'; |
| 14 import 'dart:json' as json; | 14 import 'dart:json' as json; |
| 15 import 'dart:math'; | 15 import 'dart:math'; |
| 16 import 'dart:uri'; | 16 import 'dart:uri'; |
| 17 | 17 |
| 18 import '../../../pkg/http/lib/testing.dart'; |
| 18 import '../../../pkg/oauth2/lib/oauth2.dart' as oauth2; | 19 import '../../../pkg/oauth2/lib/oauth2.dart' as oauth2; |
| 19 import '../../../pkg/path/lib/path.dart' as path; | 20 import '../../../pkg/path/lib/path.dart' as path; |
| 20 import '../../../pkg/unittest/lib/unittest.dart'; | 21 import '../../../pkg/unittest/lib/unittest.dart'; |
| 21 import '../../../pkg/http/lib/testing.dart'; | 22 import '../../../pkg/yaml/lib/yaml.dart'; |
| 22 import '../../lib/file_system.dart' as fs; | 23 import '../../lib/file_system.dart' as fs; |
| 23 import '../../pub/entrypoint.dart'; | 24 import '../../pub/entrypoint.dart'; |
| 24 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides | 25 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides |
| 25 // with the git descriptor method. Maybe we should try to clean up the top level | 26 // with the git descriptor method. Maybe we should try to clean up the top level |
| 26 // scope a bit? | 27 // scope a bit? |
| 27 import '../../pub/git.dart' as gitlib; | 28 import '../../pub/git.dart' as gitlib; |
| 28 import '../../pub/git_source.dart'; | 29 import '../../pub/git_source.dart'; |
| 29 import '../../pub/hosted_source.dart'; | 30 import '../../pub/hosted_source.dart'; |
| 30 import '../../pub/http.dart'; | 31 import '../../pub/http.dart'; |
| 31 import '../../pub/io.dart'; | 32 import '../../pub/io.dart'; |
| 32 import '../../pub/sdk_source.dart'; | 33 import '../../pub/sdk_source.dart'; |
| 33 import '../../pub/system_cache.dart'; | 34 import '../../pub/system_cache.dart'; |
| 34 import '../../pub/utils.dart'; | 35 import '../../pub/utils.dart'; |
| 35 import '../../pub/validator.dart'; | 36 import '../../pub/validator.dart'; |
| 36 import '../../pub/yaml/yaml.dart'; | |
| 37 import 'command_line_config.dart'; | 37 import 'command_line_config.dart'; |
| 38 | 38 |
| 39 /// This should be called at the top of a test file to set up an appropriate | 39 /// This should be called at the top of a test file to set up an appropriate |
| 40 /// test configuration for the machine running the tests. | 40 /// test configuration for the machine running the tests. |
| 41 initConfig() { | 41 initConfig() { |
| 42 // If we aren't running on the bots, use the human-friendly config. | 42 // If we aren't running on the bots, use the human-friendly config. |
| 43 if (new Options().arguments.contains('--human')) { | 43 if (new Options().arguments.contains('--human')) { |
| 44 configure(new CommandLineConfiguration()); | 44 configure(new CommandLineConfiguration()); |
| 45 } | 45 } |
| 46 } | 46 } |
| (...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 /// calling [completion] is unnecessary. | 1546 /// calling [completion] is unnecessary. |
| 1547 void expectLater(Future actual, matcher, {String reason, | 1547 void expectLater(Future actual, matcher, {String reason, |
| 1548 FailureHandler failureHandler, bool verbose: false}) { | 1548 FailureHandler failureHandler, bool verbose: false}) { |
| 1549 _schedule((_) { | 1549 _schedule((_) { |
| 1550 return actual.then((value) { | 1550 return actual.then((value) { |
| 1551 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1551 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
| 1552 verbose: false); | 1552 verbose: false); |
| 1553 }); | 1553 }); |
| 1554 }); | 1554 }); |
| 1555 } | 1555 } |
| OLD | NEW |