Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(707)

Side by Side Diff: utils/tests/pub/test_pub.dart

Issue 11635060: Add a validator for dependency version constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/version.dart ('k') | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 5 /**
6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub
7 * tests are integration tests that stage some stuff on the file system, run 7 * tests are integration tests that stage some stuff on the file system, run
8 * pub, and then validate the results. This library provides an API to build 8 * pub, and then validate the results. This library provides an API to build
9 * tests like that. 9 * tests like that.
10 */ 10 */
11 library test_pub; 11 library test_pub;
12 12
13 import 'dart:io'; 13 import 'dart:io';
14 import 'dart:isolate'; 14 import 'dart:isolate';
15 import 'dart:json'; 15 import 'dart:json';
16 import 'dart:math'; 16 import 'dart:math';
17 import 'dart:uri'; 17 import 'dart:uri';
18 18
19 import '../../../pkg/oauth2/lib/oauth2.dart' as oauth2; 19 import '../../../pkg/oauth2/lib/oauth2.dart' as oauth2;
20 import '../../../pkg/path/lib/path.dart' as path; 20 import '../../../pkg/path/lib/path.dart' as path;
21 import '../../../pkg/unittest/lib/unittest.dart'; 21 import '../../../pkg/unittest/lib/unittest.dart';
22 import '../../../pkg/http/lib/testing.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 import '../../pub/git_source.dart'; 25 import '../../pub/git_source.dart';
25 import '../../pub/hosted_source.dart'; 26 import '../../pub/hosted_source.dart';
27 import '../../pub/http.dart';
26 import '../../pub/io.dart'; 28 import '../../pub/io.dart';
27 import '../../pub/sdk_source.dart'; 29 import '../../pub/sdk_source.dart';
28 import '../../pub/system_cache.dart'; 30 import '../../pub/system_cache.dart';
29 import '../../pub/utils.dart'; 31 import '../../pub/utils.dart';
30 import '../../pub/validator.dart'; 32 import '../../pub/validator.dart';
31 import '../../pub/yaml/yaml.dart'; 33 import '../../pub/yaml/yaml.dart';
32 34
33 /** 35 /**
34 * Creates a new [FileDescriptor] with [name] and [contents]. 36 * Creates a new [FileDescriptor] with [name] and [contents].
35 */ 37 */
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 return isGitInstalled.transform((installed) { 703 return isGitInstalled.transform((installed) {
702 if (!installed && 704 if (!installed &&
703 !Platform.environment.containsKey('BUILDBOT_BUILDERNAME')) { 705 !Platform.environment.containsKey('BUILDBOT_BUILDERNAME')) {
704 _abortScheduled = true; 706 _abortScheduled = true;
705 } 707 }
706 return null; 708 return null;
707 }); 709 });
708 }); 710 });
709 } 711 }
710 712
713 /// Use [client] as the mock HTTP client for this test.
714 ///
715 /// Note that this will only affect HTTP requests made via http.dart in the
716 /// parent process.
717 void useMockClient(MockClient client) {
718 var oldInnerClient = httpClient.inner;
719 httpClient.inner = client;
720 _scheduleCleanup((_) {
721 httpClient.inner = oldInnerClient;
722 });
723 }
724
711 Future<Directory> _setUpSandbox() => createTempDir(); 725 Future<Directory> _setUpSandbox() => createTempDir();
712 726
713 Future _runScheduled(Directory parentDir, List<_ScheduledEvent> scheduled) { 727 Future _runScheduled(Directory parentDir, List<_ScheduledEvent> scheduled) {
714 if (scheduled == null) return new Future.immediate(null); 728 if (scheduled == null) return new Future.immediate(null);
715 var iterator = scheduled.iterator(); 729 var iterator = scheduled.iterator();
716 730
717 Future runNextEvent(_) { 731 Future runNextEvent(_) {
718 if (_abortScheduled || !iterator.hasNext) { 732 if (_abortScheduled || !iterator.hasNext) {
719 _abortScheduled = false; 733 _abortScheduled = false;
720 scheduled.clear(); 734 scheduled.clear();
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 /// calling [completion] is unnecessary. 1680 /// calling [completion] is unnecessary.
1667 void expectLater(Future actual, matcher, {String reason, 1681 void expectLater(Future actual, matcher, {String reason,
1668 FailureHandler failureHandler, bool verbose: false}) { 1682 FailureHandler failureHandler, bool verbose: false}) {
1669 _schedule((_) { 1683 _schedule((_) {
1670 return actual.transform((value) { 1684 return actual.transform((value) {
1671 expect(value, matcher, reason: reason, failureHandler: failureHandler, 1685 expect(value, matcher, reason: reason, failureHandler: failureHandler,
1672 verbose: false); 1686 verbose: false);
1673 }); 1687 });
1674 }); 1688 });
1675 } 1689 }
OLDNEW
« no previous file with comments | « utils/pub/version.dart ('k') | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698