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