| 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 ]}); | 483 ]}); |
| 484 | 484 |
| 485 rewrite.pauseApply(); | 485 rewrite.pauseApply(); |
| 486 updateSources(["app|foo.in", "app|bar.txt"]); | 486 updateSources(["app|foo.in", "app|bar.txt"]); |
| 487 expectAssetDoesNotComplete("app|bar.out"); | 487 expectAssetDoesNotComplete("app|bar.out"); |
| 488 | 488 |
| 489 rewrite.resumeApply(); | 489 rewrite.resumeApply(); |
| 490 expectAsset("app|bar.out", "foo.in"); | 490 expectAsset("app|bar.out", "foo.in"); |
| 491 buildShouldSucceed(); | 491 buildShouldSucceed(); |
| 492 }); | 492 }); |
| 493 | |
| 494 test("materializes a passed-through asset that was emitted before it was " | |
| 495 "available", () { | |
| 496 initGraph(["app|foo.in"], {"app": [ | |
| 497 [new RewriteTransformer("txt", "txt")] | |
| 498 ]}); | |
| 499 | |
| 500 pauseProvider(); | |
| 501 updateSources(["app|foo.in"]); | |
| 502 expectAssetDoesNotComplete("app|foo.in"); | |
| 503 | |
| 504 resumeProvider(); | |
| 505 expectAsset("app|foo.in", "foo"); | |
| 506 buildShouldSucceed(); | |
| 507 }); | |
| 508 | |
| 509 test("re-runs if the primary input is invalidated before accessing", () { | |
| 510 var transformer1 = new RewriteTransformer("txt", "mid"); | |
| 511 var transformer2 = new RewriteTransformer("mid", "out"); | |
| 512 | |
| 513 initGraph([ | |
| 514 "app|foo.txt" | |
| 515 ], {"app": [ | |
| 516 [transformer1], | |
| 517 [transformer2] | |
| 518 ]}); | |
| 519 | |
| 520 transformer2.pausePrimaryInput(); | |
| 521 updateSources(["app|foo.txt"]); | |
| 522 | |
| 523 // Wait long enough to ensure that transformer1 has completed and | |
| 524 // transformer2 has started. | |
| 525 schedule(pumpEventQueue); | |
| 526 | |
| 527 // Update the source again so that transformer1 invalidates the primary | |
| 528 // input of transformer2. | |
| 529 transformer1.pauseApply(); | |
| 530 modifyAsset("app|foo.txt", "new foo"); | |
| 531 updateSources(["app|foo.txt"]); | |
| 532 | |
| 533 transformer2.resumePrimaryInput(); | |
| 534 transformer1.resumeApply(); | |
| 535 | |
| 536 expectAsset("app|foo.out", "new foo.mid.out"); | |
| 537 buildShouldSucceed(); | |
| 538 | |
| 539 expect(transformer1.numRuns, completion(equals(2))); | |
| 540 expect(transformer2.numRuns, completion(equals(2))); | |
| 541 }); | |
| 542 } | 493 } |
| OLD | NEW |