OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library pub_tests; | |
6 | |
7 import 'package:scheduled_test/scheduled_test.dart'; | |
8 | |
9 import '../lib/src/exit_codes.dart' as exit_codes; | |
10 import 'descriptor.dart' as d; | |
11 import 'test_pub.dart'; | |
12 | |
13 main() { | |
14 initConfig(); | |
15 | |
16 forBothPubGetAndUpgrade((command) { | |
17 group('requires', () { | |
18 integration('a pubspec', () { | |
19 d.dir(appPath, []).create(); | |
20 | |
21 pubCommand(command, | |
22 error: new RegExp(r'Could not find a file named "pubspec.yaml" ' | |
23 r'in "[^\n]*"\.')); | |
24 }); | |
25 | |
26 integration('a pubspec with a "name" key', () { | |
27 d.dir(appPath, [ | |
28 d.pubspec({"dependencies": {"foo": null}}) | |
29 ]).create(); | |
30 | |
31 pubCommand(command, | |
32 error: contains('Missing the required "name" field.'), | |
33 exitCode: exit_codes.DATA); | |
34 }); | |
35 }); | |
36 | |
37 integration('adds itself to the packages', () { | |
38 // The symlink should use the name in the pubspec, not the name of the | |
39 // directory. | |
40 d.dir(appPath, [ | |
41 d.pubspec({"name": "myapp_name"}), | |
42 d.libDir('myapp_name') | |
43 ]).create(); | |
44 | |
45 pubCommand(command); | |
46 | |
47 d.dir(packagesPath, [ | |
48 d.dir("myapp_name", [ | |
49 d.file('myapp_name.dart', 'main() => "myapp_name";') | |
50 ]) | |
51 ]).validate(); | |
52 }); | |
53 | |
54 integration('does not adds itself to the packages if it has no "lib" ' | |
55 'directory', () { | |
56 // The symlink should use the name in the pubspec, not the name of the | |
57 // directory. | |
58 d.dir(appPath, [ | |
59 d.pubspec({"name": "myapp_name"}), | |
60 ]).create(); | |
61 | |
62 pubCommand(command); | |
63 | |
64 d.dir(packagesPath, [ | |
65 d.nothing("myapp_name") | |
66 ]).validate(); | |
67 }); | |
68 | |
69 integration('does not add a package if it does not have a "lib" ' | |
70 'directory', () { | |
71 // Using a path source, but this should be true of all sources. | |
72 d.dir('foo', [ | |
73 d.libPubspec('foo', '0.0.0-not.used') | |
74 ]).create(); | |
75 | |
76 d.dir(appPath, [ | |
77 d.appPubspec({"foo": {"path": "../foo"}}) | |
78 ]).create(); | |
79 | |
80 pubCommand(command); | |
81 | |
82 d.packagesDir({"foo": null}).validate(); | |
83 }); | |
84 | |
85 integration('reports a solver failure', () { | |
86 // myapp depends on foo and bar which both depend on baz with mismatched | |
87 // descriptions. | |
88 d.dir('deps', [ | |
89 d.dir('foo', [ | |
90 d.pubspec({"name": "foo", "dependencies": { | |
91 "baz": {"path": "../baz1"} | |
92 }}) | |
93 ]), | |
94 d.dir('bar', [ | |
95 d.pubspec({"name": "bar", "dependencies": { | |
96 "baz": {"path": "../baz2"} | |
97 }}) | |
98 ]), | |
99 d.dir('baz1', [ | |
100 d.libPubspec('baz', '0.0.0') | |
101 ]), | |
102 d.dir('baz2', [ | |
103 d.libPubspec('baz', '0.0.0') | |
104 ]) | |
105 ]).create(); | |
106 | |
107 d.dir(appPath, [ | |
108 d.appPubspec({ | |
109 "foo": {"path": "../deps/foo"}, | |
110 "bar": {"path": "../deps/bar"} | |
111 }) | |
112 ]).create(); | |
113 | |
114 pubCommand(command, | |
115 error: new RegExp("^Incompatible dependencies on baz:\n")); | |
116 }); | |
117 | |
118 integration('does not allow a dependency on itself', () { | |
119 d.dir(appPath, [ | |
120 d.appPubspec({ | |
121 "myapp": {"path": "."} | |
122 }) | |
123 ]).create(); | |
124 | |
125 pubCommand(command, | |
126 error: contains('A package may not list itself as a dependency.'), | |
127 exitCode: exit_codes.DATA); | |
128 }); | |
129 | |
130 integration('does not allow a dev dependency on itself', () { | |
131 d.dir(appPath, [ | |
132 d.pubspec({ | |
133 "name": "myapp", | |
134 "dev_dependencies": { | |
135 "myapp": {"path": "."} | |
136 } | |
137 }) | |
138 ]).create(); | |
139 | |
140 pubCommand(command, | |
141 error: contains('A package may not list itself as a dependency.'), | |
142 exitCode: exit_codes.DATA); | |
143 }); | |
144 }); | |
145 } | |
OLD | NEW |