Index: packages/barback/test/package_graph/declaring_transformer_test.dart |
diff --git a/packages/barback/test/package_graph/declaring_transformer_test.dart b/packages/barback/test/package_graph/declaring_transformer_test.dart |
index aa830dfde0bd555064805def4d46a706d200003f..aef3299d129732d28b39e0b2ba4592338eba8131 100644 |
--- a/packages/barback/test/package_graph/declaring_transformer_test.dart |
+++ b/packages/barback/test/package_graph/declaring_transformer_test.dart |
@@ -4,7 +4,6 @@ |
library barback.test.package_graph.declaring_transformer_test; |
-import 'package:barback/barback.dart'; |
import 'package:barback/src/utils.dart'; |
import 'package:scheduled_test/scheduled_test.dart'; |
@@ -14,36 +13,52 @@ main() { |
initConfig(); |
test("gets a declared output with a different path", () { |
- initGraph(["app|foo.blub"], {"app": [ |
- [new DeclaringRewriteTransformer("blub", "blab")] |
- ]}); |
+ initGraph([ |
+ "app|foo.blub" |
+ ], { |
+ "app": [ |
+ [new DeclaringRewriteTransformer("blub", "blab")] |
+ ] |
+ }); |
updateSources(["app|foo.blub"]); |
expectAsset("app|foo.blab", "foo.blab"); |
buildShouldSucceed(); |
}); |
test("gets a declared output with the same path", () { |
- initGraph(["app|foo.blub"], {"app": [ |
- [new DeclaringRewriteTransformer("blub", "blub")] |
- ]}); |
+ initGraph([ |
+ "app|foo.blub" |
+ ], { |
+ "app": [ |
+ [new DeclaringRewriteTransformer("blub", "blub")] |
+ ] |
+ }); |
updateSources(["app|foo.blub"]); |
expectAsset("app|foo.blub", "foo.blub"); |
buildShouldSucceed(); |
}); |
test("gets a passed-through asset", () { |
- initGraph(["app|foo.blub"], {"app": [ |
- [new DeclaringRewriteTransformer("blub", "blab")] |
- ]}); |
+ initGraph([ |
+ "app|foo.blub" |
+ ], { |
+ "app": [ |
+ [new DeclaringRewriteTransformer("blub", "blab")] |
+ ] |
+ }); |
updateSources(["app|foo.blub"]); |
expectAsset("app|foo.blub", "foo"); |
buildShouldSucceed(); |
}); |
test("doesn't get a consumed asset", () { |
- initGraph(["app|foo.blub"], {"app": [ |
- [new DeclaringRewriteTransformer("blub", "blab")..consumePrimary = true] |
- ]}); |
+ initGraph([ |
+ "app|foo.blub" |
+ ], { |
+ "app": [ |
+ [new DeclaringRewriteTransformer("blub", "blab")..consumePrimary = true] |
+ ] |
+ }); |
updateSources(["app|foo.blub"]); |
expectNoAsset("app|foo.blub"); |
buildShouldSucceed(); |
@@ -51,7 +66,13 @@ main() { |
test("gets a passed-through asset before apply is finished", () { |
var transformer = new DeclaringRewriteTransformer("blub", "blab"); |
- initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
+ initGraph([ |
+ "app|foo.blub" |
+ ], { |
+ "app": [ |
+ [transformer] |
+ ] |
+ }); |
transformer.pauseApply(); |
updateSources(["app|foo.blub"]); |
@@ -63,22 +84,36 @@ main() { |
test("fails to get a consumed asset before apply is finished", () { |
var transformer = new DeclaringRewriteTransformer("blub", "blab") |
- ..consumePrimary = true; |
- initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
- |
+ ..consumePrimary = true; |
+ initGraph([ |
+ "app|foo.blub" |
+ ], { |
+ "app": [ |
+ [transformer] |
+ ] |
+ }); |
+ |
transformer.pauseApply(); |
updateSources(["app|foo.blub"]); |
expectNoAsset("app|foo.blub"); |
- |
+ |
transformer.resumeApply(); |
buildShouldSucceed(); |
}); |
test("blocks on getting a declared asset that wasn't generated last run", () { |
var transformer = new DeclaringCheckContentAndRenameTransformer( |
- oldExtension: "txt", oldContent: "yes", |
- newExtension: "out", newContent: "done"); |
- initGraph({"app|foo.txt": "no"}, {"app": [[transformer]]}); |
+ oldExtension: "txt", |
+ oldContent: "yes", |
+ newExtension: "out", |
+ newContent: "done"); |
+ initGraph({ |
+ "app|foo.txt": "no" |
+ }, { |
+ "app": [ |
+ [transformer] |
+ ] |
+ }); |
updateSources(["app|foo.txt"]); |
expectNoAsset("app|foo.out"); |
@@ -96,12 +131,21 @@ main() { |
buildShouldSucceed(); |
}); |
- test("doesn't block on on getting an undeclared asset that wasn't generated " |
+ test( |
+ "doesn't block on on getting an undeclared asset that wasn't generated " |
"last run", () { |
var transformer = new DeclaringCheckContentAndRenameTransformer( |
- oldExtension: "txt", oldContent: "yes", |
- newExtension: "out", newContent: "done"); |
- initGraph({"app|foo.txt": "no"}, {"app": [[transformer]]}); |
+ oldExtension: "txt", |
+ oldContent: "yes", |
+ newExtension: "out", |
+ newContent: "done"); |
+ initGraph({ |
+ "app|foo.txt": "no" |
+ }, { |
+ "app": [ |
+ [transformer] |
+ ] |
+ }); |
updateSources(["app|foo.txt"]); |
expectNoAsset("app|foo.out"); |
@@ -116,36 +160,49 @@ main() { |
buildShouldSucceed(); |
}); |
- test("fails to get a consumed asset before apply is finished when a sibling " |
+ test( |
+ "fails to get a consumed asset before apply is finished when a sibling " |
"has finished applying", () { |
var transformer = new DeclaringRewriteTransformer("blub", "blab") |
- ..consumePrimary = true; |
- initGraph(["app|foo.blub", "app|foo.txt"], {"app": [[ |
- transformer, |
- new RewriteTransformer("txt", "out") |
- ]]}); |
- |
+ ..consumePrimary = true; |
+ initGraph([ |
+ "app|foo.blub", |
+ "app|foo.txt" |
+ ], { |
+ "app": [ |
+ [transformer, new RewriteTransformer("txt", "out")] |
+ ] |
+ }); |
+ |
transformer.pauseApply(); |
updateSources(["app|foo.blub", "app|foo.txt"]); |
expectAsset("app|foo.out", "foo.out"); |
expectNoAsset("app|foo.blub"); |
- |
+ |
transformer.resumeApply(); |
buildShouldSucceed(); |
}); |
- test("blocks getting a consumed asset before apply is finished when a " |
+ test( |
+ "blocks getting a consumed asset before apply is finished when a " |
"sibling hasn't finished applying", () { |
var declaring = new DeclaringRewriteTransformer("blub", "blab") |
- ..consumePrimary = true; |
+ ..consumePrimary = true; |
var eager = new RewriteTransformer("txt", "out"); |
- initGraph(["app|foo.blub", "app|foo.txt"], {"app": [[declaring, eager]]}); |
- |
+ initGraph([ |
+ "app|foo.blub", |
+ "app|foo.txt" |
+ ], { |
+ "app": [ |
+ [declaring, eager] |
+ ] |
+ }); |
+ |
declaring.pauseApply(); |
eager.pauseApply(); |
updateSources(["app|foo.blub", "app|foo.txt"]); |
expectAssetDoesNotComplete("app|foo.blub"); |
- |
+ |
declaring.resumeApply(); |
eager.resumeApply(); |
expectNoAsset("app|foo.blub"); |
@@ -154,7 +211,13 @@ main() { |
test("waits until apply is finished to get an overwritten asset", () { |
var transformer = new DeclaringRewriteTransformer("blub", "blub"); |
- initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
+ initGraph([ |
+ "app|foo.blub" |
+ ], { |
+ "app": [ |
+ [transformer] |
+ ] |
+ }); |
transformer.pauseApply(); |
updateSources(["app|foo.blub"]); |
@@ -169,10 +232,14 @@ main() { |
test("a declaring transformer's output passes through a lazy transformer", |
() { |
var declaring = new DeclaringRewriteTransformer("one", "two"); |
- initGraph(["app|foo.one"], {"app": [ |
- [declaring], |
- [new LazyRewriteTransformer("two", "three")] |
- ]}); |
+ initGraph([ |
+ "app|foo.one" |
+ ], { |
+ "app": [ |
+ [declaring], |
+ [new LazyRewriteTransformer("two", "three")] |
+ ] |
+ }); |
updateSources(["app|foo.one"]); |
// Give the transformers time to declare their assets. |
@@ -194,13 +261,20 @@ main() { |
expect(declaring.numRuns, completion(equals(2))); |
}); |
- test("a declaring transformer following a lazy transformer runs eagerly once " |
+ 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] |
- ]}); |
+ initGraph([ |
+ "app|foo.in" |
+ ], { |
+ "app": [ |
+ [ |
+ new LazyAssetsTransformer(["app|out.one", "app|out.two"]) |
+ ], |
+ [declaring] |
+ ] |
+ }); |
updateSources(["app|foo.in"]); |
// Give the transformers time to declare their assets. |
@@ -212,13 +286,20 @@ main() { |
expect(declaring.numRuns, completion(equals(1))); |
}); |
- test("a declaring transformer following a lazy transformer doesn't re-run if " |
+ 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] |
- ]}); |
+ initGraph([ |
+ "app|foo.in" |
+ ], { |
+ "app": [ |
+ [ |
+ new LazyAssetsTransformer(["app|out.one", "app|out.two"]) |
+ ], |
+ [declaring] |
+ ] |
+ }); |
declaring.pauseApply(); |
updateSources(["app|foo.in"]); |
@@ -251,14 +332,21 @@ main() { |
expect(declaring.numRuns, completion(equals(2))); |
}); |
- test("a declaring transformer following a lazy transformer does re-run if " |
+ test( |
+ "a declaring transformer following a lazy transformer does re-run if " |
"its input becomes available, it's forced, and then its input becomes " |
"unavailable", () { |
var declaring = new DeclaringRewriteTransformer("two", "three"); |
- initGraph(["app|foo.in"], {"app": [ |
- [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], |
- [declaring] |
- ]}); |
+ initGraph([ |
+ "app|foo.in" |
+ ], { |
+ "app": [ |
+ [ |
+ new LazyAssetsTransformer(["app|out.one", "app|out.two"]) |
+ ], |
+ [declaring] |
+ ] |
+ }); |
declaring.pauseApply(); |
updateSources(["app|foo.in"]); |
@@ -289,10 +377,16 @@ main() { |
group("with an error in declareOutputs", () { |
test("still runs apply", () { |
- initGraph(["app|foo.txt"], {"app": [[ |
- new DeclaringBadTransformer("app|out.txt", |
- declareError: true, applyError: false) |
- ]]}); |
+ initGraph([ |
+ "app|foo.txt" |
+ ], { |
+ "app": [ |
+ [ |
+ new DeclaringBadTransformer("app|out.txt", |
+ declareError: true, applyError: false) |
+ ] |
+ ] |
+ }); |
updateSources(["app|foo.txt"]); |
expectAsset("app|out.txt", "bad out"); |
@@ -300,11 +394,19 @@ main() { |
buildShouldFail([isTransformerException(BadTransformer.ERROR)]); |
}); |
- test("waits for apply to complete before passing through the input even if " |
+ test( |
+ "waits for apply to complete before passing through the input even if " |
"consumePrimary was called", () { |
var transformer = new DeclaringBadTransformer("app|out.txt", |
- declareError: true, applyError: false)..consumePrimary = true; |
- initGraph(["app|foo.txt"], {"app": [[transformer]]}); |
+ declareError: true, applyError: false) |
+ ..consumePrimary = true; |
+ initGraph([ |
+ "app|foo.txt" |
+ ], { |
+ "app": [ |
+ [transformer] |
+ ] |
+ }); |
transformer.pauseApply(); |
updateSources(["app|foo.txt"]); |
@@ -319,21 +421,33 @@ main() { |
}); |
test("with an error in apply still passes through the input", () { |
- initGraph(["app|foo.txt"], {"app": [[ |
- new DeclaringBadTransformer("app|out.txt", |
- declareError: false, applyError: true) |
- ]]}); |
- |
- updateSources(["app|foo.txt"]); |
- expectNoAsset("app|out.txt"); |
- expectAsset("app|foo.txt", "foo"); |
- buildShouldFail([isTransformerException(BadTransformer.ERROR)]); |
+ initGraph([ |
+ "app|foo.txt" |
+ ], { |
+ "app": [ |
+ [ |
+ new DeclaringBadTransformer("app|out.txt", |
+ declareError: false, applyError: true) |
+ ] |
+ ] |
+ }); |
+ |
+ updateSources(["app|foo.txt"]); |
+ expectNoAsset("app|out.txt"); |
+ expectAsset("app|foo.txt", "foo"); |
+ buildShouldFail([isTransformerException(BadTransformer.ERROR)]); |
}); |
test("can emit outputs it didn't declare", () { |
- initGraph(["app|foo.txt"], {"app": [ |
- [new DeclareAssetsTransformer([], emitted: ["app|out.txt"])] |
- ]}); |
+ initGraph([ |
+ "app|foo.txt" |
+ ], { |
+ "app": [ |
+ [ |
+ new DeclareAssetsTransformer([], emitted: ["app|out.txt"]) |
+ ] |
+ ] |
+ }); |
updateSources(["app|foo.txt"]); |
// There's probably going to be some time when "out.txt" is unavailable, |
@@ -345,9 +459,15 @@ main() { |
test("can overwrite the primary input even if it declared that it wouldn't", |
() { |
- var transformer = new DeclareAssetsTransformer( |
- [], emitted: ["app|foo.txt"]); |
- initGraph(["app|foo.txt"], {"app": [[transformer]]}); |
+ var transformer = |
+ new DeclareAssetsTransformer([], emitted: ["app|foo.txt"]); |
+ initGraph([ |
+ "app|foo.txt" |
+ ], { |
+ "app": [ |
+ [transformer] |
+ ] |
+ }); |
transformer.pauseApply(); |
updateSources(["app|foo.txt"]); |
@@ -360,12 +480,18 @@ main() { |
}); |
test("can declare outputs it doesn't emit", () { |
- initGraph(["app|foo.txt"], {"app": [ |
- [new DeclareAssetsTransformer(["app|out.txt"], emitted: [])] |
- ]}); |
+ initGraph([ |
+ "app|foo.txt" |
+ ], { |
+ "app": [ |
+ [ |
+ new DeclareAssetsTransformer(["app|out.txt"], emitted: []) |
+ ] |
+ ] |
+ }); |
updateSources(["app|foo.txt"]); |
expectNoAsset("app|out.txt"); |
buildShouldSucceed(); |
}); |
-} |
+} |