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 |
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 import 'dart:utf'; | 17 import 'dart:utf'; |
18 | 18 |
19 import 'package:http/testing.dart'; | 19 import 'package:http/testing.dart'; |
20 import 'package:oauth2/oauth2.dart' as oauth2; | 20 import 'package:oauth2/oauth2.dart' as oauth2; |
21 import 'package:pathos/path.dart' as path; | 21 import 'package:pathos/path.dart' as path; |
22 import 'package:scheduled_test/scheduled_process.dart'; | 22 import 'package:scheduled_test/scheduled_process.dart'; |
23 import 'package:scheduled_test/scheduled_server.dart'; | 23 import 'package:scheduled_test/scheduled_server.dart'; |
24 import 'package:scheduled_test/scheduled_test.dart'; | 24 import 'package:scheduled_test/scheduled_test.dart'; |
| 25 import 'package:unittest/unittest.dart' as unittest; |
25 import 'package:yaml/yaml.dart'; | 26 import 'package:yaml/yaml.dart'; |
26 | 27 |
27 import '../../pub/entrypoint.dart'; | 28 import '../../pub/entrypoint.dart'; |
28 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides | 29 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides |
29 // with the git descriptor method. Maybe we should try to clean up the top level | 30 // with the git descriptor method. Maybe we should try to clean up the top level |
30 // scope a bit? | 31 // scope a bit? |
31 import '../../pub/git.dart' as gitlib; | 32 import '../../pub/git.dart' as gitlib; |
32 import '../../pub/git_source.dart'; | 33 import '../../pub/git_source.dart'; |
33 import '../../pub/hosted_source.dart'; | 34 import '../../pub/hosted_source.dart'; |
34 import '../../pub/http.dart'; | 35 import '../../pub/http.dart'; |
35 import '../../pub/io.dart'; | 36 import '../../pub/io.dart'; |
36 import '../../pub/path_source.dart'; | 37 import '../../pub/path_source.dart'; |
37 import '../../pub/safe_http_server.dart'; | 38 import '../../pub/safe_http_server.dart'; |
38 import '../../pub/system_cache.dart'; | 39 import '../../pub/system_cache.dart'; |
39 import '../../pub/utils.dart'; | 40 import '../../pub/utils.dart'; |
40 import '../../pub/validator.dart'; | 41 import '../../pub/validator.dart'; |
41 import 'command_line_config.dart'; | 42 import 'command_line_config.dart'; |
42 import 'descriptor.dart' as d; | 43 import 'descriptor.dart' as d; |
43 | 44 |
44 /// This should be called at the top of a test file to set up an appropriate | 45 /// This should be called at the top of a test file to set up an appropriate |
45 /// test configuration for the machine running the tests. | 46 /// test configuration for the machine running the tests. |
46 initConfig() { | 47 initConfig() { |
47 // If we aren't running on the bots, use the human-friendly config. | 48 // If we aren't running on the bots, use the human-friendly config. |
48 if (new Options().arguments.contains('--human')) { | 49 if (new Options().arguments.contains('--human')) { |
49 configure(new CommandLineConfiguration()); | 50 unittest.unittestConfiguration = new CommandLineConfiguration(); |
50 } | 51 } |
51 } | 52 } |
52 | 53 |
53 /// The current [HttpServer] created using [serve]. | 54 /// The current [HttpServer] created using [serve]. |
54 var _server; | 55 var _server; |
55 | 56 |
56 /// The cached value for [_portCompleter]. | 57 /// The cached value for [_portCompleter]. |
57 Completer<int> _portCompleterCache; | 58 Completer<int> _portCompleterCache; |
58 | 59 |
59 /// The completer for [port]. | 60 /// The completer for [port]. |
(...skipping 540 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 |