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

Unified Diff: pkg/barback/test/package_graph/declaring_transformer_test.dart

Issue 243103003: Run declaring transformers eagerly if possible, even if their inputs are deferred. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/barback/lib/src/transform_node.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/test/package_graph/declaring_transformer_test.dart
diff --git a/pkg/barback/test/package_graph/declaring_transformer_test.dart b/pkg/barback/test/package_graph/declaring_transformer_test.dart
index 19ac9ce6673495945cd102bd4070968d623c1b81..13efe74d7a096b00d082a8efbab3b2e8a7a2242e 100644
--- a/pkg/barback/test/package_graph/declaring_transformer_test.dart
+++ b/pkg/barback/test/package_graph/declaring_transformer_test.dart
@@ -88,6 +88,55 @@ main() {
buildShouldSucceed();
});
+ test("a declaring transformer following a lazy transformer runs eagerly once "
+ "its input is available", () {
+ var declaring = new DeclaringRewriteTransformer("two", "three");
+ initGraph(["app|foo.in"], {"app": [
+ [new LazyAssetsTransformer(["app|out.one", "app|out.two"])],
+ [declaring]
+ ]});
+
+ updateSources(["app|foo.in"]);
+ expectAsset("app|out.one", "app|out.one");
+ buildShouldSucceed();
+
+ expect(declaring.numRuns, completion(equals(1)));
+ });
+
+ test("a declaring transformer following a lazy transformer doesn't re-run if "
+ "its input becomes available and then unavailable", () {
+ var declaring = new DeclaringRewriteTransformer("two", "three");
+ initGraph(["app|foo.in"], {"app": [
+ [new LazyAssetsTransformer(["app|out.one", "app|out.two"])],
+ [declaring]
+ ]});
+
+ // Start [declaring] running, because its input became available.
+ declaring.pauseApply();
+ updateSources(["app|foo.in"]);
+ expectAsset("app|out.one", "app|out.one");
+ expectAssetDoesNotComplete("app|out.three");
+
+ // Now [declaring]'s input is dirty, so it shouldn't re-run without an
+ // explicit request.
+ updateSources(["app|foo.in"]);
+ declaring.resumeApply();
+ buildShouldSucceed();
+
+ // [declaring] should only have run once, despite its input changing. After
+ // the first run, it should be awaiting a force() call.
+ expect(declaring.numRuns, completion(equals(1)));
+
+ // Once we make a request, [declaring] should force the lazy transformer and
+ // then run itself.
+ expectAsset("app|out.three", "app|out.two.three");
+ buildShouldSucceed();
+
+ // Now [declaring] should have run twice. This ensures that it didn't use
+ // its original output for some reason.
+ expect(declaring.numRuns, completion(equals(2)));
+ });
+
group("with an error in declareOutputs", () {
test("still runs apply", () {
initGraph(["app|foo.txt"], {"app": [[
« no previous file with comments | « pkg/barback/lib/src/transform_node.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698