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

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

Issue 183993003: Revert commits r33138, r33135, and r33134. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/pubspec.yaml ('k') | pkg/barback/test/package_graph/errors_test.dart » ('j') | 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.transform_test; 5 library barback.test.package_graph.transform_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 test("a new transformer is applied to a matching asset", () { 14 test("a new transformer is applied to a matching asset", () {
15 initGraph(["app|foo.blub"]); 15 initGraph(["app|foo.blub"]);
16 16
17 updateSources(["app|foo.blub"]); 17 updateSources(["app|foo.blub"]);
18 expectAsset("app|foo.blub", "foo"); 18 expectAsset("app|foo.blub", "foo");
19 buildShouldSucceed(); 19 buildShouldSucceed();
20 20
21 updateTransformers("app", [[new RewriteTransformer("blub", "blab")]]); 21 updateTransformers("app", [[new RewriteTransformer("blub", "blab")]]);
22 expectAsset("app|foo.blab", "foo.blab"); 22 expectAsset("app|foo.blab", "foo.blab");
23 expectNoAsset("app|foo.blub");
23 buildShouldSucceed(); 24 buildShouldSucceed();
24 }); 25 });
25 26
26 test("a new transformer is not applied to a non-matching asset", () { 27 test("a new transformer is not applied to a non-matching asset", () {
27 initGraph(["app|foo.blub"]); 28 initGraph(["app|foo.blub"]);
28 29
29 updateSources(["app|foo.blub"]); 30 updateSources(["app|foo.blub"]);
30 expectAsset("app|foo.blub", "foo"); 31 expectAsset("app|foo.blub", "foo");
31 buildShouldSucceed(); 32 buildShouldSucceed();
32 33
33 updateTransformers("app", [[new RewriteTransformer("zip", "zap")]]); 34 updateTransformers("app", [[new RewriteTransformer("zip", "zap")]]);
34 expectAsset("app|foo.blub", "foo"); 35 expectAsset("app|foo.blub", "foo");
35 expectNoAsset("app|foo.zap"); 36 expectNoAsset("app|foo.zap");
36 buildShouldSucceed(); 37 buildShouldSucceed();
37 }); 38 });
38 39
39 test("updateTransformers doesn't re-run an old transformer", () { 40 test("updateTransformers doesn't re-run an old transformer", () {
40 var rewrite = new RewriteTransformer("blub", "blab"); 41 var rewrite = new RewriteTransformer("blub", "blab");
41 initGraph(["app|foo.blub"], {"app": [[rewrite]]}); 42 initGraph(["app|foo.blub"], {"app": [[rewrite]]});
42 43
43 updateSources(["app|foo.blub"]); 44 updateSources(["app|foo.blub"]);
44 expectAsset("app|foo.blab", "foo.blab"); 45 expectAsset("app|foo.blab", "foo.blab");
46 expectNoAsset("app|foo.blub");
45 buildShouldSucceed(); 47 buildShouldSucceed();
46 48
47 updateTransformers("app", [[rewrite]]); 49 updateTransformers("app", [[rewrite]]);
48 expectAsset("app|foo.blab", "foo.blab"); 50 expectAsset("app|foo.blab", "foo.blab");
51 expectNoAsset("app|foo.blub");
49 buildShouldSucceed(); 52 buildShouldSucceed();
50 53
51 expect(rewrite.numRuns, completion(equals(1))); 54 expect(rewrite.numRuns, completion(equals(1)));
52 }); 55 });
53 56
54 test("updateTransformers re-runs old transformers in a new phase", () { 57 test("updateTransformers re-runs old transformers in a new phase", () {
55 var rewrite1 = new RewriteTransformer("txt", "blub"); 58 var rewrite1 = new RewriteTransformer("txt", "blub");
56 var rewrite2 = new RewriteTransformer("blub", "blab"); 59 var rewrite2 = new RewriteTransformer("blub", "blab");
57 initGraph(["app|foo.txt"], {"app": [[rewrite1], [rewrite2]]}); 60 initGraph(["app|foo.txt"], {"app": [[rewrite1], [rewrite2]]});
58 61
59 updateSources(["app|foo.txt"]); 62 updateSources(["app|foo.txt"]);
60 expectAsset("app|foo.blab", "foo.blub.blab"); 63 expectAsset("app|foo.blab", "foo.blub.blab");
64 expectNoAsset("app|foo.blub");
61 buildShouldSucceed(); 65 buildShouldSucceed();
62 66
63 updateTransformers("app", [[rewrite2], [rewrite1]]); 67 updateTransformers("app", [[rewrite2], [rewrite1]]);
64 expectAsset("app|foo.blub", "foo.blub"); 68 expectAsset("app|foo.blub", "foo.blub");
65 expectNoAsset("app|foo.blab"); 69 expectNoAsset("app|foo.blab");
66 buildShouldSucceed(); 70 buildShouldSucceed();
67 }); 71 });
68 72
69 test("updateTransformers re-runs an old transformer when a previous phase " 73 test("updateTransformers re-runs an old transformer when a previous phase "
70 "changes", () { 74 "changes", () {
(...skipping 12 matching lines...) Expand all
83 buildShouldSucceed(); 87 buildShouldSucceed();
84 }); 88 });
85 89
86 test("a removed transformer is no longer applied", () { 90 test("a removed transformer is no longer applied", () {
87 initGraph(["app|foo.blub"], {"app": [ 91 initGraph(["app|foo.blub"], {"app": [
88 [new RewriteTransformer("blub", "blab")] 92 [new RewriteTransformer("blub", "blab")]
89 ]}); 93 ]});
90 94
91 updateSources(["app|foo.blub"]); 95 updateSources(["app|foo.blub"]);
92 expectAsset("app|foo.blab", "foo.blab"); 96 expectAsset("app|foo.blab", "foo.blab");
97 expectNoAsset("app|foo.blub");
93 buildShouldSucceed(); 98 buildShouldSucceed();
94 99
95 updateTransformers("app", []); 100 updateTransformers("app", []);
96 expectAsset("app|foo.blub", "foo"); 101 expectAsset("app|foo.blub", "foo");
97 expectNoAsset("app|foo.blab"); 102 expectNoAsset("app|foo.blab");
98 buildShouldSucceed(); 103 buildShouldSucceed();
99 }); 104 });
100 105
101 test("a new transformer is pipelined", () { 106 test("a new transformer is pipelined", () {
102 var rewrite1 = new RewriteTransformer("source", "phase1"); 107 var rewrite1 = new RewriteTransformer("source", "phase1");
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 185
181 updateTransformers("app", [ 186 updateTransformers("app", [
182 [rewrite, new RewriteTransformer("blib", "blob")] 187 [rewrite, new RewriteTransformer("blib", "blob")]
183 ]); 188 ]);
184 rewrite.resumeIsPrimary("app|foo.blub"); 189 rewrite.resumeIsPrimary("app|foo.blub");
185 expectAsset("app|foo.blab", "foo.blab"); 190 expectAsset("app|foo.blab", "foo.blab");
186 expectAsset("app|bar.blob", "bar.blob"); 191 expectAsset("app|bar.blob", "bar.blob");
187 buildShouldSucceed(); 192 buildShouldSucceed();
188 }); 193 });
189 194
195 test("a new transformer can see pass-through assets", () {
196 var rewrite = new RewriteTransformer("zip", "zap");
197 initGraph(["app|foo.blub"], {"app": [[rewrite]]});
198
199 updateSources(["app|foo.blub"]);
200 buildShouldSucceed();
201
202 updateTransformers("app", [
203 [rewrite],
204 [new RewriteTransformer("blub", "blab")]
205 ]);
206 expectAsset("app|foo.blab", "foo.blab");
207 expectNoAsset("app|foo.blub");
208 buildShouldSucceed();
209 });
210
190 test("a cross-package transform sees a new transformer in a new phase", () { 211 test("a cross-package transform sees a new transformer in a new phase", () {
191 var rewrite = new RewriteTransformer("inc", "inc"); 212 var rewrite = new RewriteTransformer("inc", "inc");
192 initGraph({ 213 initGraph({
193 "pkg1|foo.txt": "pkg2|foo.inc", 214 "pkg1|foo.txt": "pkg2|foo.inc",
194 "pkg2|foo.inc": "foo" 215 "pkg2|foo.inc": "foo"
195 }, { 216 }, {
196 "pkg1": [[new ManyToOneTransformer("txt")]], 217 "pkg1": [[new ManyToOneTransformer("txt")]],
197 "pkg2": [[rewrite]] 218 "pkg2": [[rewrite]]
198 }); 219 });
199 220
(...skipping 25 matching lines...) Expand all
225 246
226 updateSources(["pkg1|foo.txt", "pkg2|foo.inc"]); 247 updateSources(["pkg1|foo.txt", "pkg2|foo.inc"]);
227 expectAsset("pkg1|foo.out", "foo.inc.inc"); 248 expectAsset("pkg1|foo.out", "foo.inc.inc");
228 buildShouldSucceed(); 249 buildShouldSucceed();
229 250
230 updateTransformers("pkg2", [[rewrite]]); 251 updateTransformers("pkg2", [[rewrite]]);
231 expectAsset("pkg1|foo.out", "foo.inc"); 252 expectAsset("pkg1|foo.out", "foo.inc");
232 buildShouldSucceed(); 253 buildShouldSucceed();
233 }); 254 });
234 255
235 group("pass-through", () {
236 test("a new transformer can see pass-through assets", () {
237 var rewrite = new RewriteTransformer("zip", "zap");
238 initGraph(["app|foo.blub"], {"app": [[rewrite]]});
239
240 updateSources(["app|foo.blub"]);
241 buildShouldSucceed();
242
243 updateTransformers("app", [
244 [rewrite],
245 [new RewriteTransformer("blub", "blab")]
246 ]);
247 expectAsset("app|foo.blab", "foo.blab");
248 buildShouldSucceed();
249 });
250
251 test("a new transformer can overwrite an old asset", () {
252 var rewrite = new RewriteTransformer("zip", "zap");
253 initGraph(["app|foo.txt"], {"app": [[rewrite]]});
254
255 updateSources(["app|foo.txt"]);
256 expectAsset("app|foo.txt", "foo");
257 buildShouldSucceed();
258
259 // Add a transformer that will overwrite the previously-passed-through
260 // "foo.txt" asset. The transformed asset should be emitted, not the
261 // passed-through asset.
262 updateTransformers("app", [
263 [rewrite, new RewriteTransformer("txt", "txt")]
264 ]);
265 expectAsset("app|foo.txt", "foo.txt");
266 buildShouldSucceed();
267 });
268
269 test("passes an asset through when an overwriting transform is removed",
270 () {
271 initGraph(["app|foo.txt"], {
272 "app": [[new RewriteTransformer("txt", "txt")]]
273 });
274
275 updateSources(["app|foo.txt"]);
276 expectAsset("app|foo.txt", "foo.txt");
277 buildShouldSucceed();
278
279 updateTransformers("app", [[]]);
280 expectAsset("app|foo.txt", "foo");
281 buildShouldSucceed();
282 });
283
284 test("passes an asset through when its overwriting transform is removed "
285 "during apply", () {
286 var rewrite = new RewriteTransformer("txt", "txt");
287 initGraph(["app|foo.txt"], {"app": [[rewrite]]});
288
289 rewrite.pauseApply();
290 updateSources(["app|foo.txt"]);
291 expectAssetDoesNotComplete("app|foo.txt");
292
293 updateTransformers("app", [[]]);
294 rewrite.resumeApply();
295 expectAsset("app|foo.txt", "foo");
296 buildShouldSucceed();
297 });
298
299 test("doesn't pass an asset through when its overwriting transform is "
300 "removed during apply if another transform overwrites it", () {
301 var rewrite1 = new RewriteTransformer("txt", "txt");
302 var rewrite2 = new RewriteTransformer("txt", "txt");
303 initGraph(["app|foo.txt"], {"app": [[rewrite1, rewrite2]]});
304
305 rewrite1.pauseApply();
306 updateSources(["app|foo.txt"]);
307 expectAssetDoesNotComplete("app|foo.txt");
308 // Ensure we're waiting on [rewrite1.apply]
309 schedule(pumpEventQueue);
310
311 updateTransformers("app", [[rewrite2]]);
312 rewrite1.resumeApply();
313 expectAsset("app|foo.txt", "foo.txt");
314 buildShouldSucceed();
315 });
316
317 test("doesn't pass an asset through when one overwriting transform is "
318 "removed if another transform still overwrites it", () {
319 var rewrite = new RewriteTransformer("txt", "txt");
320 initGraph(["app|foo.txt"], {"app": [[
321 rewrite,
322 new RewriteTransformer("txt", "txt")
323 ]]});
324
325 updateSources(["app|foo.txt"]);
326 // This could be either the output of [CheckContentTransformer] or
327 // [RewriteTransformer], depending which completes first.
328 expectAsset("app|foo.txt", anything);
329 buildShouldFail([isAssetCollisionException("app|foo.txt")]);
330
331 updateTransformers("app", [[rewrite]]);
332 expectAsset("app|foo.txt", "foo.txt");
333 buildShouldSucceed();
334 });
335 });
336
337 // Regression test. 256 // Regression test.
338 test("a phase is added, then an input is removed and re-added", () { 257 test("a phase is added, then an input is removed and re-added", () {
339 var rewrite = new RewriteTransformer("txt", "mid"); 258 var rewrite = new RewriteTransformer("txt", "mid");
340 initGraph(["app|foo.txt"], { 259 initGraph(["app|foo.txt"], {
341 "app": [[rewrite]] 260 "app": [[rewrite]]
342 }); 261 });
343 262
344 updateSources(["app|foo.txt"]); 263 updateSources(["app|foo.txt"]);
345 expectAsset("app|foo.mid", "foo.mid"); 264 expectAsset("app|foo.mid", "foo.mid");
346 buildShouldSucceed(); 265 buildShouldSucceed();
347 266
348 updateTransformers("app", [ 267 updateTransformers("app", [
349 [rewrite], 268 [rewrite],
350 [new RewriteTransformer("mid", "out")] 269 [new RewriteTransformer("mid", "out")]
351 ]); 270 ]);
352 expectAsset("app|foo.out", "foo.mid.out"); 271 expectAsset("app|foo.out", "foo.mid.out");
353 buildShouldSucceed(); 272 buildShouldSucceed();
354 273
355 removeSources(["app|foo.txt"]); 274 removeSources(["app|foo.txt"]);
356 expectNoAsset("app|foo.out"); 275 expectNoAsset("app|foo.out");
357 buildShouldSucceed(); 276 buildShouldSucceed();
358 277
359 updateSources(["app|foo.txt"]); 278 updateSources(["app|foo.txt"]);
360 expectAsset("app|foo.out", "foo.mid.out"); 279 expectAsset("app|foo.out", "foo.mid.out");
361 buildShouldSucceed(); 280 buildShouldSucceed();
362 }); 281 });
363 } 282 }
OLDNEW
« no previous file with comments | « pkg/barback/pubspec.yaml ('k') | pkg/barback/test/package_graph/errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698