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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/barback/test/package_graph/transform/pass_through_test.dart
diff --git a/pkg/barback/test/package_graph/transform/pass_through_test.dart b/pkg/barback/test/package_graph/transform/pass_through_test.dart
index eb90418385fd1d0b89e218f5253f261f46f2840a..c8b1d7ecc139c905df267bd3c368731a134b1caa 100644
--- a/pkg/barback/test/package_graph/transform/pass_through_test.dart
+++ b/pkg/barback/test/package_graph/transform/pass_through_test.dart
@@ -270,4 +270,148 @@ main() {
expectAsset("app|foo.txt", "foo.txt");
buildShouldSucceed();
});
+
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.
+ group("consumeInput", () {
+ test("a transform consumes its input without overwriting it", () {
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [[new RewriteTransformer("txt", "out")..consumePrimary = true]]
+ });
+
+ updateSources(["app|foo.txt"]);
+ expectAsset("app|foo.out", "foo.out");
+ expectNoAsset("app|foo.txt");
+ buildShouldSucceed();
+ });
+
+ test("a transform consumes its input while a sibling overwrites it", () {
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [[
+ new RewriteTransformer("txt", "out")..consumePrimary = true,
+ new RewriteTransformer("txt", "txt")
+ ]]
+ });
+
+ updateSources(["app|foo.txt"]);
+ expectAsset("app|foo.out", "foo.out");
+ expectAsset("app|foo.txt", "foo.txt");
+ buildShouldSucceed();
+ });
+
+ test("a transform stops consuming its input", () {
+ initGraph({
+ "app|foo.txt": "yes"
+ }, {
+ "app": [[
+ new ConditionallyConsumePrimaryTransformer("txt", "out", "yes")
+ ]]
+ });
+
+ updateSources(["app|foo.txt"]);
+ expectAsset("app|foo.out", "yes.out");
+ expectNoAsset("app|foo.txt");
+ buildShouldSucceed();
+
+ modifyAsset("app|foo.txt", "no");
+ updateSources(["app|foo.txt"]);
+ expectAsset("app|foo.out", "no.out");
+ expectAsset("app|foo.txt", "no");
+ buildShouldSucceed();
+ });
+
+ test("a transform stops consuming its input but a sibling is still "
+ "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.
+ initGraph({
+ "app|foo.txt": "yes"
+ }, {
+ "app": [[
+ new RewriteTransformer("txt", "one")..consumePrimary = true,
+ new ConditionallyConsumePrimaryTransformer("txt", "two", "yes")
+ ]]
+ });
+
+ updateSources(["app|foo.txt"]);
+ expectAsset("app|foo.one", "yes.one");
+ expectAsset("app|foo.two", "yes.two");
+ expectNoAsset("app|foo.txt");
+ buildShouldSucceed();
+
+ modifyAsset("app|foo.txt", "no");
+ updateSources(["app|foo.txt"]);
+ expectAsset("app|foo.one", "no.one");
+ expectAsset("app|foo.two", "no.two");
+ expectNoAsset("app|foo.txt");
+ buildShouldSucceed();
+ });
+
+ test("a transform consumes its input and emits nothing", () {
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [[new EmitNothingTransformer("txt")..consumePrimary = true]]
+ });
+
+ updateSources(["app|foo.txt"]);
+ expectNoAsset("app|foo.txt");
+ buildShouldSucceed();
+ });
+
+ test("a transform consumes its input, then is removed", () {
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [[new RewriteTransformer("txt", "out")..consumePrimary = true]]
+ });
+
+ updateSources(["app|foo.txt"]);
+ expectAsset("app|foo.out", "foo.out");
+ expectNoAsset("app|foo.txt");
+ buildShouldSucceed();
+
+ updateTransformers("app", [[]]);
+ expectNoAsset("app|foo.out");
+ expectAsset("app|foo.txt", "foo");
+ buildShouldSucceed();
+ });
+
+ test("a transform consumes its input and emits nothing, then is removed",
+ () {
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [[new EmitNothingTransformer("txt")..consumePrimary = true]]
+ });
+
+ updateSources(["app|foo.txt"]);
+ expectNoAsset("app|foo.txt");
+ buildShouldSucceed();
+
+ updateTransformers("app", [[]]);
+ expectAsset("app|foo.txt", "foo");
+ buildShouldSucceed();
+ });
+
+ test("a transform which consumes its input is added", () {
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [[]]
+ });
+
+ updateSources(["app|foo.txt"]);
+ expectNoAsset("app|foo.out");
+ expectAsset("app|foo.txt", "foo");
+ buildShouldSucceed();
+
+ updateTransformers("app", [[
+ new RewriteTransformer("txt", "out")..consumePrimary = true
+ ]]);
+ expectAsset("app|foo.out", "foo.out");
+ expectNoAsset("app|foo.txt");
+ buildShouldSucceed();
+ });
+ });
}

Powered by Google App Engine
This is Rietveld 408576698