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('dart:io'); | |
8 | |
9 #import('test_pub.dart'); | |
10 #import('../../../pkg/unittest/unittest.dart'); | |
11 | |
12 main() { | |
13 test("updates locked Git packages", () { | |
14 ensureGit(); | |
15 | |
16 git('foo.git', [ | |
17 libDir('foo'), | |
18 libPubspec('foo', '1.0.0') | |
19 ]).scheduleCreate(); | |
20 | |
21 git('bar.git', [ | |
22 libDir('bar'), | |
23 libPubspec('bar', '1.0.0') | |
24 ]).scheduleCreate(); | |
25 | |
26 appDir([{"git": "../foo.git"}, {"git": "../bar.git"}]).scheduleCreate(); | |
27 | |
28 schedulePub(args: ['install'], | |
29 output: const RegExp(r"Dependencies installed!$")); | |
30 | |
31 dir(packagesPath, [ | |
32 dir('foo', [ | |
33 file('foo.dart', 'main() => "foo";') | |
34 ]), | |
35 dir('bar', [ | |
36 file('bar.dart', 'main() => "bar";') | |
37 ]) | |
38 ]).scheduleValidate(); | |
39 | |
40 git('foo.git', [ | |
41 libDir('foo', 'foo 2'), | |
42 libPubspec('foo', '1.0.0') | |
43 ]).scheduleCommit(); | |
44 | |
45 git('bar.git', [ | |
46 libDir('bar', 'bar 2'), | |
47 libPubspec('bar', '1.0.0') | |
48 ]).scheduleCommit(); | |
49 | |
50 schedulePub(args: ['update'], | |
51 output: const RegExp(r"Dependencies updated!$")); | |
52 | |
53 dir(packagesPath, [ | |
54 dir('foo', [ | |
55 file('foo.dart', 'main() => "foo 2";') | |
56 ]), | |
57 dir('bar', [ | |
58 file('bar.dart', 'main() => "bar 2";') | |
59 ]) | |
60 ]).scheduleValidate(); | |
61 | |
62 run(); | |
63 }); | |
64 | |
65 test("updates Git packages to an incompatible pubspec", () { | |
66 ensureGit(); | |
67 | |
68 git('foo.git', [ | |
69 libDir('foo'), | |
70 libPubspec('foo', '1.0.0') | |
71 ]).scheduleCreate(); | |
72 | |
73 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
74 | |
75 schedulePub(args: ['install'], | |
76 output: const RegExp(r"Dependencies installed!$")); | |
77 | |
78 dir(packagesPath, [ | |
79 dir('foo', [ | |
80 file('foo.dart', 'main() => "foo";') | |
81 ]) | |
82 ]).scheduleValidate(); | |
83 | |
84 git('foo.git', [ | |
85 libDir('zoo'), | |
86 libPubspec('zoo', '1.0.0') | |
87 ]).scheduleCommit(); | |
88 | |
89 schedulePub(args: ['update'], | |
90 error: const RegExp(r'The name you specified for your dependency, ' | |
91 r'"foo", doesn' "'" r't match the name "zoo" in its pubspec.'), | |
92 exitCode: 1); | |
93 | |
94 dir(packagesPath, [ | |
95 dir('foo', [ | |
96 file('foo.dart', 'main() => "foo";') | |
97 ]) | |
98 ]).scheduleValidate(); | |
99 | |
100 run(); | |
101 }); | |
102 | |
103 solo_test("updates Git packages to a nonexistent pubspec", () { | |
104 ensureGit(); | |
105 | |
106 var repo = git('foo.git', [ | |
107 libDir('foo'), | |
108 libPubspec('foo', '1.0.0') | |
109 ]); | |
110 repo.scheduleCreate(); | |
111 | |
112 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
113 | |
114 schedulePub(args: ['install'], | |
115 output: const RegExp(r"Dependencies installed!$")); | |
116 | |
117 dir(packagesPath, [ | |
118 dir('foo', [ | |
119 file('foo.dart', 'main() => "foo";') | |
120 ]) | |
121 ]).scheduleValidate(); | |
122 | |
123 repo.scheduleGit(['rm', 'pubspec.yaml']); | |
124 repo.scheduleGit(['commit', '-m', 'delete']); | |
125 | |
126 schedulePub(args: ['update'], | |
127 error: const RegExp(r'Package "foo" doesn' "'" r't have a ' | |
128 r'pubspec.yaml file.'), | |
129 exitCode: 1); | |
130 | |
131 dir(packagesPath, [ | |
132 dir('foo', [ | |
133 file('foo.dart', 'main() => "foo";') | |
134 ]) | |
135 ]).scheduleValidate(); | |
136 | |
137 run(); | |
138 }); | |
139 | |
140 group("with an argument", () { | |
141 test("updates one locked Git package but no others", () { | |
142 ensureGit(); | |
143 | |
144 git('foo.git', [ | |
145 libDir('foo'), | |
146 libPubspec('foo', '1.0.0') | |
147 ]).scheduleCreate(); | |
148 | |
149 git('bar.git', [ | |
150 libDir('bar'), | |
151 libPubspec('bar', '1.0.0') | |
152 ]).scheduleCreate(); | |
153 | |
154 appDir([{"git": "../foo.git"}, {"git": "../bar.git"}]).scheduleCreate(); | |
155 | |
156 schedulePub(args: ['install'], | |
157 output: const RegExp(r"Dependencies installed!$")); | |
158 | |
159 dir(packagesPath, [ | |
160 dir('foo', [ | |
161 file('foo.dart', 'main() => "foo";') | |
162 ]), | |
163 dir('bar', [ | |
164 file('bar.dart', 'main() => "bar";') | |
165 ]) | |
166 ]).scheduleValidate(); | |
167 | |
168 git('foo.git', [ | |
169 libDir('foo', 'foo 2'), | |
170 libPubspec('foo', '1.0.0') | |
171 ]).scheduleCommit(); | |
172 | |
173 git('bar.git', [ | |
174 libDir('bar', 'bar 2'), | |
175 libPubspec('bar', '1.0.0') | |
176 ]).scheduleCommit(); | |
177 | |
178 schedulePub(args: ['update', 'foo'], | |
179 output: const RegExp(r"Dependencies updated!$")); | |
180 | |
181 dir(packagesPath, [ | |
182 dir('foo', [ | |
183 file('foo.dart', 'main() => "foo 2";') | |
184 ]), | |
185 dir('bar', [ | |
186 file('bar.dart', 'main() => "bar";') | |
187 ]) | |
188 ]).scheduleValidate(); | |
189 | |
190 run(); | |
191 }); | |
192 | |
193 test("doesn't update one locked Git package's dependencies if it's not " | |
194 "necessary", () { | |
195 ensureGit(); | |
196 | |
197 git('foo.git', [ | |
198 libDir('foo'), | |
199 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}]) | |
200 ]).scheduleCreate(); | |
201 | |
202 git('foo-dep.git', [ | |
203 libDir('foo-dep'), | |
204 libPubspec('foo-dep', '1.0.0') | |
205 ]).scheduleCreate(); | |
206 | |
207 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
208 | |
209 schedulePub(args: ['install'], | |
210 output: const RegExp(r"Dependencies installed!$")); | |
211 | |
212 dir(packagesPath, [ | |
213 dir('foo', [ | |
214 file('foo.dart', 'main() => "foo";') | |
215 ]), | |
216 dir('foo-dep', [ | |
217 file('foo-dep.dart', 'main() => "foo-dep";') | |
218 ]) | |
219 ]).scheduleValidate(); | |
220 | |
221 git('foo.git', [ | |
222 libDir('foo', 'foo 2'), | |
223 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}]) | |
224 ]).scheduleCreate(); | |
225 | |
226 git('foo-dep.git', [ | |
227 libDir('foo-dep', 'foo-dep 2'), | |
228 libPubspec('foo-dep', '1.0.0') | |
229 ]).scheduleCommit(); | |
230 | |
231 schedulePub(args: ['update', 'foo'], | |
232 output: const RegExp(r"Dependencies updated!$")); | |
233 | |
234 dir(packagesPath, [ | |
235 dir('foo', [ | |
236 file('foo.dart', 'main() => "foo 2";') | |
237 ]), | |
238 dir('foo-dep', [ | |
239 file('foo-dep.dart', 'main() => "foo-dep";') | |
240 ]), | |
241 ]).scheduleValidate(); | |
242 | |
243 run(); | |
244 }); | |
245 }); | |
246 } | |
OLD | NEW |