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

Side by Side Diff: packages/barback/test/package_graph/declaring_transformer_test.dart

Issue 3015713002: Roll to pickup pool changes
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 library barback.test.package_graph.declaring_transformer_test; 5 library barback.test.package_graph.declaring_transformer_test;
6 6
7 import 'package:barback/barback.dart';
8 import 'package:barback/src/utils.dart'; 7 import 'package:barback/src/utils.dart';
9 import 'package:scheduled_test/scheduled_test.dart'; 8 import 'package:scheduled_test/scheduled_test.dart';
10 9
11 import '../utils.dart'; 10 import '../utils.dart';
12 11
13 main() { 12 main() {
14 initConfig(); 13 initConfig();
15 14
16 test("gets a declared output with a different path", () { 15 test("gets a declared output with a different path", () {
17 initGraph(["app|foo.blub"], {"app": [ 16 initGraph([
18 [new DeclaringRewriteTransformer("blub", "blab")] 17 "app|foo.blub"
19 ]}); 18 ], {
19 "app": [
20 [new DeclaringRewriteTransformer("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 declared output with the same path", () { 28 test("gets a declared output with the same path", () {
26 initGraph(["app|foo.blub"], {"app": [ 29 initGraph([
27 [new DeclaringRewriteTransformer("blub", "blub")] 30 "app|foo.blub"
28 ]}); 31 ], {
32 "app": [
33 [new DeclaringRewriteTransformer("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("gets a passed-through asset", () { 41 test("gets a passed-through asset", () {
35 initGraph(["app|foo.blub"], {"app": [ 42 initGraph([
36 [new DeclaringRewriteTransformer("blub", "blab")] 43 "app|foo.blub"
37 ]}); 44 ], {
45 "app": [
46 [new DeclaringRewriteTransformer("blub", "blab")]
47 ]
48 });
38 updateSources(["app|foo.blub"]); 49 updateSources(["app|foo.blub"]);
39 expectAsset("app|foo.blub", "foo"); 50 expectAsset("app|foo.blub", "foo");
40 buildShouldSucceed(); 51 buildShouldSucceed();
41 }); 52 });
42 53
43 test("doesn't get a consumed asset", () { 54 test("doesn't get a consumed asset", () {
44 initGraph(["app|foo.blub"], {"app": [ 55 initGraph([
45 [new DeclaringRewriteTransformer("blub", "blab")..consumePrimary = true] 56 "app|foo.blub"
46 ]}); 57 ], {
58 "app": [
59 [new DeclaringRewriteTransformer("blub", "blab")..consumePrimary = true]
60 ]
61 });
47 updateSources(["app|foo.blub"]); 62 updateSources(["app|foo.blub"]);
48 expectNoAsset("app|foo.blub"); 63 expectNoAsset("app|foo.blub");
49 buildShouldSucceed(); 64 buildShouldSucceed();
50 }); 65 });
51 66
52 test("gets a passed-through asset before apply is finished", () { 67 test("gets a passed-through asset before apply is finished", () {
53 var transformer = new DeclaringRewriteTransformer("blub", "blab"); 68 var transformer = new DeclaringRewriteTransformer("blub", "blab");
54 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 69 initGraph([
70 "app|foo.blub"
71 ], {
72 "app": [
73 [transformer]
74 ]
75 });
55 76
56 transformer.pauseApply(); 77 transformer.pauseApply();
57 updateSources(["app|foo.blub"]); 78 updateSources(["app|foo.blub"]);
58 expectAsset("app|foo.blub", "foo"); 79 expectAsset("app|foo.blub", "foo");
59 80
60 transformer.resumeApply(); 81 transformer.resumeApply();
61 buildShouldSucceed(); 82 buildShouldSucceed();
62 }); 83 });
63 84
64 test("fails to get a consumed asset before apply is finished", () { 85 test("fails to get a consumed asset before apply is finished", () {
65 var transformer = new DeclaringRewriteTransformer("blub", "blab") 86 var transformer = new DeclaringRewriteTransformer("blub", "blab")
66 ..consumePrimary = true; 87 ..consumePrimary = true;
67 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 88 initGraph([
68 89 "app|foo.blub"
90 ], {
91 "app": [
92 [transformer]
93 ]
94 });
95
69 transformer.pauseApply(); 96 transformer.pauseApply();
70 updateSources(["app|foo.blub"]); 97 updateSources(["app|foo.blub"]);
71 expectNoAsset("app|foo.blub"); 98 expectNoAsset("app|foo.blub");
72 99
73 transformer.resumeApply(); 100 transformer.resumeApply();
74 buildShouldSucceed(); 101 buildShouldSucceed();
75 }); 102 });
76 103
77 test("blocks on getting a declared asset that wasn't generated last run", () { 104 test("blocks on getting a declared asset that wasn't generated last run", () {
78 var transformer = new DeclaringCheckContentAndRenameTransformer( 105 var transformer = new DeclaringCheckContentAndRenameTransformer(
79 oldExtension: "txt", oldContent: "yes", 106 oldExtension: "txt",
80 newExtension: "out", newContent: "done"); 107 oldContent: "yes",
81 initGraph({"app|foo.txt": "no"}, {"app": [[transformer]]}); 108 newExtension: "out",
109 newContent: "done");
110 initGraph({
111 "app|foo.txt": "no"
112 }, {
113 "app": [
114 [transformer]
115 ]
116 });
82 117
83 updateSources(["app|foo.txt"]); 118 updateSources(["app|foo.txt"]);
84 expectNoAsset("app|foo.out"); 119 expectNoAsset("app|foo.out");
85 buildShouldSucceed(); 120 buildShouldSucceed();
86 121
87 // The transform should remember that foo.out was declared, so it should 122 // The transform should remember that foo.out was declared, so it should
88 // expect that it might still be generated even though it wasn't last time. 123 // expect that it might still be generated even though it wasn't last time.
89 transformer.pauseApply(); 124 transformer.pauseApply();
90 modifyAsset("app|foo.txt", "yes"); 125 modifyAsset("app|foo.txt", "yes");
91 updateSources(["app|foo.txt"]); 126 updateSources(["app|foo.txt"]);
92 expectAssetDoesNotComplete("app|foo.out"); 127 expectAssetDoesNotComplete("app|foo.out");
93 128
94 transformer.resumeApply(); 129 transformer.resumeApply();
95 expectAsset("app|foo.out", "done"); 130 expectAsset("app|foo.out", "done");
96 buildShouldSucceed(); 131 buildShouldSucceed();
97 }); 132 });
98 133
99 test("doesn't block on on getting an undeclared asset that wasn't generated " 134 test(
135 "doesn't block on on getting an undeclared asset that wasn't generated "
100 "last run", () { 136 "last run", () {
101 var transformer = new DeclaringCheckContentAndRenameTransformer( 137 var transformer = new DeclaringCheckContentAndRenameTransformer(
102 oldExtension: "txt", oldContent: "yes", 138 oldExtension: "txt",
103 newExtension: "out", newContent: "done"); 139 oldContent: "yes",
104 initGraph({"app|foo.txt": "no"}, {"app": [[transformer]]}); 140 newExtension: "out",
141 newContent: "done");
142 initGraph({
143 "app|foo.txt": "no"
144 }, {
145 "app": [
146 [transformer]
147 ]
148 });
105 149
106 updateSources(["app|foo.txt"]); 150 updateSources(["app|foo.txt"]);
107 expectNoAsset("app|foo.out"); 151 expectNoAsset("app|foo.out");
108 buildShouldSucceed(); 152 buildShouldSucceed();
109 153
110 transformer.pauseApply(); 154 transformer.pauseApply();
111 modifyAsset("app|foo.txt", "yes"); 155 modifyAsset("app|foo.txt", "yes");
112 updateSources(["app|foo.txt"]); 156 updateSources(["app|foo.txt"]);
113 expectNoAsset("app|undeclared.out"); 157 expectNoAsset("app|undeclared.out");
114 158
115 transformer.resumeApply(); 159 transformer.resumeApply();
116 buildShouldSucceed(); 160 buildShouldSucceed();
117 }); 161 });
118 162
119 test("fails to get a consumed asset before apply is finished when a sibling " 163 test(
164 "fails to get a consumed asset before apply is finished when a sibling "
120 "has finished applying", () { 165 "has finished applying", () {
121 var transformer = new DeclaringRewriteTransformer("blub", "blab") 166 var transformer = new DeclaringRewriteTransformer("blub", "blab")
122 ..consumePrimary = true; 167 ..consumePrimary = true;
123 initGraph(["app|foo.blub", "app|foo.txt"], {"app": [[ 168 initGraph([
124 transformer, 169 "app|foo.blub",
125 new RewriteTransformer("txt", "out") 170 "app|foo.txt"
126 ]]}); 171 ], {
127 172 "app": [
173 [transformer, new RewriteTransformer("txt", "out")]
174 ]
175 });
176
128 transformer.pauseApply(); 177 transformer.pauseApply();
129 updateSources(["app|foo.blub", "app|foo.txt"]); 178 updateSources(["app|foo.blub", "app|foo.txt"]);
130 expectAsset("app|foo.out", "foo.out"); 179 expectAsset("app|foo.out", "foo.out");
131 expectNoAsset("app|foo.blub"); 180 expectNoAsset("app|foo.blub");
132 181
133 transformer.resumeApply(); 182 transformer.resumeApply();
134 buildShouldSucceed(); 183 buildShouldSucceed();
135 }); 184 });
136 185
137 test("blocks getting a consumed asset before apply is finished when a " 186 test(
187 "blocks getting a consumed asset before apply is finished when a "
138 "sibling hasn't finished applying", () { 188 "sibling hasn't finished applying", () {
139 var declaring = new DeclaringRewriteTransformer("blub", "blab") 189 var declaring = new DeclaringRewriteTransformer("blub", "blab")
140 ..consumePrimary = true; 190 ..consumePrimary = true;
141 var eager = new RewriteTransformer("txt", "out"); 191 var eager = new RewriteTransformer("txt", "out");
142 initGraph(["app|foo.blub", "app|foo.txt"], {"app": [[declaring, eager]]}); 192 initGraph([
143 193 "app|foo.blub",
194 "app|foo.txt"
195 ], {
196 "app": [
197 [declaring, eager]
198 ]
199 });
200
144 declaring.pauseApply(); 201 declaring.pauseApply();
145 eager.pauseApply(); 202 eager.pauseApply();
146 updateSources(["app|foo.blub", "app|foo.txt"]); 203 updateSources(["app|foo.blub", "app|foo.txt"]);
147 expectAssetDoesNotComplete("app|foo.blub"); 204 expectAssetDoesNotComplete("app|foo.blub");
148 205
149 declaring.resumeApply(); 206 declaring.resumeApply();
150 eager.resumeApply(); 207 eager.resumeApply();
151 expectNoAsset("app|foo.blub"); 208 expectNoAsset("app|foo.blub");
152 buildShouldSucceed(); 209 buildShouldSucceed();
153 }); 210 });
154 211
155 test("waits until apply is finished to get an overwritten asset", () { 212 test("waits until apply is finished to get an overwritten asset", () {
156 var transformer = new DeclaringRewriteTransformer("blub", "blub"); 213 var transformer = new DeclaringRewriteTransformer("blub", "blub");
157 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 214 initGraph([
215 "app|foo.blub"
216 ], {
217 "app": [
218 [transformer]
219 ]
220 });
158 221
159 transformer.pauseApply(); 222 transformer.pauseApply();
160 updateSources(["app|foo.blub"]); 223 updateSources(["app|foo.blub"]);
161 expectAssetDoesNotComplete("app|foo.blub"); 224 expectAssetDoesNotComplete("app|foo.blub");
162 225
163 transformer.resumeApply(); 226 transformer.resumeApply();
164 expectAsset("app|foo.blub", "foo.blub"); 227 expectAsset("app|foo.blub", "foo.blub");
165 buildShouldSucceed(); 228 buildShouldSucceed();
166 }); 229 });
167 230
168 // Regression test for #64. 231 // Regression test for #64.
169 test("a declaring transformer's output passes through a lazy transformer", 232 test("a declaring transformer's output passes through a lazy transformer",
170 () { 233 () {
171 var declaring = new DeclaringRewriteTransformer("one", "two"); 234 var declaring = new DeclaringRewriteTransformer("one", "two");
172 initGraph(["app|foo.one"], {"app": [ 235 initGraph([
173 [declaring], 236 "app|foo.one"
174 [new LazyRewriteTransformer("two", "three")] 237 ], {
175 ]}); 238 "app": [
239 [declaring],
240 [new LazyRewriteTransformer("two", "three")]
241 ]
242 });
176 243
177 updateSources(["app|foo.one"]); 244 updateSources(["app|foo.one"]);
178 // Give the transformers time to declare their assets. 245 // Give the transformers time to declare their assets.
179 schedule(pumpEventQueue); 246 schedule(pumpEventQueue);
180 247
181 expectAsset("app|foo.one", "foo"); 248 expectAsset("app|foo.one", "foo");
182 expectAsset("app|foo.two", "foo.two"); 249 expectAsset("app|foo.two", "foo.two");
183 expectAsset("app|foo.three", "foo.two.three"); 250 expectAsset("app|foo.three", "foo.two.three");
184 buildShouldSucceed(); 251 buildShouldSucceed();
185 252
186 modifyAsset("app|foo.one", "bar"); 253 modifyAsset("app|foo.one", "bar");
187 updateSources(["app|foo.one"]); 254 updateSources(["app|foo.one"]);
188 255
189 expectAsset("app|foo.one", "bar"); 256 expectAsset("app|foo.one", "bar");
190 expectAsset("app|foo.two", "bar.two"); 257 expectAsset("app|foo.two", "bar.two");
191 expectAsset("app|foo.three", "bar.two.three"); 258 expectAsset("app|foo.three", "bar.two.three");
192 buildShouldSucceed(); 259 buildShouldSucceed();
193 260
194 expect(declaring.numRuns, completion(equals(2))); 261 expect(declaring.numRuns, completion(equals(2)));
195 }); 262 });
196 263
197 test("a declaring transformer following a lazy transformer runs eagerly once " 264 test(
265 "a declaring transformer following a lazy transformer runs eagerly once "
198 "its input is available", () { 266 "its input is available", () {
199 var declaring = new DeclaringRewriteTransformer("two", "three"); 267 var declaring = new DeclaringRewriteTransformer("two", "three");
200 initGraph(["app|foo.in"], {"app": [ 268 initGraph([
201 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], 269 "app|foo.in"
202 [declaring] 270 ], {
203 ]}); 271 "app": [
272 [
273 new LazyAssetsTransformer(["app|out.one", "app|out.two"])
274 ],
275 [declaring]
276 ]
277 });
204 278
205 updateSources(["app|foo.in"]); 279 updateSources(["app|foo.in"]);
206 // Give the transformers time to declare their assets. 280 // Give the transformers time to declare their assets.
207 schedule(pumpEventQueue); 281 schedule(pumpEventQueue);
208 282
209 expectAsset("app|out.one", "app|out.one"); 283 expectAsset("app|out.one", "app|out.one");
210 buildShouldSucceed(); 284 buildShouldSucceed();
211 285
212 expect(declaring.numRuns, completion(equals(1))); 286 expect(declaring.numRuns, completion(equals(1)));
213 }); 287 });
214 288
215 test("a declaring transformer following a lazy transformer doesn't re-run if " 289 test(
290 "a declaring transformer following a lazy transformer doesn't re-run if "
216 "its input becomes available and then unavailable", () { 291 "its input becomes available and then unavailable", () {
217 var declaring = new DeclaringRewriteTransformer("two", "three"); 292 var declaring = new DeclaringRewriteTransformer("two", "three");
218 initGraph(["app|foo.in"], {"app": [ 293 initGraph([
219 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], 294 "app|foo.in"
220 [declaring] 295 ], {
221 ]}); 296 "app": [
297 [
298 new LazyAssetsTransformer(["app|out.one", "app|out.two"])
299 ],
300 [declaring]
301 ]
302 });
222 303
223 declaring.pauseApply(); 304 declaring.pauseApply();
224 updateSources(["app|foo.in"]); 305 updateSources(["app|foo.in"]);
225 // Give the transformers time to declare their assets. 306 // Give the transformers time to declare their assets.
226 schedule(pumpEventQueue); 307 schedule(pumpEventQueue);
227 308
228 // Start [declaring] running, because its input became available. 309 // Start [declaring] running, because its input became available.
229 expectAsset("app|out.one", "app|out.one"); 310 expectAsset("app|out.one", "app|out.one");
230 311
231 // Make sure we're blocking on [declaring.apply]. 312 // Make sure we're blocking on [declaring.apply].
(...skipping 12 matching lines...) Expand all
244 // Once we make a request, [declaring] should force the lazy transformer and 325 // Once we make a request, [declaring] should force the lazy transformer and
245 // then run itself. 326 // then run itself.
246 expectAsset("app|out.three", "app|out.two.three"); 327 expectAsset("app|out.three", "app|out.two.three");
247 buildShouldSucceed(); 328 buildShouldSucceed();
248 329
249 // Now [declaring] should have run twice. This ensures that it didn't use 330 // Now [declaring] should have run twice. This ensures that it didn't use
250 // its original output for some reason. 331 // its original output for some reason.
251 expect(declaring.numRuns, completion(equals(2))); 332 expect(declaring.numRuns, completion(equals(2)));
252 }); 333 });
253 334
254 test("a declaring transformer following a lazy transformer does re-run if " 335 test(
336 "a declaring transformer following a lazy transformer does re-run if "
255 "its input becomes available, it's forced, and then its input becomes " 337 "its input becomes available, it's forced, and then its input becomes "
256 "unavailable", () { 338 "unavailable", () {
257 var declaring = new DeclaringRewriteTransformer("two", "three"); 339 var declaring = new DeclaringRewriteTransformer("two", "three");
258 initGraph(["app|foo.in"], {"app": [ 340 initGraph([
259 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], 341 "app|foo.in"
260 [declaring] 342 ], {
261 ]}); 343 "app": [
344 [
345 new LazyAssetsTransformer(["app|out.one", "app|out.two"])
346 ],
347 [declaring]
348 ]
349 });
262 350
263 declaring.pauseApply(); 351 declaring.pauseApply();
264 updateSources(["app|foo.in"]); 352 updateSources(["app|foo.in"]);
265 353
266 // Give the transformers time to declare their assets. 354 // Give the transformers time to declare their assets.
267 schedule(pumpEventQueue); 355 schedule(pumpEventQueue);
268 356
269 // Start [declaring] running, because its input became available. 357 // Start [declaring] running, because its input became available.
270 expectAsset("app|out.one", "app|out.one"); 358 expectAsset("app|out.one", "app|out.one");
271 359
(...skipping 10 matching lines...) Expand all
282 declaring.resumeApply(); 370 declaring.resumeApply();
283 buildShouldSucceed(); 371 buildShouldSucceed();
284 372
285 // [declaring] should have run twice, once for its original input and once 373 // [declaring] should have run twice, once for its original input and once
286 // after the input changed because it was forced. 374 // after the input changed because it was forced.
287 expect(declaring.numRuns, completion(equals(2))); 375 expect(declaring.numRuns, completion(equals(2)));
288 }); 376 });
289 377
290 group("with an error in declareOutputs", () { 378 group("with an error in declareOutputs", () {
291 test("still runs apply", () { 379 test("still runs apply", () {
292 initGraph(["app|foo.txt"], {"app": [[ 380 initGraph([
293 new DeclaringBadTransformer("app|out.txt", 381 "app|foo.txt"
294 declareError: true, applyError: false) 382 ], {
295 ]]}); 383 "app": [
384 [
385 new DeclaringBadTransformer("app|out.txt",
386 declareError: true, applyError: false)
387 ]
388 ]
389 });
296 390
297 updateSources(["app|foo.txt"]); 391 updateSources(["app|foo.txt"]);
298 expectAsset("app|out.txt", "bad out"); 392 expectAsset("app|out.txt", "bad out");
299 expectAsset("app|foo.txt", "foo"); 393 expectAsset("app|foo.txt", "foo");
300 buildShouldFail([isTransformerException(BadTransformer.ERROR)]); 394 buildShouldFail([isTransformerException(BadTransformer.ERROR)]);
301 }); 395 });
302 396
303 test("waits for apply to complete before passing through the input even if " 397 test(
398 "waits for apply to complete before passing through the input even if "
304 "consumePrimary was called", () { 399 "consumePrimary was called", () {
305 var transformer = new DeclaringBadTransformer("app|out.txt", 400 var transformer = new DeclaringBadTransformer("app|out.txt",
306 declareError: true, applyError: false)..consumePrimary = true; 401 declareError: true, applyError: false)
307 initGraph(["app|foo.txt"], {"app": [[transformer]]}); 402 ..consumePrimary = true;
403 initGraph([
404 "app|foo.txt"
405 ], {
406 "app": [
407 [transformer]
408 ]
409 });
308 410
309 transformer.pauseApply(); 411 transformer.pauseApply();
310 updateSources(["app|foo.txt"]); 412 updateSources(["app|foo.txt"]);
311 expectAssetDoesNotComplete("app|out.txt"); 413 expectAssetDoesNotComplete("app|out.txt");
312 expectAssetDoesNotComplete("app|foo.txt"); 414 expectAssetDoesNotComplete("app|foo.txt");
313 415
314 transformer.resumeApply(); 416 transformer.resumeApply();
315 expectAsset("app|out.txt", "bad out"); 417 expectAsset("app|out.txt", "bad out");
316 expectNoAsset("app|foo.txt"); 418 expectNoAsset("app|foo.txt");
317 buildShouldFail([isTransformerException(BadTransformer.ERROR)]); 419 buildShouldFail([isTransformerException(BadTransformer.ERROR)]);
318 }); 420 });
319 }); 421 });
320 422
321 test("with an error in apply still passes through the input", () { 423 test("with an error in apply still passes through the input", () {
322 initGraph(["app|foo.txt"], {"app": [[ 424 initGraph([
323 new DeclaringBadTransformer("app|out.txt", 425 "app|foo.txt"
324 declareError: false, applyError: true) 426 ], {
325 ]]}); 427 "app": [
428 [
429 new DeclaringBadTransformer("app|out.txt",
430 declareError: false, applyError: true)
431 ]
432 ]
433 });
326 434
327 updateSources(["app|foo.txt"]); 435 updateSources(["app|foo.txt"]);
328 expectNoAsset("app|out.txt"); 436 expectNoAsset("app|out.txt");
329 expectAsset("app|foo.txt", "foo"); 437 expectAsset("app|foo.txt", "foo");
330 buildShouldFail([isTransformerException(BadTransformer.ERROR)]); 438 buildShouldFail([isTransformerException(BadTransformer.ERROR)]);
331 }); 439 });
332 440
333 test("can emit outputs it didn't declare", () { 441 test("can emit outputs it didn't declare", () {
334 initGraph(["app|foo.txt"], {"app": [ 442 initGraph([
335 [new DeclareAssetsTransformer([], emitted: ["app|out.txt"])] 443 "app|foo.txt"
336 ]}); 444 ], {
445 "app": [
446 [
447 new DeclareAssetsTransformer([], emitted: ["app|out.txt"])
448 ]
449 ]
450 });
337 451
338 updateSources(["app|foo.txt"]); 452 updateSources(["app|foo.txt"]);
339 // There's probably going to be some time when "out.txt" is unavailable, 453 // There's probably going to be some time when "out.txt" is unavailable,
340 // since it was undeclared. 454 // since it was undeclared.
341 schedule(pumpEventQueue); 455 schedule(pumpEventQueue);
342 expectAsset("app|out.txt", "app|out.txt"); 456 expectAsset("app|out.txt", "app|out.txt");
343 buildShouldSucceed(); 457 buildShouldSucceed();
344 }); 458 });
345 459
346 test("can overwrite the primary input even if it declared that it wouldn't", 460 test("can overwrite the primary input even if it declared that it wouldn't",
347 () { 461 () {
348 var transformer = new DeclareAssetsTransformer( 462 var transformer =
349 [], emitted: ["app|foo.txt"]); 463 new DeclareAssetsTransformer([], emitted: ["app|foo.txt"]);
350 initGraph(["app|foo.txt"], {"app": [[transformer]]}); 464 initGraph([
465 "app|foo.txt"
466 ], {
467 "app": [
468 [transformer]
469 ]
470 });
351 471
352 transformer.pauseApply(); 472 transformer.pauseApply();
353 updateSources(["app|foo.txt"]); 473 updateSources(["app|foo.txt"]);
354 expectAsset("app|foo.txt", "foo"); 474 expectAsset("app|foo.txt", "foo");
355 475
356 transformer.resumeApply(); 476 transformer.resumeApply();
357 schedule(pumpEventQueue); 477 schedule(pumpEventQueue);
358 expectAsset("app|foo.txt", "app|foo.txt"); 478 expectAsset("app|foo.txt", "app|foo.txt");
359 buildShouldSucceed(); 479 buildShouldSucceed();
360 }); 480 });
361 481
362 test("can declare outputs it doesn't emit", () { 482 test("can declare outputs it doesn't emit", () {
363 initGraph(["app|foo.txt"], {"app": [ 483 initGraph([
364 [new DeclareAssetsTransformer(["app|out.txt"], emitted: [])] 484 "app|foo.txt"
365 ]}); 485 ], {
486 "app": [
487 [
488 new DeclareAssetsTransformer(["app|out.txt"], emitted: [])
489 ]
490 ]
491 });
366 492
367 updateSources(["app|foo.txt"]); 493 updateSources(["app|foo.txt"]);
368 expectNoAsset("app|out.txt"); 494 expectNoAsset("app|out.txt");
369 buildShouldSucceed(); 495 buildShouldSucceed();
370 }); 496 });
371 } 497 }
OLDNEW
« no previous file with comments | « packages/barback/test/package_graph/collisions_test.dart ('k') | packages/barback/test/package_graph/errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698