OLD | NEW |
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 library pub_tests; | 5 library pub_tests; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
| 9 import '../../../../pkg/unittest/lib/unittest.dart'; |
9 import '../test_pub.dart'; | 10 import '../test_pub.dart'; |
10 import '../../../../pkg/unittest/lib/unittest.dart'; | |
11 | 11 |
12 main() { | 12 main() { |
13 group('requires', () { | 13 group('requires', () { |
14 test('a pubspec', () { | 14 integration('a pubspec', () { |
15 dir(appPath, []).scheduleCreate(); | 15 dir(appPath, []).scheduleCreate(); |
16 | 16 |
17 schedulePub(args: ['install'], | 17 schedulePub(args: ['install'], |
18 error: new RegExp(r'^Could not find a file named "pubspec\.yaml"'), | 18 error: new RegExp(r'^Could not find a file named "pubspec\.yaml"'), |
19 exitCode: 1); | 19 exitCode: 1); |
20 | |
21 run(); | |
22 }); | 20 }); |
23 | 21 |
24 test('a pubspec with a "name" key', () { | 22 integration('a pubspec with a "name" key', () { |
25 dir(appPath, [ | 23 dir(appPath, [ |
26 pubspec({"dependencies": {"foo": null}}) | 24 pubspec({"dependencies": {"foo": null}}) |
27 ]).scheduleCreate(); | 25 ]).scheduleCreate(); |
28 | 26 |
29 schedulePub(args: ['install'], | 27 schedulePub(args: ['install'], |
30 error: new RegExp(r'^pubspec.yaml is missing the required "name" ' | 28 error: new RegExp(r'^pubspec.yaml is missing the required "name" ' |
31 r'field \(e\.g\. "name: myapp"\)\.'), | 29 r'field \(e\.g\. "name: myapp"\)\.'), |
32 exitCode: 1); | 30 exitCode: 1); |
33 | |
34 run(); | |
35 }); | 31 }); |
36 }); | 32 }); |
37 | 33 |
38 test('adds itself to the packages', () { | 34 integration('adds itself to the packages', () { |
39 // The symlink should use the name in the pubspec, not the name of the | 35 // The symlink should use the name in the pubspec, not the name of the |
40 // directory. | 36 // directory. |
41 dir(appPath, [ | 37 dir(appPath, [ |
42 pubspec({"name": "myapp_name"}), | 38 pubspec({"name": "myapp_name"}), |
43 libDir('foo'), | 39 libDir('foo'), |
44 ]).scheduleCreate(); | 40 ]).scheduleCreate(); |
45 | 41 |
46 schedulePub(args: ['install'], | 42 schedulePub(args: ['install'], |
47 output: new RegExp(r"Dependencies installed!$")); | 43 output: new RegExp(r"Dependencies installed!$")); |
48 | 44 |
49 dir(packagesPath, [ | 45 dir(packagesPath, [ |
50 dir("myapp_name", [ | 46 dir("myapp_name", [ |
51 file('foo.dart', 'main() => "foo";') | 47 file('foo.dart', 'main() => "foo";') |
52 ]) | 48 ]) |
53 ]).scheduleValidate(); | 49 ]).scheduleValidate(); |
54 | |
55 run(); | |
56 }); | 50 }); |
57 | 51 |
58 test('does not adds itself to the packages if it has no "lib" directory', () { | 52 integration('does not adds itself to the packages if it has no "lib" directory
', () { |
59 // The symlink should use the name in the pubspec, not the name of the | 53 // The symlink should use the name in the pubspec, not the name of the |
60 // directory. | 54 // directory. |
61 dir(appPath, [ | 55 dir(appPath, [ |
62 pubspec({"name": "myapp_name"}), | 56 pubspec({"name": "myapp_name"}), |
63 ]).scheduleCreate(); | 57 ]).scheduleCreate(); |
64 | 58 |
65 schedulePub(args: ['install'], | 59 schedulePub(args: ['install'], |
66 output: new RegExp(r"Dependencies installed!$")); | 60 output: new RegExp(r"Dependencies installed!$")); |
67 | 61 |
68 dir(packagesPath, [ | 62 dir(packagesPath, [ |
69 nothing("myapp_name") | 63 nothing("myapp_name") |
70 ]).scheduleValidate(); | 64 ]).scheduleValidate(); |
71 | |
72 run(); | |
73 }); | 65 }); |
74 | 66 |
75 test('does not add a package if it does not have a "lib" directory', () { | 67 integration('does not add a package if it does not have a "lib" directory', ()
{ |
76 // Using an SDK source, but this should be true of all sources. | 68 // Using an SDK source, but this should be true of all sources. |
77 dir(sdkPath, [ | 69 dir(sdkPath, [ |
78 file('revision', '1234'), | 70 file('revision', '1234'), |
79 dir('pkg', [ | 71 dir('pkg', [ |
80 dir('foo', [ | 72 dir('foo', [ |
81 libPubspec('foo', '0.0.0-not.used') | 73 libPubspec('foo', '0.0.0-not.used') |
82 ]) | 74 ]) |
83 ]) | 75 ]) |
84 ]).scheduleCreate(); | 76 ]).scheduleCreate(); |
85 | 77 |
86 dir(appPath, [ | 78 dir(appPath, [ |
87 pubspec({"name": "myapp", "dependencies": {"foo": {"sdk": "foo"}}}) | 79 pubspec({"name": "myapp", "dependencies": {"foo": {"sdk": "foo"}}}) |
88 ]).scheduleCreate(); | 80 ]).scheduleCreate(); |
89 | 81 |
90 schedulePub(args: ['install'], | 82 schedulePub(args: ['install'], |
91 error: new RegExp(r'Warning: Package "foo" does not have a "lib" ' | 83 error: new RegExp(r'Warning: Package "foo" does not have a "lib" ' |
92 'directory so you will not be able to import any libraries from ' | 84 'directory so you will not be able to import any libraries from ' |
93 'it.'), | 85 'it.'), |
94 output: new RegExp(r"Dependencies installed!$")); | 86 output: new RegExp(r"Dependencies installed!$")); |
95 | |
96 run(); | |
97 }); | 87 }); |
98 | 88 |
99 test('does not warn if the root package lacks a "lib" directory', () { | 89 integration('does not warn if the root package lacks a "lib" directory', () { |
100 dir(appPath, [ | 90 dir(appPath, [ |
101 appPubspec([]) | 91 appPubspec([]) |
102 ]).scheduleCreate(); | 92 ]).scheduleCreate(); |
103 | 93 |
104 schedulePub(args: ['install'], | 94 schedulePub(args: ['install'], |
105 error: '', | 95 error: '', |
106 output: new RegExp(r"Dependencies installed!$")); | 96 output: new RegExp(r"Dependencies installed!$")); |
107 | |
108 run(); | |
109 }); | 97 }); |
110 | 98 |
111 test('overwrites the existing packages directory', () { | 99 integration('overwrites the existing packages directory', () { |
112 dir(appPath, [ | 100 dir(appPath, [ |
113 appPubspec([]), | 101 appPubspec([]), |
114 dir('packages', [ | 102 dir('packages', [ |
115 dir('foo'), | 103 dir('foo'), |
116 dir('myapp'), | 104 dir('myapp'), |
117 ]), | 105 ]), |
118 libDir('myapp') | 106 libDir('myapp') |
119 ]).scheduleCreate(); | 107 ]).scheduleCreate(); |
120 | 108 |
121 schedulePub(args: ['install'], | 109 schedulePub(args: ['install'], |
122 output: new RegExp(r"Dependencies installed!$")); | 110 output: new RegExp(r"Dependencies installed!$")); |
123 | 111 |
124 dir(packagesPath, [ | 112 dir(packagesPath, [ |
125 nothing('foo'), | 113 nothing('foo'), |
126 dir('myapp', [file('myapp.dart', 'main() => "myapp";')]) | 114 dir('myapp', [file('myapp.dart', 'main() => "myapp";')]) |
127 ]).scheduleValidate(); | 115 ]).scheduleValidate(); |
128 | |
129 run(); | |
130 }); | 116 }); |
131 | 117 |
132 group('creates a packages directory in', () { | 118 group('creates a packages directory in', () { |
133 test('"test/" and its subdirectories', () { | 119 integration('"test/" and its subdirectories', () { |
134 dir(appPath, [ | 120 dir(appPath, [ |
135 appPubspec([]), | 121 appPubspec([]), |
136 libDir('foo'), | 122 libDir('foo'), |
137 dir("test", [dir("subtest")]) | 123 dir("test", [dir("subtest")]) |
138 ]).scheduleCreate(); | 124 ]).scheduleCreate(); |
139 | 125 |
140 schedulePub(args: ['install'], | 126 schedulePub(args: ['install'], |
141 output: new RegExp(r"Dependencies installed!$")); | 127 output: new RegExp(r"Dependencies installed!$")); |
142 | 128 |
143 dir(appPath, [ | 129 dir(appPath, [ |
144 dir("test", [ | 130 dir("test", [ |
145 dir("packages", [ | 131 dir("packages", [ |
146 dir("myapp", [ | 132 dir("myapp", [ |
147 file('foo.dart', 'main() => "foo";') | 133 file('foo.dart', 'main() => "foo";') |
148 ]) | 134 ]) |
149 ]), | 135 ]), |
150 dir("subtest", [ | 136 dir("subtest", [ |
151 dir("packages", [ | 137 dir("packages", [ |
152 dir("myapp", [ | 138 dir("myapp", [ |
153 file('foo.dart', 'main() => "foo";') | 139 file('foo.dart', 'main() => "foo";') |
154 ]) | 140 ]) |
155 ]) | 141 ]) |
156 ]) | 142 ]) |
157 ]) | 143 ]) |
158 ]).scheduleValidate(); | 144 ]).scheduleValidate(); |
159 | |
160 run(); | |
161 }); | 145 }); |
162 | 146 |
163 test('"example/" and its subdirectories', () { | 147 integration('"example/" and its subdirectories', () { |
164 dir(appPath, [ | 148 dir(appPath, [ |
165 appPubspec([]), | 149 appPubspec([]), |
166 libDir('foo'), | 150 libDir('foo'), |
167 dir("example", [dir("subexample")]) | 151 dir("example", [dir("subexample")]) |
168 ]).scheduleCreate(); | 152 ]).scheduleCreate(); |
169 | 153 |
170 schedulePub(args: ['install'], | 154 schedulePub(args: ['install'], |
171 output: new RegExp(r"Dependencies installed!$")); | 155 output: new RegExp(r"Dependencies installed!$")); |
172 | 156 |
173 dir(appPath, [ | 157 dir(appPath, [ |
174 dir("example", [ | 158 dir("example", [ |
175 dir("packages", [ | 159 dir("packages", [ |
176 dir("myapp", [ | 160 dir("myapp", [ |
177 file('foo.dart', 'main() => "foo";') | 161 file('foo.dart', 'main() => "foo";') |
178 ]) | 162 ]) |
179 ]), | 163 ]), |
180 dir("subexample", [ | 164 dir("subexample", [ |
181 dir("packages", [ | 165 dir("packages", [ |
182 dir("myapp", [ | 166 dir("myapp", [ |
183 file('foo.dart', 'main() => "foo";') | 167 file('foo.dart', 'main() => "foo";') |
184 ]) | 168 ]) |
185 ]) | 169 ]) |
186 ]) | 170 ]) |
187 ]) | 171 ]) |
188 ]).scheduleValidate(); | 172 ]).scheduleValidate(); |
189 | |
190 run(); | |
191 }); | 173 }); |
192 | 174 |
193 test('"tool/" and its subdirectories', () { | 175 integration('"tool/" and its subdirectories', () { |
194 dir(appPath, [ | 176 dir(appPath, [ |
195 appPubspec([]), | 177 appPubspec([]), |
196 libDir('foo'), | 178 libDir('foo'), |
197 dir("tool", [dir("subtool")]) | 179 dir("tool", [dir("subtool")]) |
198 ]).scheduleCreate(); | 180 ]).scheduleCreate(); |
199 | 181 |
200 schedulePub(args: ['install'], | 182 schedulePub(args: ['install'], |
201 output: new RegExp(r"Dependencies installed!$")); | 183 output: new RegExp(r"Dependencies installed!$")); |
202 | 184 |
203 dir(appPath, [ | 185 dir(appPath, [ |
204 dir("tool", [ | 186 dir("tool", [ |
205 dir("packages", [ | 187 dir("packages", [ |
206 dir("myapp", [ | 188 dir("myapp", [ |
207 file('foo.dart', 'main() => "foo";') | 189 file('foo.dart', 'main() => "foo";') |
208 ]) | 190 ]) |
209 ]), | 191 ]), |
210 dir("subtool", [ | 192 dir("subtool", [ |
211 dir("packages", [ | 193 dir("packages", [ |
212 dir("myapp", [ | 194 dir("myapp", [ |
213 file('foo.dart', 'main() => "foo";') | 195 file('foo.dart', 'main() => "foo";') |
214 ]) | 196 ]) |
215 ]) | 197 ]) |
216 ]) | 198 ]) |
217 ]) | 199 ]) |
218 ]).scheduleValidate(); | 200 ]).scheduleValidate(); |
219 | |
220 run(); | |
221 }); | 201 }); |
222 | 202 |
223 test('"web/" and its subdirectories', () { | 203 integration('"web/" and its subdirectories', () { |
224 dir(appPath, [ | 204 dir(appPath, [ |
225 appPubspec([]), | 205 appPubspec([]), |
226 libDir('foo'), | 206 libDir('foo'), |
227 dir("web", [dir("subweb")]) | 207 dir("web", [dir("subweb")]) |
228 ]).scheduleCreate(); | 208 ]).scheduleCreate(); |
229 | 209 |
230 schedulePub(args: ['install'], | 210 schedulePub(args: ['install'], |
231 output: new RegExp(r"Dependencies installed!$")); | 211 output: new RegExp(r"Dependencies installed!$")); |
232 | 212 |
233 dir(appPath, [ | 213 dir(appPath, [ |
234 dir("web", [ | 214 dir("web", [ |
235 dir("packages", [ | 215 dir("packages", [ |
236 dir("myapp", [ | 216 dir("myapp", [ |
237 file('foo.dart', 'main() => "foo";') | 217 file('foo.dart', 'main() => "foo";') |
238 ]) | 218 ]) |
239 ]), | 219 ]), |
240 dir("subweb", [ | 220 dir("subweb", [ |
241 dir("packages", [ | 221 dir("packages", [ |
242 dir("myapp", [ | 222 dir("myapp", [ |
243 file('foo.dart', 'main() => "foo";') | 223 file('foo.dart', 'main() => "foo";') |
244 ]) | 224 ]) |
245 ]) | 225 ]) |
246 ]) | 226 ]) |
247 ]) | 227 ]) |
248 ]).scheduleValidate(); | 228 ]).scheduleValidate(); |
249 | |
250 run(); | |
251 }); | 229 }); |
252 | 230 |
253 test('"bin/"', () { | 231 integration('"bin/"', () { |
254 dir(appPath, [ | 232 dir(appPath, [ |
255 appPubspec([]), | 233 appPubspec([]), |
256 libDir('foo'), | 234 libDir('foo'), |
257 dir("bin") | 235 dir("bin") |
258 ]).scheduleCreate(); | 236 ]).scheduleCreate(); |
259 | 237 |
260 schedulePub(args: ['install'], | 238 schedulePub(args: ['install'], |
261 output: new RegExp(r"Dependencies installed!$")); | 239 output: new RegExp(r"Dependencies installed!$")); |
262 | 240 |
263 dir(appPath, [ | 241 dir(appPath, [ |
264 dir("bin", [ | 242 dir("bin", [ |
265 dir("packages", [ | 243 dir("packages", [ |
266 dir("myapp", [ | 244 dir("myapp", [ |
267 file('foo.dart', 'main() => "foo";') | 245 file('foo.dart', 'main() => "foo";') |
268 ]) | 246 ]) |
269 ]) | 247 ]) |
270 ]) | 248 ]) |
271 ]).scheduleValidate(); | 249 ]).scheduleValidate(); |
272 | |
273 run(); | |
274 }); | 250 }); |
275 }); | 251 }); |
276 } | 252 } |
OLD | NEW |