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 library pub_cache_test; | 5 library pub_cache_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:json' as json; | 8 import 'dart:json' as json; |
9 | 9 |
10 import 'package:scheduled_test/scheduled_test.dart'; | 10 import 'package:scheduled_test/scheduled_test.dart'; |
11 | 11 |
12 import '../lib/src/io.dart'; | 12 import '../lib/src/io.dart'; |
13 import 'descriptor.dart' as d; | 13 import 'descriptor.dart' as d; |
14 import 'test_pub.dart'; | 14 import 'test_pub.dart'; |
15 | 15 |
16 main() { | 16 main() { |
17 initConfig(); | 17 initConfig(); |
18 | 18 |
19 integration('running pub cache displays error message', () { | 19 integration('running pub cache displays error message', () { |
20 schedulePub(args: ['cache'], | 20 schedulePub(args: ['cache'], |
21 output: ''' | 21 output: ''' |
22 Inspect the system cache. | 22 Inspect the system cache. |
23 | 23 |
24 Usage: pub cache list | 24 Usage: pub cache list |
25 ''', | 25 ''', |
26 error: 'The cache command expects one argument.', | 26 error: 'The cache command expects one argument.', |
27 exitCode: 64); | 27 exitCode: 64); |
28 }); | 28 }); |
29 | 29 |
30 integration('running pub cache foo displays error message', () { | 30 integration('running pub cache foo displays error message', () { |
31 schedulePub(args: ['cache' ,'foo'], | 31 schedulePub(args: ['cache' ,'foo'], |
32 output: ''' | 32 output: ''' |
33 Inspect the system cache. | 33 Inspect the system cache. |
34 | 34 |
35 Usage: pub cache list | 35 Usage: pub cache list |
36 ''', | 36 ''', |
37 error: 'Unknown cache command "foo".', | 37 error: 'Unknown cache command "foo".', |
38 exitCode: 64); | 38 exitCode: 64); |
39 }); | 39 }); |
40 | 40 |
41 integration('running pub cache list when there is no cache', () { | 41 integration('running pub cache list when there is no cache', () { |
42 schedulePub(args: ['cache', 'list'], output: '{"packages":{}}'); | 42 schedulePub(args: ['cache', 'list'], output: '{"packages":{}}'); |
43 }); | 43 }); |
44 | 44 |
45 integration('running pub cache list on empty cache', () { | 45 integration('running pub cache list on empty cache', () { |
46 // Set up a cache. | 46 // Set up a cache. |
47 d.dir(cachePath, [ | 47 d.dir(cachePath, [ |
48 d.dir('hosted', [ | 48 d.dir('hosted', [ |
49 d.dir('pub.dartlang.org', [ | 49 d.dir('pub.dartlang.org', [ |
50 ]) | 50 ]) |
51 ]) | 51 ]) |
52 ]).create(); | 52 ]).create(); |
53 | 53 |
54 schedulePub(args: ['cache', 'list'], output: '{"packages":{}}'); | 54 schedulePub(args: ['cache', 'list'], output: '{"packages":{}}'); |
55 }); | 55 }); |
56 | 56 |
57 integration('running pub cache list', () { | 57 integration('running pub cache list', () { |
58 // Set up a cache. | 58 // Set up a cache. |
59 d.dir(cachePath, [ | 59 d.dir(cachePath, [ |
60 d.dir('hosted', [ | 60 d.dir('hosted', [ |
61 d.dir('pub.dartlang.org', [ | 61 d.dir('pub.dartlang.org', [ |
62 d.dir("foo-1.2.3", [ | 62 d.dir("foo-1.2.3", [ |
63 d.libPubspec("foo", "1.2.3"), | 63 d.libPubspec("foo", "1.2.3"), |
64 d.libDir("foo") | 64 d.libDir("foo") |
65 ]), | 65 ]), |
66 d.dir("bar-2.0.0", [ | 66 d.dir("bar-2.0.0", [ |
67 d.libPubspec("bar", "2.0.0"), | 67 d.libPubspec("bar", "2.0.0"), |
68 d.libDir("bar") ]) | 68 d.libDir("bar") ]) |
69 ]) | 69 ]) |
70 ]) | 70 ]) |
71 ]).create(); | 71 ]).create(); |
72 | 72 |
73 schedulePub(args: ['cache', 'list'], output: | 73 schedulePub(args: ['cache', 'list'], output: |
74 new RegExp(r'\{"packages":\{"bar":\{"version":"2\.0\.0","location":' | 74 new RegExp(r'\{"packages":\{"bar":\{"version":"2\.0\.0","location":' |
75 r'"[^"]+bar-2\.0\.0"\},"foo":\{"version":"1\.2\.3","location":' | 75 r'"[^"]+bar-2\.0\.0"\},"foo":\{"version":"1\.2\.3","location":' |
76 r'"[^"]+foo-1\.2\.3"\}\}\}$')); | 76 r'"[^"]+foo-1\.2\.3"\}\}\}$')); |
77 }); | 77 }); |
78 | 78 |
| 79 integration('includes packages containing deps with bad sources', () { |
| 80 // Set up a cache. |
| 81 d.dir(cachePath, [ |
| 82 d.dir('hosted', [ |
| 83 d.dir('pub.dartlang.org', [ |
| 84 d.dir("foo-1.2.3", [ |
| 85 d.libPubspec("foo", "1.2.3", deps: [{"bad": "bar"}]), |
| 86 d.libDir("foo") |
| 87 ]) |
| 88 ]) |
| 89 ]) |
| 90 ]).create(); |
| 91 |
| 92 schedulePub(args: ['cache', 'list'], output: |
| 93 new RegExp(r'\{"packages":\{"foo":\{"version":"1\.2\.3","location":' |
| 94 r'"[^"]+foo-1\.2\.3"\}\}\}$')); |
| 95 }); |
79 } | 96 } |
OLD | NEW |