Chromium Code Reviews| Index: pkg/barback/test/package_graph/group_test.dart |
| diff --git a/pkg/barback/test/package_graph/group_test.dart b/pkg/barback/test/package_graph/group_test.dart |
| index c81b3b6997c56a935bf2a3980267e6eee5621090..f42de356e4661b3b292afc32d0855bd405ea20ee 100644 |
| --- a/pkg/barback/test/package_graph/group_test.dart |
| +++ b/pkg/barback/test/package_graph/group_test.dart |
| @@ -4,6 +4,8 @@ |
| library barback.test.package_graph.group_test; |
| +import 'dart:async'; |
| + |
| import 'package:barback/barback.dart'; |
| import 'package:scheduled_test/scheduled_test.dart'; |
| @@ -313,6 +315,31 @@ main() { |
| expectAsset("app|foo.a", "foo.a"); |
| buildShouldSucceed(); |
| }); |
| + |
| + test("doesn't pass-through an asset that ceases to be forwarded due to a " |
| + "resolved collision", () { |
| + initGraph({ |
| + "app|foo.a": "foo.a", |
| + "app|foo.x": "foo.x" |
| + }, {"app": [ |
| + [new TransformerGroup([[ |
| + new CheckContentAndRenameTransformer( |
| + "a", "new foo.a", "z", "modified foo.a"), |
| + new RewriteTransformer('x', 'a') |
| + ]])] |
| + ]}); |
| + |
| + updateSources(["app|foo.a", "app|foo.x"]); |
| + expectAsset("app|foo.a", "foo.a"); |
| + expectNoAsset("app|foo.z"); |
| + buildShouldFail([isAssetCollisionException("app|foo.a")]); |
| + |
| + modifyAsset('app|foo.a', 'new foo.a'); |
| + updateSources(["app|foo.a"]); |
| + expectAsset("app|foo.a", "foo.x.a"); |
| + expectAsset("app|foo.z", "modified foo.a"); |
| + buildShouldSucceed(); |
| + }); |
| }); |
| test("runs transforms in an added group", () { |
| @@ -399,3 +426,27 @@ main() { |
| buildShouldFail([isAssetCollisionException("app|foo.c")]); |
| }); |
| } |
| + |
| +/// A transformer that checks the extension and content of an asset, then |
| +/// produces a new asset with a new extension and new content. |
| +class CheckContentAndRenameTransformer extends MockTransformer { |
|
Bob Nystrom
2013/10/08 21:07:36
Move this to its own file in test/transformer.
nweiz
2013/10/08 22:20:12
Done. I didn't do that originally because it seeme
|
| + final String oldExtension; |
| + final String oldContent; |
| + final String newExtension; |
| + final String newContent; |
| + |
| + CheckContentAndRenameTransformer(this.oldExtension, this.oldContent, |
| + this.newExtension, this.newContent); |
| + |
| + Future<bool> doIsPrimary(Asset asset) { |
| + if (asset.id.extension != '.$oldExtension') return new Future.value(false); |
| + return asset.readAsString().then((value) => value == oldContent); |
| + } |
| + |
| + Future doApply(Transform transform) { |
| + return getPrimary(transform).then((input) { |
| + transform.addOutput(new Asset.fromString( |
| + input.id.changeExtension('.$newExtension'), newContent)); |
| + }); |
| + } |
| +} |