| OLD | NEW |
| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
| 10 import 'package:barback/src/utils.dart'; | 10 import 'package:barback/src/utils.dart'; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 }); | 425 }); |
| 426 | 426 |
| 427 expectNoAsset("app|foo.out"); | 427 expectNoAsset("app|foo.out"); |
| 428 buildShouldSucceed(); | 428 buildShouldSucceed(); |
| 429 | 429 |
| 430 schedule(() { | 430 schedule(() { |
| 431 expect(transformer.numRuns, equals(1)); | 431 expect(transformer.numRuns, equals(1)); |
| 432 }); | 432 }); |
| 433 }); | 433 }); |
| 434 | 434 |
| 435 test("restarts processing if a change to a new secondary input occurs during " |
| 436 "processing", () { |
| 437 var transformer = new ManyToOneTransformer("txt"); |
| 438 initGraph({ |
| 439 "app|foo.txt": "bar.inc", |
| 440 "app|bar.inc": "bar" |
| 441 }, {"app": [[transformer]]}); |
| 442 |
| 443 transformer.pauseApply(); |
| 444 |
| 445 updateSources(["app|foo.txt", "app|bar.inc"]); |
| 446 // Wait for the transform to start. |
| 447 schedule(() => transformer.started); |
| 448 |
| 449 // Give the transform time to load bar.inc the first time. |
| 450 schedule(pumpEventQueue); |
| 451 |
| 452 // Now update the secondary input before the transform finishes. |
| 453 modifyAsset("app|bar.inc", "baz"); |
| 454 schedule(() => updateSources(["app|bar.inc"])); |
| 455 // Give bar.inc enough time to be loaded and marked available before the |
| 456 // transformer completes. |
| 457 schedule(pumpEventQueue); |
| 458 |
| 459 schedule(transformer.resumeApply); |
| 460 |
| 461 expectAsset("app|foo.out", "baz"); |
| 462 buildShouldSucceed(); |
| 463 |
| 464 schedule(() { |
| 465 expect(transformer.numRuns, equals(2)); |
| 466 }); |
| 467 }); |
| 468 |
| 469 test("doesn't restart processing if a change to an old secondary input " |
| 470 "occurs during processing", () { |
| 471 var transformer = new ManyToOneTransformer("txt"); |
| 472 initGraph({ |
| 473 "app|foo.txt": "bar.inc", |
| 474 "app|bar.inc": "bar", |
| 475 "app|baz.inc": "baz" |
| 476 }, {"app": [[transformer]]}); |
| 477 |
| 478 updateSources(["app|foo.txt", "app|bar.inc", "app|baz.inc"]); |
| 479 expectAsset("app|foo.out", "bar"); |
| 480 buildShouldSucceed(); |
| 481 |
| 482 schedule(transformer.pauseApply); |
| 483 modifyAsset("app|foo.txt", "baz.inc"); |
| 484 schedule(() { |
| 485 updateSources(["app|foo.txt"]); |
| 486 // Wait for the transform to start. |
| 487 return transformer.started; |
| 488 }); |
| 489 |
| 490 // Now update the old secondary input before the transform finishes. |
| 491 modifyAsset("app|bar.inc", "new bar"); |
| 492 schedule(() => updateSources(["app|bar.inc"])); |
| 493 // Give bar.inc enough time to be loaded and marked available before the |
| 494 // transformer completes. |
| 495 schedule(pumpEventQueue); |
| 496 |
| 497 schedule(transformer.resumeApply); |
| 498 |
| 499 expectAsset("app|foo.out", "baz"); |
| 500 buildShouldSucceed(); |
| 501 |
| 502 schedule(() { |
| 503 // Should have run once the first time, then again when switching to |
| 504 // baz.inc. Should not run a third time because of bar.inc being modified. |
| 505 expect(transformer.numRuns, equals(2)); |
| 506 }); |
| 507 }); |
| 508 |
| 435 test("handles an output moving from one transformer to another", () { | 509 test("handles an output moving from one transformer to another", () { |
| 436 // In the first run, "shared.out" is created by the "a.a" transformer. | 510 // In the first run, "shared.out" is created by the "a.a" transformer. |
| 437 initGraph({ | 511 initGraph({ |
| 438 "app|a.a": "a.out,shared.out", | 512 "app|a.a": "a.out,shared.out", |
| 439 "app|b.b": "b.out" | 513 "app|b.b": "b.out" |
| 440 }, {"app": [ | 514 }, {"app": [ |
| 441 [new OneToManyTransformer("a"), new OneToManyTransformer("b")] | 515 [new OneToManyTransformer("a"), new OneToManyTransformer("b")] |
| 442 ]}); | 516 ]}); |
| 443 | 517 |
| 444 updateSources(["app|a.a", "app|b.b"]); | 518 updateSources(["app|a.a", "app|b.b"]); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 schedule(() => updateSources(["pkg2|foo.txt"])); | 888 schedule(() => updateSources(["pkg2|foo.txt"])); |
| 815 expectAsset("pkg1|foo.out", "foo.out"); | 889 expectAsset("pkg1|foo.out", "foo.out"); |
| 816 buildShouldNotBeDone(); | 890 buildShouldNotBeDone(); |
| 817 | 891 |
| 818 // Now that the provider is unpaused, pkg2's transforms finish and the | 892 // Now that the provider is unpaused, pkg2's transforms finish and the |
| 819 // overall build succeeds. | 893 // overall build succeeds. |
| 820 resumeProvider(); | 894 resumeProvider(); |
| 821 buildShouldSucceed(); | 895 buildShouldSucceed(); |
| 822 }); | 896 }); |
| 823 } | 897 } |
| OLD | NEW |