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

Side by Side Diff: pkg/barback/test/package_graph/transform/pass_through_test.dart

Issue 191223004: Add BaseTransform.consumePrimary to barback. (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
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.transform.pass_through_test; 5 library barback.test.package_graph.transform.pass_through_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';
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 buildShouldSucceed(); 263 buildShouldSucceed();
264 264
265 rewrite.pauseIsPrimary("app|foo.txt"); 265 rewrite.pauseIsPrimary("app|foo.txt");
266 updateSources(["app|foo.txt"]); 266 updateSources(["app|foo.txt"]);
267 expectAssetDoesNotComplete("app|foo.txt"); 267 expectAssetDoesNotComplete("app|foo.txt");
268 268
269 rewrite.resumeIsPrimary("app|foo.txt"); 269 rewrite.resumeIsPrimary("app|foo.txt");
270 expectAsset("app|foo.txt", "foo.txt"); 270 expectAsset("app|foo.txt", "foo.txt");
271 buildShouldSucceed(); 271 buildShouldSucceed();
272 }); 272 });
273
Bob Nystrom 2014/03/07 21:54:11 Might be worth making a separate suite for these.
nweiz 2014/03/11 21:44:05 Done.
274 group("consumeInput", () {
275 test("a transform consumes its input without overwriting it", () {
276 initGraph([
277 "app|foo.txt"
278 ], {
279 "app": [[new RewriteTransformer("txt", "out")..consumePrimary = true]]
280 });
281
282 updateSources(["app|foo.txt"]);
283 expectAsset("app|foo.out", "foo.out");
284 expectNoAsset("app|foo.txt");
285 buildShouldSucceed();
286 });
287
288 test("a transform consumes its input while a sibling overwrites it", () {
289 initGraph([
290 "app|foo.txt"
291 ], {
292 "app": [[
293 new RewriteTransformer("txt", "out")..consumePrimary = true,
294 new RewriteTransformer("txt", "txt")
295 ]]
296 });
297
298 updateSources(["app|foo.txt"]);
299 expectAsset("app|foo.out", "foo.out");
300 expectAsset("app|foo.txt", "foo.txt");
301 buildShouldSucceed();
302 });
303
304 test("a transform stops consuming its input", () {
305 initGraph({
306 "app|foo.txt": "yes"
307 }, {
308 "app": [[
309 new ConditionallyConsumePrimaryTransformer("txt", "out", "yes")
310 ]]
311 });
312
313 updateSources(["app|foo.txt"]);
314 expectAsset("app|foo.out", "yes.out");
315 expectNoAsset("app|foo.txt");
316 buildShouldSucceed();
317
318 modifyAsset("app|foo.txt", "no");
319 updateSources(["app|foo.txt"]);
320 expectAsset("app|foo.out", "no.out");
321 expectAsset("app|foo.txt", "no");
322 buildShouldSucceed();
323 });
324
325 test("a transform stops consuming its input but a sibling is still "
326 "consuming it", () {
Bob Nystrom 2014/03/07 21:54:11 It's a subset of this test, but it might be nice t
nweiz 2014/03/11 21:44:05 Done.
327 initGraph({
328 "app|foo.txt": "yes"
329 }, {
330 "app": [[
331 new RewriteTransformer("txt", "one")..consumePrimary = true,
332 new ConditionallyConsumePrimaryTransformer("txt", "two", "yes")
333 ]]
334 });
335
336 updateSources(["app|foo.txt"]);
337 expectAsset("app|foo.one", "yes.one");
338 expectAsset("app|foo.two", "yes.two");
339 expectNoAsset("app|foo.txt");
340 buildShouldSucceed();
341
342 modifyAsset("app|foo.txt", "no");
343 updateSources(["app|foo.txt"]);
344 expectAsset("app|foo.one", "no.one");
345 expectAsset("app|foo.two", "no.two");
346 expectNoAsset("app|foo.txt");
347 buildShouldSucceed();
348 });
349
350 test("a transform consumes its input and emits nothing", () {
351 initGraph([
352 "app|foo.txt"
353 ], {
354 "app": [[new EmitNothingTransformer("txt")..consumePrimary = true]]
355 });
356
357 updateSources(["app|foo.txt"]);
358 expectNoAsset("app|foo.txt");
359 buildShouldSucceed();
360 });
361
362 test("a transform consumes its input, then is removed", () {
363 initGraph([
364 "app|foo.txt"
365 ], {
366 "app": [[new RewriteTransformer("txt", "out")..consumePrimary = true]]
367 });
368
369 updateSources(["app|foo.txt"]);
370 expectAsset("app|foo.out", "foo.out");
371 expectNoAsset("app|foo.txt");
372 buildShouldSucceed();
373
374 updateTransformers("app", [[]]);
375 expectNoAsset("app|foo.out");
376 expectAsset("app|foo.txt", "foo");
377 buildShouldSucceed();
378 });
379
380 test("a transform consumes its input and emits nothing, then is removed",
381 () {
382 initGraph([
383 "app|foo.txt"
384 ], {
385 "app": [[new EmitNothingTransformer("txt")..consumePrimary = true]]
386 });
387
388 updateSources(["app|foo.txt"]);
389 expectNoAsset("app|foo.txt");
390 buildShouldSucceed();
391
392 updateTransformers("app", [[]]);
393 expectAsset("app|foo.txt", "foo");
394 buildShouldSucceed();
395 });
396
397 test("a transform which consumes its input is added", () {
398 initGraph([
399 "app|foo.txt"
400 ], {
401 "app": [[]]
402 });
403
404 updateSources(["app|foo.txt"]);
405 expectNoAsset("app|foo.out");
406 expectAsset("app|foo.txt", "foo");
407 buildShouldSucceed();
408
409 updateTransformers("app", [[
410 new RewriteTransformer("txt", "out")..consumePrimary = true
411 ]]);
412 expectAsset("app|foo.out", "foo.out");
413 expectNoAsset("app|foo.txt");
414 buildShouldSucceed();
415 });
416 });
273 } 417 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698