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