| OLD | NEW |
| 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.concurrency_test; | 7 library barback.test.package_graph.transform.concurrency_test; |
| 8 | 8 |
| 9 import 'package:barback/src/utils.dart'; | 9 import 'package:barback/src/utils.dart'; |
| 10 import 'package:scheduled_test/scheduled_test.dart'; | 10 import 'package:scheduled_test/scheduled_test.dart'; |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 532 |
| 533 transformer2.resumePrimaryInput(); | 533 transformer2.resumePrimaryInput(); |
| 534 transformer1.resumeApply(); | 534 transformer1.resumeApply(); |
| 535 | 535 |
| 536 expectAsset("app|foo.out", "new foo.mid.out"); | 536 expectAsset("app|foo.out", "new foo.mid.out"); |
| 537 buildShouldSucceed(); | 537 buildShouldSucceed(); |
| 538 | 538 |
| 539 expect(transformer1.numRuns, completion(equals(2))); | 539 expect(transformer1.numRuns, completion(equals(2))); |
| 540 expect(transformer2.numRuns, completion(equals(2))); | 540 expect(transformer2.numRuns, completion(equals(2))); |
| 541 }); | 541 }); |
| 542 |
| 543 // Regression test for issue 19038. |
| 544 test("a secondary input that's marked dirty followed by the primary input " |
| 545 "being synchronously marked dirty re-runs a transformer", () { |
| 546 // Issue 19038 was caused by the following sequence of events: |
| 547 // |
| 548 // * Several inputs are marked dirty at once, causing dirty events to |
| 549 // propagate synchronously throughout the transform graph. |
| 550 // |
| 551 // * A transform (ManyToOneTransformer in this test case) has a secondary |
| 552 // input ("one.in") and a primary input ("foo.txt") that will both be |
| 553 // marked dirty. |
| 554 // |
| 555 // * The secondary input is marked dirty before the primary input. This |
| 556 // causes the transform to start running `apply`. Since as far as it knows |
| 557 // its primary input is still available, it passes that input to `apply`. |
| 558 // |
| 559 // * Now the primary input is marked dirty. The transform node checks to see |
| 560 // if this primary input has already been added to the transform |
| 561 // controller. This is where the bug existed: the answer to this was |
| 562 // incorrectly "no" until after some asynchronous processing occurred. |
| 563 // |
| 564 // * Since the transform thought the primary input hadn't yet been passed to |
| 565 // the transform controller, it didn't bother restarting the transform, |
| 566 // causing the old output to be preserved incorrectly. |
| 567 initGraph({ |
| 568 "app|foo.txt": "one", |
| 569 "app|one.in": "1", |
| 570 "app|two.in": "2" |
| 571 }, {"app": [ |
| 572 // We need to use CheckContentTransformer here so that |
| 573 // ManyToOneTransformer reads its primary input from memory rather than |
| 574 // from the filesystem. If it read from the filesystem, it might |
| 575 // accidentally get the correct output despite accessing the incorrect |
| 576 // asset, which would cause false positives for the test. |
| 577 [new CheckContentTransformer(new RegExp("one|two"), ".in")], |
| 578 [new ManyToOneTransformer("txt")] |
| 579 ]}); |
| 580 |
| 581 updateSources(["app|foo.txt", "app|one.in", "app|two.in"]); |
| 582 expectAsset("app|foo.out", "1"); |
| 583 buildShouldSucceed(); |
| 584 |
| 585 modifyAsset("app|foo.txt", "two"); |
| 586 |
| 587 // It's important that "one.in" come first in this list, since |
| 588 // ManyToOneTransformer needs to see its secondary input change first. |
| 589 updateSources(["app|one.in", "app|foo.txt"]); |
| 590 |
| 591 expectAsset("app|foo.out", "2"); |
| 592 buildShouldSucceed(); |
| 593 }); |
| 542 } | 594 } |
| OLD | NEW |