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

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

Issue 26413003: Make PhaseOutput emit a new AssetNode whenever it changes outputs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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/phase_output.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/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));
+ });
+ }
+}
« no previous file with comments | « pkg/barback/lib/src/phase_output.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698