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

Side by Side Diff: packages/barback/test/package_graph/transform/transform_test.dart

Issue 3014633002: Roll to pickup pool changes (Closed)
Patch Set: Created 3 years, 2 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This library contains tests for transformer behavior that relates to actions 5 // This library contains tests for transformer behavior that relates to actions
6 // happening concurrently or other complex asynchronous timing behavior. 6 // happening concurrently or other complex asynchronous timing behavior.
7 library barback.test.package_graph.transform.transform_test; 7 library barback.test.package_graph.transform.transform_test;
8 8
9 import 'package:barback/src/utils.dart';
10 import 'package:scheduled_test/scheduled_test.dart'; 9 import 'package:scheduled_test/scheduled_test.dart';
11 10
12 import '../../utils.dart'; 11 import '../../utils.dart';
13 12
14 main() { 13 main() {
15 initConfig(); 14 initConfig();
16 test("gets a transformed asset with a different path", () { 15 test("gets a transformed asset with a different path", () {
17 initGraph(["app|foo.blub"], {"app": [ 16 initGraph([
18 [new RewriteTransformer("blub", "blab")] 17 "app|foo.blub"
19 ]}); 18 ], {
19 "app": [
20 [new RewriteTransformer("blub", "blab")]
21 ]
22 });
20 updateSources(["app|foo.blub"]); 23 updateSources(["app|foo.blub"]);
21 expectAsset("app|foo.blab", "foo.blab"); 24 expectAsset("app|foo.blab", "foo.blab");
22 buildShouldSucceed(); 25 buildShouldSucceed();
23 }); 26 });
24 27
25 test("gets a transformed asset with the same path", () { 28 test("gets a transformed asset with the same path", () {
26 initGraph(["app|foo.blub"], {"app": [ 29 initGraph([
27 [new RewriteTransformer("blub", "blub")] 30 "app|foo.blub"
28 ]}); 31 ], {
32 "app": [
33 [new RewriteTransformer("blub", "blub")]
34 ]
35 });
29 updateSources(["app|foo.blub"]); 36 updateSources(["app|foo.blub"]);
30 expectAsset("app|foo.blub", "foo.blub"); 37 expectAsset("app|foo.blub", "foo.blub");
31 buildShouldSucceed(); 38 buildShouldSucceed();
32 }); 39 });
33 40
34 test("doesn't find an output from a later phase", () { 41 test("doesn't find an output from a later phase", () {
35 initGraph(["app|foo.a"], {"app": [ 42 initGraph([
36 [new RewriteTransformer("b", "c")], 43 "app|foo.a"
37 [new RewriteTransformer("a", "b")] 44 ], {
38 ]}); 45 "app": [
46 [new RewriteTransformer("b", "c")],
47 [new RewriteTransformer("a", "b")]
48 ]
49 });
39 updateSources(["app|foo.a"]); 50 updateSources(["app|foo.a"]);
40 expectNoAsset("app|foo.c"); 51 expectNoAsset("app|foo.c");
41 buildShouldSucceed(); 52 buildShouldSucceed();
42 }); 53 });
43 54
44 test("doesn't find an output from the same phase", () { 55 test("doesn't find an output from the same phase", () {
45 initGraph(["app|foo.a"], {"app": [ 56 initGraph([
46 [ 57 "app|foo.a"
47 new RewriteTransformer("a", "b"), 58 ], {
48 new RewriteTransformer("b", "c") 59 "app": [
60 [new RewriteTransformer("a", "b"), new RewriteTransformer("b", "c")]
49 ] 61 ]
50 ]}); 62 });
51 updateSources(["app|foo.a"]); 63 updateSources(["app|foo.a"]);
52 expectAsset("app|foo.b", "foo.b"); 64 expectAsset("app|foo.b", "foo.b");
53 expectNoAsset("app|foo.c"); 65 expectNoAsset("app|foo.c");
54 buildShouldSucceed(); 66 buildShouldSucceed();
55 }); 67 });
56 68
57 test("finds the latest output before the transformer's phase", () { 69 test("finds the latest output before the transformer's phase", () {
58 initGraph(["app|foo.blub"], {"app": [ 70 initGraph([
59 [new RewriteTransformer("blub", "blub")], 71 "app|foo.blub"
60 [ 72 ], {
61 new RewriteTransformer("blub", "blub"), 73 "app": [
62 new RewriteTransformer("blub", "done") 74 [new RewriteTransformer("blub", "blub")],
63 ], 75 [
64 [new RewriteTransformer("blub", "blub")] 76 new RewriteTransformer("blub", "blub"),
65 ]}); 77 new RewriteTransformer("blub", "done")
78 ],
79 [new RewriteTransformer("blub", "blub")]
80 ]
81 });
66 updateSources(["app|foo.blub"]); 82 updateSources(["app|foo.blub"]);
67 expectAsset("app|foo.done", "foo.blub.done"); 83 expectAsset("app|foo.done", "foo.blub.done");
68 buildShouldSucceed(); 84 buildShouldSucceed();
69 }); 85 });
70 86
71 test("applies multiple transformations to an asset", () { 87 test("applies multiple transformations to an asset", () {
72 initGraph(["app|foo.a"], {"app": [ 88 initGraph([
73 [new RewriteTransformer("a", "b")], 89 "app|foo.a"
74 [new RewriteTransformer("b", "c")], 90 ], {
75 [new RewriteTransformer("c", "d")], 91 "app": [
76 [new RewriteTransformer("d", "e")], 92 [new RewriteTransformer("a", "b")],
77 [new RewriteTransformer("e", "f")], 93 [new RewriteTransformer("b", "c")],
78 [new RewriteTransformer("f", "g")], 94 [new RewriteTransformer("c", "d")],
79 [new RewriteTransformer("g", "h")], 95 [new RewriteTransformer("d", "e")],
80 [new RewriteTransformer("h", "i")], 96 [new RewriteTransformer("e", "f")],
81 [new RewriteTransformer("i", "j")], 97 [new RewriteTransformer("f", "g")],
82 [new RewriteTransformer("j", "k")], 98 [new RewriteTransformer("g", "h")],
83 ]}); 99 [new RewriteTransformer("h", "i")],
100 [new RewriteTransformer("i", "j")],
101 [new RewriteTransformer("j", "k")],
102 ]
103 });
84 updateSources(["app|foo.a"]); 104 updateSources(["app|foo.a"]);
85 expectAsset("app|foo.k", "foo.b.c.d.e.f.g.h.i.j.k"); 105 expectAsset("app|foo.k", "foo.b.c.d.e.f.g.h.i.j.k");
86 buildShouldSucceed(); 106 buildShouldSucceed();
87 }); 107 });
88 108
89 test("only runs a transform once for all of its outputs", () { 109 test("only runs a transform once for all of its outputs", () {
90 var transformer = new RewriteTransformer("blub", "a b c"); 110 var transformer = new RewriteTransformer("blub", "a b c");
91 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 111 initGraph([
112 "app|foo.blub"
113 ], {
114 "app": [
115 [transformer]
116 ]
117 });
92 updateSources(["app|foo.blub"]); 118 updateSources(["app|foo.blub"]);
93 expectAsset("app|foo.a", "foo.a"); 119 expectAsset("app|foo.a", "foo.a");
94 expectAsset("app|foo.b", "foo.b"); 120 expectAsset("app|foo.b", "foo.b");
95 expectAsset("app|foo.c", "foo.c"); 121 expectAsset("app|foo.c", "foo.c");
96 buildShouldSucceed(); 122 buildShouldSucceed();
97 expect(transformer.numRuns, completion(equals(1))); 123 expect(transformer.numRuns, completion(equals(1)));
98 }); 124 });
99 125
100 test("outputs are passed through transformers by default", () { 126 test("outputs are passed through transformers by default", () {
101 initGraph(["app|foo.a"], {"app": [ 127 initGraph([
102 [new RewriteTransformer("a", "b")], 128 "app|foo.a"
103 [new RewriteTransformer("a", "c")] 129 ], {
104 ]}); 130 "app": [
131 [new RewriteTransformer("a", "b")],
132 [new RewriteTransformer("a", "c")]
133 ]
134 });
105 updateSources(["app|foo.a"]); 135 updateSources(["app|foo.a"]);
106 expectAsset("app|foo.a", "foo"); 136 expectAsset("app|foo.a", "foo");
107 expectAsset("app|foo.b", "foo.b"); 137 expectAsset("app|foo.b", "foo.b");
108 expectAsset("app|foo.c", "foo.c"); 138 expectAsset("app|foo.c", "foo.c");
109 buildShouldSucceed(); 139 buildShouldSucceed();
110 }); 140 });
111 141
112 test("does not reapply transform when inputs are not modified", () { 142 test("does not reapply transform when inputs are not modified", () {
113 var transformer = new RewriteTransformer("blub", "blab"); 143 var transformer = new RewriteTransformer("blub", "blab");
114 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 144 initGraph([
145 "app|foo.blub"
146 ], {
147 "app": [
148 [transformer]
149 ]
150 });
115 updateSources(["app|foo.blub"]); 151 updateSources(["app|foo.blub"]);
116 expectAsset("app|foo.blab", "foo.blab"); 152 expectAsset("app|foo.blab", "foo.blab");
117 expectAsset("app|foo.blab", "foo.blab"); 153 expectAsset("app|foo.blab", "foo.blab");
118 expectAsset("app|foo.blab", "foo.blab"); 154 expectAsset("app|foo.blab", "foo.blab");
119 buildShouldSucceed(); 155 buildShouldSucceed();
120 156
121 expect(transformer.numRuns, completion(equals(1))); 157 expect(transformer.numRuns, completion(equals(1)));
122 }); 158 });
123 159
124 test("reapplies a transform when its input is modified", () { 160 test("reapplies a transform when its input is modified", () {
125 var transformer = new RewriteTransformer("blub", "blab"); 161 var transformer = new RewriteTransformer("blub", "blab");
126 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 162 initGraph([
163 "app|foo.blub"
164 ], {
165 "app": [
166 [transformer]
167 ]
168 });
127 169
128 updateSources(["app|foo.blub"]); 170 updateSources(["app|foo.blub"]);
129 expectAsset("app|foo.blab", "foo.blab"); 171 expectAsset("app|foo.blab", "foo.blab");
130 buildShouldSucceed(); 172 buildShouldSucceed();
131 173
132 updateSources(["app|foo.blub"]); 174 updateSources(["app|foo.blub"]);
133 expectAsset("app|foo.blab", "foo.blab"); 175 expectAsset("app|foo.blab", "foo.blab");
134 buildShouldSucceed(); 176 buildShouldSucceed();
135 177
136 updateSources(["app|foo.blub"]); 178 updateSources(["app|foo.blub"]);
137 expectAsset("app|foo.blab", "foo.blab"); 179 expectAsset("app|foo.blab", "foo.blab");
138 buildShouldSucceed(); 180 buildShouldSucceed();
139 181
140 expect(transformer.numRuns, completion(equals(3))); 182 expect(transformer.numRuns, completion(equals(3)));
141 }); 183 });
142 184
143 test("does not reapply transform when a removed input is modified", () { 185 test("does not reapply transform when a removed input is modified", () {
144 var transformer = new ManyToOneTransformer("txt"); 186 var transformer = new ManyToOneTransformer("txt");
145 initGraph({ 187 initGraph({
146 "app|a.txt": "a.inc,b.inc", 188 "app|a.txt": "a.inc,b.inc",
147 "app|a.inc": "a", 189 "app|a.inc": "a",
148 "app|b.inc": "b" 190 "app|b.inc": "b"
149 }, {"app": [[transformer]]}); 191 }, {
192 "app": [
193 [transformer]
194 ]
195 });
150 196
151 updateSources(["app|a.txt", "app|a.inc", "app|b.inc"]); 197 updateSources(["app|a.txt", "app|a.inc", "app|b.inc"]);
152 198
153 expectAsset("app|a.out", "ab"); 199 expectAsset("app|a.out", "ab");
154 buildShouldSucceed(); 200 buildShouldSucceed();
155 201
156 // Remove the dependency on the non-primary input. 202 // Remove the dependency on the non-primary input.
157 modifyAsset("app|a.txt", "a.inc"); 203 modifyAsset("app|a.txt", "a.inc");
158 updateSources(["app|a.txt"]); 204 updateSources(["app|a.txt"]);
159 205
160 // Process it again. 206 // Process it again.
161 expectAsset("app|a.out", "a"); 207 expectAsset("app|a.out", "a");
162 buildShouldSucceed(); 208 buildShouldSucceed();
163 209
164 // Now touch the removed input. It should not trigger another build. 210 // Now touch the removed input. It should not trigger another build.
165 updateSources(["app|b.inc"]); 211 updateSources(["app|b.inc"]);
166 expectAsset("app|a.out", "a"); 212 expectAsset("app|a.out", "a");
167 buildShouldSucceed(); 213 buildShouldSucceed();
168 214
169 expect(transformer.numRuns, completion(equals(2))); 215 expect(transformer.numRuns, completion(equals(2)));
170 }); 216 });
171 217
172 test("allows a transform to generate multiple outputs", () { 218 test("allows a transform to generate multiple outputs", () {
173 initGraph({"app|foo.txt": "a.out,b.out"}, {"app": [ 219 initGraph({
174 [new OneToManyTransformer("txt")] 220 "app|foo.txt": "a.out,b.out"
175 ]}); 221 }, {
222 "app": [
223 [new OneToManyTransformer("txt")]
224 ]
225 });
176 226
177 updateSources(["app|foo.txt"]); 227 updateSources(["app|foo.txt"]);
178 228
179 expectAsset("app|a.out", "spread txt"); 229 expectAsset("app|a.out", "spread txt");
180 expectAsset("app|b.out", "spread txt"); 230 expectAsset("app|b.out", "spread txt");
181 buildShouldSucceed(); 231 buildShouldSucceed();
182 }); 232 });
183 233
184 test("does not rebuild transforms that don't use modified source", () { 234 test("does not rebuild transforms that don't use modified source", () {
185 var a = new RewriteTransformer("a", "aa"); 235 var a = new RewriteTransformer("a", "aa");
186 var aa = new RewriteTransformer("aa", "aaa"); 236 var aa = new RewriteTransformer("aa", "aaa");
187 var b = new RewriteTransformer("b", "bb"); 237 var b = new RewriteTransformer("b", "bb");
188 var bb = new RewriteTransformer("bb", "bbb"); 238 var bb = new RewriteTransformer("bb", "bbb");
189 initGraph(["app|foo.a", "app|foo.b"], {"app": [ 239 initGraph([
190 [a, b], 240 "app|foo.a",
191 [aa, bb], 241 "app|foo.b"
192 ]}); 242 ], {
243 "app": [
244 [a, b],
245 [aa, bb],
246 ]
247 });
193 248
194 updateSources(["app|foo.a"]); 249 updateSources(["app|foo.a"]);
195 updateSources(["app|foo.b"]); 250 updateSources(["app|foo.b"]);
196 251
197 expectAsset("app|foo.aaa", "foo.aa.aaa"); 252 expectAsset("app|foo.aaa", "foo.aa.aaa");
198 expectAsset("app|foo.bbb", "foo.bb.bbb"); 253 expectAsset("app|foo.bbb", "foo.bb.bbb");
199 buildShouldSucceed(); 254 buildShouldSucceed();
200 255
201 updateSources(["app|foo.a"]); 256 updateSources(["app|foo.a"]);
202 expectAsset("app|foo.aaa", "foo.aa.aaa"); 257 expectAsset("app|foo.aaa", "foo.aa.aaa");
203 expectAsset("app|foo.bbb", "foo.bb.bbb"); 258 expectAsset("app|foo.bbb", "foo.bb.bbb");
204 buildShouldSucceed(); 259 buildShouldSucceed();
205 260
206 expect(aa.numRuns, completion(equals(2))); 261 expect(aa.numRuns, completion(equals(2)));
207 expect(bb.numRuns, completion(equals(1))); 262 expect(bb.numRuns, completion(equals(1)));
208 }); 263 });
209 264
210 test("doesn't get an output from a transform whose primary input is removed", 265 test("doesn't get an output from a transform whose primary input is removed",
211 () { 266 () {
212 initGraph(["app|foo.txt"], {"app": [ 267 initGraph([
213 [new RewriteTransformer("txt", "out")] 268 "app|foo.txt"
214 ]}); 269 ], {
270 "app": [
271 [new RewriteTransformer("txt", "out")]
272 ]
273 });
215 274
216 updateSources(["app|foo.txt"]); 275 updateSources(["app|foo.txt"]);
217 expectAsset("app|foo.out", "foo.out"); 276 expectAsset("app|foo.out", "foo.out");
218 buildShouldSucceed(); 277 buildShouldSucceed();
219 278
220 removeSources(["app|foo.txt"]); 279 removeSources(["app|foo.txt"]);
221 expectNoAsset("app|foo.out"); 280 expectNoAsset("app|foo.out");
222 buildShouldSucceed(); 281 buildShouldSucceed();
223 }); 282 });
224 283
225 test("reapplies a transform when a non-primary input changes", () { 284 test("reapplies a transform when a non-primary input changes", () {
226 initGraph({ 285 initGraph({
227 "app|a.txt": "a.inc", 286 "app|a.txt": "a.inc",
228 "app|a.inc": "a" 287 "app|a.inc": "a"
229 }, {"app": [[new ManyToOneTransformer("txt")]]}); 288 }, {
289 "app": [
290 [new ManyToOneTransformer("txt")]
291 ]
292 });
230 293
231 updateSources(["app|a.txt", "app|a.inc"]); 294 updateSources(["app|a.txt", "app|a.inc"]);
232 expectAsset("app|a.out", "a"); 295 expectAsset("app|a.out", "a");
233 buildShouldSucceed(); 296 buildShouldSucceed();
234 297
235 modifyAsset("app|a.inc", "after"); 298 modifyAsset("app|a.inc", "after");
236 updateSources(["app|a.inc"]); 299 updateSources(["app|a.inc"]);
237 300
238 expectAsset("app|a.out", "after"); 301 expectAsset("app|a.out", "after");
239 buildShouldSucceed(); 302 buildShouldSucceed();
240 }); 303 });
241 304
242 test("applies a transform when it becomes newly primary", () { 305 test("applies a transform when it becomes newly primary", () {
243 initGraph({ 306 initGraph({
244 "app|foo.txt": "this", 307 "app|foo.txt": "this",
245 }, {"app": [[new CheckContentTransformer("that", " and the other")]]}); 308 }, {
309 "app": [
310 [new CheckContentTransformer("that", " and the other")]
311 ]
312 });
246 313
247 updateSources(["app|foo.txt"]); 314 updateSources(["app|foo.txt"]);
248 expectAsset("app|foo.txt", "this"); 315 expectAsset("app|foo.txt", "this");
249 buildShouldSucceed(); 316 buildShouldSucceed();
250 317
251 modifyAsset("app|foo.txt", "that"); 318 modifyAsset("app|foo.txt", "that");
252 updateSources(["app|foo.txt"]); 319 updateSources(["app|foo.txt"]);
253 320
254 expectAsset("app|foo.txt", "that and the other"); 321 expectAsset("app|foo.txt", "that and the other");
255 buildShouldSucceed(); 322 buildShouldSucceed();
256 }); 323 });
257 324
258 test("handles an output moving from one transformer to another", () { 325 test("handles an output moving from one transformer to another", () {
259 // In the first run, "shared.out" is created by the "a.a" transformer. 326 // In the first run, "shared.out" is created by the "a.a" transformer.
260 initGraph({ 327 initGraph({
261 "app|a.a": "a.out,shared.out", 328 "app|a.a": "a.out,shared.out",
262 "app|b.b": "b.out" 329 "app|b.b": "b.out"
263 }, {"app": [ 330 }, {
264 [new OneToManyTransformer("a"), new OneToManyTransformer("b")] 331 "app": [
265 ]}); 332 [new OneToManyTransformer("a"), new OneToManyTransformer("b")]
333 ]
334 });
266 335
267 updateSources(["app|a.a", "app|b.b"]); 336 updateSources(["app|a.a", "app|b.b"]);
268 337
269 expectAsset("app|a.out", "spread a"); 338 expectAsset("app|a.out", "spread a");
270 expectAsset("app|b.out", "spread b"); 339 expectAsset("app|b.out", "spread b");
271 expectAsset("app|shared.out", "spread a"); 340 expectAsset("app|shared.out", "spread a");
272 buildShouldSucceed(); 341 buildShouldSucceed();
273 342
274 // Now switch their contents so that "shared.out" will be output by "b.b"'s 343 // Now switch their contents so that "shared.out" will be output by "b.b"'s
275 // transformer. 344 // transformer.
276 modifyAsset("app|a.a", "a.out"); 345 modifyAsset("app|a.a", "a.out");
277 modifyAsset("app|b.b", "b.out,shared.out"); 346 modifyAsset("app|b.b", "b.out,shared.out");
278 updateSources(["app|a.a", "app|b.b"]); 347 updateSources(["app|a.a", "app|b.b"]);
279 348
280 expectAsset("app|a.out", "spread a"); 349 expectAsset("app|a.out", "spread a");
281 expectAsset("app|b.out", "spread b"); 350 expectAsset("app|b.out", "spread b");
282 expectAsset("app|shared.out", "spread b"); 351 expectAsset("app|shared.out", "spread b");
283 buildShouldSucceed(); 352 buildShouldSucceed();
284 }); 353 });
285 354
286 test("applies transforms to the correct packages", () { 355 test("applies transforms to the correct packages", () {
287 var rewrite1 = new RewriteTransformer("txt", "out1"); 356 var rewrite1 = new RewriteTransformer("txt", "out1");
288 var rewrite2 = new RewriteTransformer("txt", "out2"); 357 var rewrite2 = new RewriteTransformer("txt", "out2");
289 initGraph([ 358 initGraph([
290 "pkg1|foo.txt", 359 "pkg1|foo.txt",
291 "pkg2|foo.txt" 360 "pkg2|foo.txt"
292 ], {"pkg1": [[rewrite1]], "pkg2": [[rewrite2]]}); 361 ], {
362 "pkg1": [
363 [rewrite1]
364 ],
365 "pkg2": [
366 [rewrite2]
367 ]
368 });
293 369
294 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]); 370 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
295 expectAsset("pkg1|foo.out1", "foo.out1"); 371 expectAsset("pkg1|foo.out1", "foo.out1");
296 expectAsset("pkg2|foo.out2", "foo.out2"); 372 expectAsset("pkg2|foo.out2", "foo.out2");
297 buildShouldSucceed(); 373 buildShouldSucceed();
298 }); 374 });
299 375
300 test("transforms don't see generated assets in other packages", () { 376 test("transforms don't see generated assets in other packages", () {
301 var fooToBar = new RewriteTransformer("foo", "bar"); 377 var fooToBar = new RewriteTransformer("foo", "bar");
302 var barToBaz = new RewriteTransformer("bar", "baz"); 378 var barToBaz = new RewriteTransformer("bar", "baz");
303 initGraph(["pkg1|file.foo"], {"pkg1": [[fooToBar]], "pkg2": [[barToBaz]]}); 379 initGraph([
380 "pkg1|file.foo"
381 ], {
382 "pkg1": [
383 [fooToBar]
384 ],
385 "pkg2": [
386 [barToBaz]
387 ]
388 });
304 389
305 updateSources(["pkg1|file.foo"]); 390 updateSources(["pkg1|file.foo"]);
306 expectAsset("pkg1|file.bar", "file.bar"); 391 expectAsset("pkg1|file.bar", "file.bar");
307 expectNoAsset("pkg2|file.baz"); 392 expectNoAsset("pkg2|file.baz");
308 buildShouldSucceed(); 393 buildShouldSucceed();
309 }); 394 });
310 395
311 test("removes pipelined transforms when the root primary input is removed", 396 test("removes pipelined transforms when the root primary input is removed",
312 () { 397 () {
313 initGraph(["app|foo.txt"], {"app": [ 398 initGraph([
314 [new RewriteTransformer("txt", "mid")], 399 "app|foo.txt"
315 [new RewriteTransformer("mid", "out")] 400 ], {
316 ]}); 401 "app": [
402 [new RewriteTransformer("txt", "mid")],
403 [new RewriteTransformer("mid", "out")]
404 ]
405 });
317 406
318 updateSources(["app|foo.txt"]); 407 updateSources(["app|foo.txt"]);
319 expectAsset("app|foo.out", "foo.mid.out"); 408 expectAsset("app|foo.out", "foo.mid.out");
320 buildShouldSucceed(); 409 buildShouldSucceed();
321 410
322 removeSources(["app|foo.txt"]); 411 removeSources(["app|foo.txt"]);
323 expectNoAsset("app|foo.out"); 412 expectNoAsset("app|foo.out");
324 buildShouldSucceed(); 413 buildShouldSucceed();
325 }); 414 });
326 415
327 test("removes pipelined transforms when the parent ceases to generate the " 416 test(
417 "removes pipelined transforms when the parent ceases to generate the "
328 "primary input", () { 418 "primary input", () {
329 initGraph({"app|foo.txt": "foo.mid"}, {'app': [ 419 initGraph({
330 [new OneToManyTransformer('txt')], 420 "app|foo.txt": "foo.mid"
331 [new RewriteTransformer('mid', 'out')] 421 }, {
332 ]}); 422 'app': [
423 [new OneToManyTransformer('txt')],
424 [new RewriteTransformer('mid', 'out')]
425 ]
426 });
333 427
334 updateSources(['app|foo.txt']); 428 updateSources(['app|foo.txt']);
335 expectAsset('app|foo.out', 'spread txt.out'); 429 expectAsset('app|foo.out', 'spread txt.out');
336 buildShouldSucceed(); 430 buildShouldSucceed();
337 431
338 modifyAsset("app|foo.txt", "bar.mid"); 432 modifyAsset("app|foo.txt", "bar.mid");
339 updateSources(["app|foo.txt"]); 433 updateSources(["app|foo.txt"]);
340 expectNoAsset('app|foo.out'); 434 expectNoAsset('app|foo.out');
341 expectAsset('app|bar.out', 'spread txt.out'); 435 expectAsset('app|bar.out', 'spread txt.out');
342 buildShouldSucceed(); 436 buildShouldSucceed();
343 }); 437 });
344 438
345 test("gets an asset transformed by a sync transformer", () { 439 test("gets an asset transformed by a sync transformer", () {
346 initGraph(["app|foo.blub"], {"app": [ 440 initGraph([
347 [new SyncRewriteTransformer("blub", "blab")] 441 "app|foo.blub"
348 ]}); 442 ], {
443 "app": [
444 [new SyncRewriteTransformer("blub", "blab")]
445 ]
446 });
349 updateSources(["app|foo.blub"]); 447 updateSources(["app|foo.blub"]);
350 expectAsset("app|foo.blab", "new.blab"); 448 expectAsset("app|foo.blab", "new.blab");
351 buildShouldSucceed(); 449 buildShouldSucceed();
352 }); 450 });
353 451
354 group("Transform.hasInput", () { 452 group("Transform.hasInput", () {
355 test("returns whether an input exists", () { 453 test("returns whether an input exists", () {
356 initGraph(["app|foo.txt", "app|bar.txt"], {'app': [ 454 initGraph([
357 [new HasInputTransformer(['app|foo.txt', 'app|bar.txt', 'app|baz.txt'])] 455 "app|foo.txt",
358 ]}); 456 "app|bar.txt"
457 ], {
458 'app': [
459 [
460 new HasInputTransformer(
461 ['app|foo.txt', 'app|bar.txt', 'app|baz.txt'])
462 ]
463 ]
464 });
359 465
360 updateSources(['app|foo.txt', 'app|bar.txt']); 466 updateSources(['app|foo.txt', 'app|bar.txt']);
361 expectAsset('app|foo.txt', 467 expectAsset('app|foo.txt',
362 'app|foo.txt: true, app|bar.txt: true, app|baz.txt: false'); 468 'app|foo.txt: true, app|bar.txt: true, app|baz.txt: false');
363 buildShouldSucceed(); 469 buildShouldSucceed();
364 }); 470 });
365 471
366 test("re-runs the transformer when an input stops existing", () { 472 test("re-runs the transformer when an input stops existing", () {
367 initGraph(["app|foo.txt", "app|bar.txt"], {'app': [ 473 initGraph([
368 [new HasInputTransformer(['app|bar.txt'])] 474 "app|foo.txt",
369 ]}); 475 "app|bar.txt"
476 ], {
477 'app': [
478 [
479 new HasInputTransformer(['app|bar.txt'])
480 ]
481 ]
482 });
370 483
371 updateSources(['app|foo.txt', 'app|bar.txt']); 484 updateSources(['app|foo.txt', 'app|bar.txt']);
372 expectAsset('app|foo.txt', 'app|bar.txt: true'); 485 expectAsset('app|foo.txt', 'app|bar.txt: true');
373 buildShouldSucceed(); 486 buildShouldSucceed();
374 487
375 removeSources(['app|bar.txt']); 488 removeSources(['app|bar.txt']);
376 expectAsset('app|foo.txt', 'app|bar.txt: false'); 489 expectAsset('app|foo.txt', 'app|bar.txt: false');
377 buildShouldSucceed(); 490 buildShouldSucceed();
378 }); 491 });
379 492
380 test("re-runs the transformer when an input starts existing", () { 493 test("re-runs the transformer when an input starts existing", () {
381 initGraph(["app|foo.txt", "app|bar.txt"], {'app': [ 494 initGraph([
382 [new HasInputTransformer(['app|bar.txt'])] 495 "app|foo.txt",
383 ]}); 496 "app|bar.txt"
384 497 ], {
498 'app': [
499 [
500 new HasInputTransformer(['app|bar.txt'])
501 ]
502 ]
503 });
504
385 updateSources(['app|foo.txt']); 505 updateSources(['app|foo.txt']);
386 expectAsset('app|foo.txt', 'app|bar.txt: false'); 506 expectAsset('app|foo.txt', 'app|bar.txt: false');
387 buildShouldSucceed(); 507 buildShouldSucceed();
388 508
389 updateSources(['app|bar.txt']); 509 updateSources(['app|bar.txt']);
390 expectAsset('app|foo.txt', 'app|bar.txt: true'); 510 expectAsset('app|foo.txt', 'app|bar.txt: true');
391 buildShouldSucceed(); 511 buildShouldSucceed();
392 }); 512 });
393 513
394 group("on an input in another package", () { 514 group("on an input in another package", () {
395 test("returns whether it exists", () { 515 test("returns whether it exists", () {
396 initGraph(["app|foo.txt", "other|bar.txt"], {'app': [ 516 initGraph([
397 [new HasInputTransformer(['other|bar.txt', 'other|baz.txt'])] 517 "app|foo.txt",
398 ]}); 518 "other|bar.txt"
519 ], {
520 'app': [
521 [
522 new HasInputTransformer(['other|bar.txt', 'other|baz.txt'])
523 ]
524 ]
525 });
399 526
400 updateSources(['app|foo.txt', 'other|bar.txt']); 527 updateSources(['app|foo.txt', 'other|bar.txt']);
401 expectAsset('app|foo.txt', 528 expectAsset('app|foo.txt', 'other|bar.txt: true, other|baz.txt: false');
402 'other|bar.txt: true, other|baz.txt: false');
403 buildShouldSucceed(); 529 buildShouldSucceed();
404 }); 530 });
405 531
406 test("re-runs the transformer when it stops existing", () { 532 test("re-runs the transformer when it stops existing", () {
407 initGraph(["app|foo.txt", "other|bar.txt"], {'app': [ 533 initGraph([
408 [new HasInputTransformer(['other|bar.txt'])] 534 "app|foo.txt",
409 ]}); 535 "other|bar.txt"
536 ], {
537 'app': [
538 [
539 new HasInputTransformer(['other|bar.txt'])
540 ]
541 ]
542 });
410 543
411 updateSources(['app|foo.txt', 'other|bar.txt']); 544 updateSources(['app|foo.txt', 'other|bar.txt']);
412 expectAsset('app|foo.txt', 'other|bar.txt: true'); 545 expectAsset('app|foo.txt', 'other|bar.txt: true');
413 buildShouldSucceed(); 546 buildShouldSucceed();
414 547
415 removeSources(['other|bar.txt']); 548 removeSources(['other|bar.txt']);
416 expectAsset('app|foo.txt', 'other|bar.txt: false'); 549 expectAsset('app|foo.txt', 'other|bar.txt: false');
417 buildShouldSucceed(); 550 buildShouldSucceed();
418 }); 551 });
419 552
420 test("re-runs the transformer when it starts existing", () { 553 test("re-runs the transformer when it starts existing", () {
421 initGraph(["app|foo.txt", "other|bar.txt"], {'app': [ 554 initGraph([
422 [new HasInputTransformer(['other|bar.txt'])] 555 "app|foo.txt",
423 ]}); 556 "other|bar.txt"
424 557 ], {
558 'app': [
559 [
560 new HasInputTransformer(['other|bar.txt'])
561 ]
562 ]
563 });
564
425 updateSources(['app|foo.txt']); 565 updateSources(['app|foo.txt']);
426 expectAsset('app|foo.txt', 'other|bar.txt: false'); 566 expectAsset('app|foo.txt', 'other|bar.txt: false');
427 buildShouldSucceed(); 567 buildShouldSucceed();
428 568
429 updateSources(['other|bar.txt']); 569 updateSources(['other|bar.txt']);
430 expectAsset('app|foo.txt', 'other|bar.txt: true'); 570 expectAsset('app|foo.txt', 'other|bar.txt: true');
431 buildShouldSucceed(); 571 buildShouldSucceed();
432 }); 572 });
433 }); 573 });
434 }); 574 });
435 } 575 }
OLDNEW
« no previous file with comments | « packages/barback/test/package_graph/transform/pass_through_test.dart ('k') | packages/barback/test/static_provider_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698