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