| 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 '../../../pkg/http/lib/testing.dart'; | 19 import '../../../pkg/http/lib/testing.dart'; |
| 20 import '../../../pkg/oauth2/lib/oauth2.dart' as oauth2; | 20 import '../../../pkg/oauth2/lib/oauth2.dart' as oauth2; |
| 21 import '../../../pkg/pathos/lib/path.dart' as path; | 21 import '../../../pkg/pathos/lib/path.dart' as path; |
| 22 import '../../../pkg/scheduled_test/lib/scheduled_process.dart'; | 22 import '../../../pkg/scheduled_test/lib/scheduled_process.dart'; |
| 23 import '../../../pkg/scheduled_test/lib/scheduled_server.dart'; | 23 import '../../../pkg/scheduled_test/lib/scheduled_server.dart'; |
| 24 import '../../../pkg/scheduled_test/lib/scheduled_test.dart'; | 24 import '../../../pkg/scheduled_test/lib/scheduled_test.dart'; |
| 25 import '../../../pkg/unittest/lib/unittest.dart' as unittest; |
| 25 import '../../../pkg/yaml/lib/yaml.dart'; | 26 import '../../../pkg/yaml/lib/yaml.dart'; |
| 26 | 27 |
| 27 import '../../lib/file_system.dart' as fs; | 28 import '../../lib/file_system.dart' as fs; |
| 28 import '../../pub/entrypoint.dart'; | 29 import '../../pub/entrypoint.dart'; |
| 29 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides | 30 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides |
| 30 // with the git descriptor method. Maybe we should try to clean up the top level | 31 // with the git descriptor method. Maybe we should try to clean up the top level |
| 31 // scope a bit? | 32 // scope a bit? |
| 32 import '../../pub/git.dart' as gitlib; | 33 import '../../pub/git.dart' as gitlib; |
| 33 import '../../pub/git_source.dart'; | 34 import '../../pub/git_source.dart'; |
| 34 import '../../pub/hosted_source.dart'; | 35 import '../../pub/hosted_source.dart'; |
| 35 import '../../pub/http.dart'; | 36 import '../../pub/http.dart'; |
| 36 import '../../pub/io.dart'; | 37 import '../../pub/io.dart'; |
| 37 import '../../pub/path_source.dart'; | 38 import '../../pub/path_source.dart'; |
| 38 import '../../pub/safe_http_server.dart'; | 39 import '../../pub/safe_http_server.dart'; |
| 39 import '../../pub/system_cache.dart'; | 40 import '../../pub/system_cache.dart'; |
| 40 import '../../pub/utils.dart'; | 41 import '../../pub/utils.dart'; |
| 41 import '../../pub/validator.dart'; | 42 import '../../pub/validator.dart'; |
| 42 import 'command_line_config.dart'; | 43 import 'command_line_config.dart'; |
| 43 import 'descriptor.dart' as d; | 44 import 'descriptor.dart' as d; |
| 44 | 45 |
| 45 /// This should be called at the top of a test file to set up an appropriate | 46 /// This should be called at the top of a test file to set up an appropriate |
| 46 /// test configuration for the machine running the tests. | 47 /// test configuration for the machine running the tests. |
| 47 initConfig() { | 48 initConfig() { |
| 48 // If we aren't running on the bots, use the human-friendly config. | 49 // If we aren't running on the bots, use the human-friendly config. |
| 49 if (new Options().arguments.contains('--human')) { | 50 if (new Options().arguments.contains('--human')) { |
| 50 configure(new CommandLineConfiguration()); | 51 unittest.unittestConfiguration = new CommandLineConfiguration(); |
| 51 } | 52 } |
| 52 } | 53 } |
| 53 | 54 |
| 54 /// The current [HttpServer] created using [serve]. | 55 /// The current [HttpServer] created using [serve]. |
| 55 var _server; | 56 var _server; |
| 56 | 57 |
| 57 /// The cached value for [_portCompleter]. | 58 /// The cached value for [_portCompleter]. |
| 58 Completer<int> _portCompleterCache; | 59 Completer<int> _portCompleterCache; |
| 59 | 60 |
| 60 /// The completer for [port]. | 61 /// The completer for [port]. |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 bool matches(item, MatchState matchState) { | 585 bool matches(item, MatchState matchState) { |
| 585 if (item is! Pair) return false; | 586 if (item is! Pair) return false; |
| 586 return _firstMatcher.matches(item.first, matchState) && | 587 return _firstMatcher.matches(item.first, matchState) && |
| 587 _lastMatcher.matches(item.last, matchState); | 588 _lastMatcher.matches(item.last, matchState); |
| 588 } | 589 } |
| 589 | 590 |
| 590 Description describe(Description description) { | 591 Description describe(Description description) { |
| 591 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 592 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 592 } | 593 } |
| 593 } | 594 } |
| OLD | NEW |