Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: pkg/barback/test/package_graph/errors_test.dart

Issue 195993005: Don't pass an asset through a transformer that produces an error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: move more tests into collisions_test Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/barback/test/package_graph/collisions_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 barback.test.package_graph.source_test; 5 library barback.test.package_graph.source_test;
6 6
7 import 'package:barback/src/utils.dart'; 7 import 'package:barback/src/utils.dart';
8 import 'package:scheduled_test/scheduled_test.dart'; 8 import 'package:scheduled_test/scheduled_test.dart';
9 9
10 import '../utils.dart'; 10 import '../utils.dart';
11 11
12 main() { 12 main() {
13 initConfig(); 13 initConfig();
14 14
15 test("errors if two transformers output the same file", () {
16 initGraph(["app|foo.a"], {"app": [
17 [
18 new RewriteTransformer("a", "b"),
19 new RewriteTransformer("a", "b")
20 ]
21 ]});
22 updateSources(["app|foo.a"]);
23
24 buildShouldFail([isAssetCollisionException("app|foo.b")]);
25 });
26
27 test("errors if a new transformer outputs the same file as an old "
28 "transformer", () {
29 initGraph(["app|foo.a", "app|foo.b"], {"app": [
30 [
31 new RewriteTransformer("a", "c"),
32 new RewriteTransformer("b", "c")
33 ]
34 ]});
35 updateSources(["app|foo.a"]);
36 expectAsset("app|foo.c", "foo.c");
37 buildShouldSucceed();
38
39 updateSources(["app|foo.b"]);
40 buildShouldFail([isAssetCollisionException("app|foo.c")]);
41 });
42
43 test("does not report asset not found errors in results", () { 15 test("does not report asset not found errors in results", () {
44 initGraph(["app|bar.txt"]); 16 initGraph(["app|bar.txt"]);
45 17
46 // Trigger a build. 18 // Trigger a build.
47 updateSources(["app|bar.txt"]); 19 updateSources(["app|bar.txt"]);
48 20
49 expectNoAsset("app|foo.txt"); 21 expectNoAsset("app|foo.txt");
50 buildShouldSucceed(); 22 buildShouldSucceed();
51 }); 23 });
52 24
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 ]}); 138 ]});
167 139
168 setAssetError("app|foo.txt"); 140 setAssetError("app|foo.txt");
169 updateSources(["app|foo.txt"]); 141 updateSources(["app|foo.txt"]);
170 expectNoAsset("app|foo.txt"); 142 expectNoAsset("app|foo.txt");
171 buildShouldFail([ 143 buildShouldFail([
172 isAssetLoadException("app|foo.txt", isMockLoadException("app|foo.txt")) 144 isAssetLoadException("app|foo.txt", isMockLoadException("app|foo.txt"))
173 ]); 145 ]);
174 }); 146 });
175 147
176 test("a collision returns the first-produced output", () { 148 test("an asset isn't passed through a transformer with an error", () {
177 var rewrite1 = new RewriteTransformer("one", "out"); 149 initGraph(["app|foo.txt",], {"app": [[new BadTransformer([])]]});
178 var rewrite2 = new RewriteTransformer("two", "out");
179 initGraph({
180 "app|foo.one": "one",
181 "app|foo.two": "two"
182 }, {"app": [[rewrite1, rewrite2]]});
183
184 rewrite1.pauseApply();
185 updateSources(["app|foo.one", "app|foo.two"]);
186 // Wait long enough to ensure that rewrite2 has completed.
187 schedule(pumpEventQueue);
188
189 rewrite1.resumeApply();
190 expectAsset("app|foo.out", "two.out");
191 buildShouldFail([isAssetCollisionException("app|foo.out")]);
192
193 // Even after the collision is discovered, the first-produced output should
194 // be returned.
195 expectAsset("app|foo.out", "two.out");
196
197 // Even if the other output is updated more recently, the first output
198 // should continue to take precedence.
199 updateSources(["app|foo.one"]);
200 expectAsset("app|foo.out", "two.out");
201 });
202
203 test("a collision that is later resolved produces an output", () {
204 initGraph({
205 "app|foo.one": "one",
206 "app|foo.two": "two"
207 }, {"app": [
208 [
209 new RewriteTransformer("one", "out"),
210 new RewriteTransformer("two", "out")
211 ]
212 ]});
213
214 updateSources(["app|foo.one"]);
215 expectAsset("app|foo.out", "one.out");
216 buildShouldSucceed();
217
218 updateSources(["app|foo.two"]);
219 expectAsset("app|foo.out", "one.out");
220 buildShouldFail([isAssetCollisionException("app|foo.out")]);
221
222 removeSources(["app|foo.one"]);
223 expectAsset("app|foo.out", "two.out");
224 buildShouldSucceed();
225 });
226
227 test("a collision that is later resolved runs transforms", () {
228 initGraph({
229 "app|foo.one": "one",
230 "app|foo.two": "two"
231 }, {"app": [
232 [
233 new RewriteTransformer("one", "mid"),
234 new RewriteTransformer("two", "mid")
235 ],
236 [new RewriteTransformer("mid", "out")]
237 ]});
238
239 updateSources(["app|foo.one"]);
240 expectAsset("app|foo.out", "one.mid.out");
241 buildShouldSucceed();
242
243 updateSources(["app|foo.two"]);
244 expectAsset("app|foo.out", "one.mid.out");
245 buildShouldFail([isAssetCollisionException("app|foo.mid")]);
246
247 removeSources(["app|foo.one"]);
248 expectAsset("app|foo.out", "two.mid.out");
249 buildShouldSucceed();
250 });
251
252 test("a collision that is partially resolved returns the second completed "
253 "output", () {
254 var rewrite1 = new RewriteTransformer("one", "out");
255 var rewrite2 = new RewriteTransformer("two", "out");
256 var rewrite3 = new RewriteTransformer("three", "out");
257 initGraph({
258 "app|foo.one": "one",
259 "app|foo.two": "two",
260 "app|foo.three": "three"
261 }, {"app": [[rewrite1, rewrite2, rewrite3]]});
262
263 // Make rewrite3 the most-recently-completed transformer from the first run.
264 rewrite2.pauseApply();
265 rewrite3.pauseApply();
266 updateSources(["app|foo.one", "app|foo.two", "app|foo.three"]);
267 schedule(pumpEventQueue);
268 rewrite2.resumeApply();
269 schedule(pumpEventQueue);
270 rewrite3.resumeApply();
271 buildShouldFail([
272 isAssetCollisionException("app|foo.out"),
273 isAssetCollisionException("app|foo.out")
274 ]);
275
276 // Then update rewrite3 in a separate build. rewrite2 should still be the
277 // next version of foo.out in line.
278 // TODO(nweiz): Should this emit a collision error as well? Or should they
279 // only be emitted when a file is added or removed?
280 updateSources(["app|foo.three"]);
281 buildShouldSucceed();
282
283 removeSources(["app|foo.one"]);
284 expectAsset("app|foo.out", "two.out");
285 buildShouldFail([isAssetCollisionException("app|foo.out")]);
286 });
287
288 test("a collision with a pass-through asset returns the pass-through asset",
289 () {
290 initGraph([
291 "app|foo.txt",
292 "app|foo.in"
293 ], {"app": [
294 [new RewriteTransformer("in", "txt")]
295 ]});
296
297 updateSources(["app|foo.txt", "app|foo.in"]);
298 expectAsset("app|foo.txt", "foo");
299 buildShouldFail([isAssetCollisionException("app|foo.txt")]);
300 });
301
302 test("a new pass-through asset that collides returns the previous asset", () {
303 initGraph([
304 "app|foo.txt",
305 "app|foo.in"
306 ], {"app": [
307 [new RewriteTransformer("in", "txt")]
308 ]});
309
310 updateSources(["app|foo.in"]);
311 expectAsset("app|foo.txt", "foo.txt");
312 buildShouldSucceed();
313 150
314 updateSources(["app|foo.txt"]); 151 updateSources(["app|foo.txt"]);
315 expectAsset("app|foo.txt", "foo.txt"); 152 expectNoAsset("app|foo.txt");
316 buildShouldFail([isAssetCollisionException("app|foo.txt")]); 153 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
317 });
318
319 test("a new transform output that collides with a pass-through asset returns "
320 "the pass-through asset", () {
321 initGraph([
322 "app|foo.txt",
323 "app|foo.in"
324 ], {"app": [
325 [new RewriteTransformer("in", "txt")]
326 ]});
327
328 updateSources(["app|foo.txt"]);
329 expectAsset("app|foo.txt", "foo");
330 buildShouldSucceed();
331
332 updateSources(["app|foo.in"]);
333 expectAsset("app|foo.txt", "foo");
334 buildShouldFail([isAssetCollisionException("app|foo.txt")]);
335 }); 154 });
336 } 155 }
OLDNEW
« no previous file with comments | « pkg/barback/test/package_graph/collisions_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698