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

Side by Side Diff: pkg/barback/test/package_graph/transform_test.dart

Issue 180473003: Barback transforms now pass through the primary input by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code reivew 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/barback/test/package_graph/lazy_transformer_test.dart ('k') | pkg/barback/test/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library barback.test.package_graph.transform_test; 5 library barback.test.package_graph.transform_test;
6 6
7 import 'package:barback/src/utils.dart'; 7 import 'package:barback/src/utils.dart';
8 import 'package:scheduled_test/scheduled_test.dart'; 8 import 'package:scheduled_test/scheduled_test.dart';
9 9
10 import '../utils.dart'; 10 import '../utils.dart';
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 expect(transformerB.isRunning, completion(isTrue)); 113 expect(transformerB.isRunning, completion(isTrue));
114 114
115 transformerA.resumeApply(); 115 transformerA.resumeApply();
116 transformerB.resumeApply(); 116 transformerB.resumeApply();
117 117
118 expectAsset("app|foo.a", "foo.a"); 118 expectAsset("app|foo.a", "foo.a");
119 expectAsset("app|foo.b", "foo.b"); 119 expectAsset("app|foo.b", "foo.b");
120 buildShouldSucceed(); 120 buildShouldSucceed();
121 }); 121 });
122 122
123 test("outputs are inaccessible once used", () { 123 test("outputs are passed through transformers by default", () {
124 initGraph(["app|foo.a"], {"app": [ 124 initGraph(["app|foo.a"], {"app": [
125 [new RewriteTransformer("a", "b")], 125 [new RewriteTransformer("a", "b")],
126 [new RewriteTransformer("a", "c")] 126 [new RewriteTransformer("a", "c")]
127 ]}); 127 ]});
128 updateSources(["app|foo.a"]); 128 updateSources(["app|foo.a"]);
129 expectAsset("app|foo.a", "foo");
129 expectAsset("app|foo.b", "foo.b"); 130 expectAsset("app|foo.b", "foo.b");
130 expectNoAsset("app|foo.a"); 131 expectAsset("app|foo.c", "foo.c");
131 expectNoAsset("app|foo.c");
132 buildShouldSucceed(); 132 buildShouldSucceed();
133 }); 133 });
134 134
135 test("does not reapply transform when inputs are not modified", () { 135 test("does not reapply transform when inputs are not modified", () {
136 var transformer = new RewriteTransformer("blub", "blab"); 136 var transformer = new RewriteTransformer("blub", "blab");
137 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 137 initGraph(["app|foo.blub"], {"app": [[transformer]]});
138 updateSources(["app|foo.blub"]); 138 updateSources(["app|foo.blub"]);
139 expectAsset("app|foo.blab", "foo.blab"); 139 expectAsset("app|foo.blab", "foo.blab");
140 expectAsset("app|foo.blab", "foo.blab"); 140 expectAsset("app|foo.blab", "foo.blab");
141 expectAsset("app|foo.blab", "foo.blab"); 141 expectAsset("app|foo.blab", "foo.blab");
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 544
545 rewrite.pauseApply(); 545 rewrite.pauseApply();
546 updateSources(["app|foo.txt"]); 546 updateSources(["app|foo.txt"]);
547 expectAssetDoesNotComplete("app|foo.txt"); 547 expectAssetDoesNotComplete("app|foo.txt");
548 548
549 rewrite.resumeApply(); 549 rewrite.resumeApply();
550 expectAsset("app|foo.txt", "foo.txt"); 550 expectAsset("app|foo.txt", "foo.txt");
551 buildShouldSucceed(); 551 buildShouldSucceed();
552 }); 552 });
553 553
554 test("doesn't return an asset until we know it won't be transformed", 554 test("doesn't return a pass-through asset until we know it won't be "
555 () { 555 "overwritten", () {
556 var rewrite = new RewriteTransformer("txt", "txt"); 556 var rewrite = new RewriteTransformer("txt", "txt");
557 initGraph(["app|foo.a"], {"app": [[rewrite]]}); 557 initGraph(["app|foo.a"], {"app": [[rewrite]]});
558 558
559 rewrite.pauseIsPrimary("app|foo.a"); 559 rewrite.pauseIsPrimary("app|foo.a");
560 updateSources(["app|foo.a"]); 560 updateSources(["app|foo.a"]);
561 expectAssetDoesNotComplete("app|foo.a"); 561 expectAssetDoesNotComplete("app|foo.a");
562 562
563 rewrite.resumeIsPrimary("app|foo.a"); 563 rewrite.resumeIsPrimary("app|foo.a");
564 expectAsset("app|foo.a", "foo"); 564 expectAsset("app|foo.a", "foo");
565 buildShouldSucceed(); 565 buildShouldSucceed();
566 }); 566 });
567 567
568 test("doesn't return a modified asset until we know it will still be " 568 test("doesn't return a pass-through asset until we know it won't be "
569 "transformed", () { 569 "overwritten when secondary inputs change", () {
570 var manyToOne = new ManyToOneTransformer("txt");
571 initGraph({
572 "app|foo.txt": "bar.in",
573 "app|bar.in": "bar"
574 }, {"app": [[manyToOne]]});
575
576 updateSources(["app|foo.txt", "app|bar.in"]);
577 expectAsset("app|foo.txt", "bar.in");
578 expectAsset("app|foo.out", "bar");
579
580 manyToOne.pauseApply();
581 updateSources(["app|bar.in"]);
582 expectAssetDoesNotComplete("app|foo.txt");
583
584 manyToOne.resumeApply();
585 expectAsset("app|foo.txt", "bar.in");
586 buildShouldSucceed();
587 });
588
589 test("doesn't return an overwritten asset until we know it will still "
590 "be overwritten", () {
570 var rewrite = new RewriteTransformer("txt", "txt"); 591 var rewrite = new RewriteTransformer("txt", "txt");
571 initGraph(["app|foo.txt"], {"app": [[rewrite]]}); 592 initGraph(["app|foo.txt"], {"app": [[rewrite]]});
572 593
573 updateSources(["app|foo.txt"]); 594 updateSources(["app|foo.txt"]);
574 expectAsset("app|foo.txt", "foo.txt"); 595 expectAsset("app|foo.txt", "foo.txt");
575 buildShouldSucceed(); 596 buildShouldSucceed();
576 597
577 rewrite.pauseIsPrimary("app|foo.txt"); 598 rewrite.pauseIsPrimary("app|foo.txt");
578 updateSources(["app|foo.txt"]); 599 updateSources(["app|foo.txt"]);
579 expectAssetDoesNotComplete("app|foo.txt"); 600 expectAssetDoesNotComplete("app|foo.txt");
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 [new RewriteTransformer("zip", "zap")], 861 [new RewriteTransformer("zip", "zap")],
841 [new RewriteTransformer("mid", "out")], 862 [new RewriteTransformer("mid", "out")],
842 ]}); 863 ]});
843 864
844 updateSources(["app|foo.in", "app|bar.zip"]); 865 updateSources(["app|foo.in", "app|bar.zip"]);
845 expectAsset("app|foo.out", "foo.mid.out"); 866 expectAsset("app|foo.out", "foo.mid.out");
846 expectAsset("app|bar.zap", "bar.zap"); 867 expectAsset("app|bar.zap", "bar.zap");
847 buildShouldSucceed(); 868 buildShouldSucceed();
848 }); 869 });
849 870
850 test("doesn't pass an asset through a phase in which a transform consumes " 871 test("passes an asset through a phase in which a transform uses it", () {
851 "it", () {
852 initGraph([ 872 initGraph([
853 "app|foo.in", 873 "app|foo.in",
854 ], {"app": [ 874 ], {"app": [
855 [new RewriteTransformer("in", "mid")], 875 [new RewriteTransformer("in", "mid")],
856 [new RewriteTransformer("mid", "phase2")], 876 [new RewriteTransformer("mid", "phase2")],
857 [new RewriteTransformer("mid", "phase3")], 877 [new RewriteTransformer("mid", "phase3")],
858 ]}); 878 ]});
859 879
860 updateSources(["app|foo.in"]); 880 updateSources(["app|foo.in"]);
881 expectAsset("app|foo.in", "foo");
882 expectAsset("app|foo.mid", "foo.mid");
861 expectAsset("app|foo.phase2", "foo.mid.phase2"); 883 expectAsset("app|foo.phase2", "foo.mid.phase2");
862 expectNoAsset("app|foo.phase3"); 884 expectAsset("app|foo.phase3", "foo.mid.phase3");
863 buildShouldSucceed(); 885 buildShouldSucceed();
864 }); 886 });
865 887
888 // If the asset were to get passed through, it might either cause a
889 // collision or silently supersede the overwriting asset. We want to assert
890 // that that doesn't happen.
891 test("doesn't pass an asset through a phase in which a transform "
892 "overwrites it", () {
893 initGraph([
894 "app|foo.txt"
895 ], {"app": [[new RewriteTransformer("txt", "txt")]]});
896
897 updateSources(["app|foo.txt"]);
898 expectAsset("app|foo.txt", "foo.txt");
899 buildShouldSucceed();
900 });
901
866 test("removes a pass-through asset when the source is removed", () { 902 test("removes a pass-through asset when the source is removed", () {
867 initGraph([ 903 initGraph([
868 "app|foo.in", 904 "app|foo.in",
869 "app|bar.zip", 905 "app|bar.zip",
870 ], {"app": [ 906 ], {"app": [
871 [new RewriteTransformer("zip", "zap")], 907 [new RewriteTransformer("zip", "zap")],
872 [new RewriteTransformer("in", "out")], 908 [new RewriteTransformer("in", "out")],
873 ]}); 909 ]});
874 910
875 updateSources(["app|foo.in", "app|bar.zip"]); 911 updateSources(["app|foo.in", "app|bar.zip"]);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 modifyAsset("app|foo.txt", "bar"); 989 modifyAsset("app|foo.txt", "bar");
954 updateSources(["app|foo.txt"]); 990 updateSources(["app|foo.txt"]);
955 // Ensure we're waiting on [check.isPrimary] 991 // Ensure we're waiting on [check.isPrimary]
956 schedule(pumpEventQueue); 992 schedule(pumpEventQueue);
957 993
958 removeSources(["app|foo.txt"]); 994 removeSources(["app|foo.txt"]);
959 check.resumeIsPrimary("app|foo.txt"); 995 check.resumeIsPrimary("app|foo.txt");
960 expectNoAsset("app|foo.txt"); 996 expectNoAsset("app|foo.txt");
961 buildShouldSucceed(); 997 buildShouldSucceed();
962 }); 998 });
999
1000 test("passes an asset through when its overwriting transform becomes "
1001 "non-primary during apply", () {
1002 var check = new CheckContentTransformer("yes", " modified");
1003 initGraph({"app|foo.txt": "yes"}, {"app": [[check]]});
1004
1005 check.pauseApply();
1006 updateSources(["app|foo.txt"]);
1007 expectAssetDoesNotComplete("app|foo.txt");
1008
1009 modifyAsset("app|foo.txt", "no");
1010 updateSources(["app|foo.txt"]);
1011 check.resumeApply();
1012
1013 expectAsset("app|foo.txt", "no");
1014 buildShouldSucceed();
1015 });
1016
1017 test("doesn't pass an asset through when its overwriting transform becomes "
1018 "non-primary during apply if another transform overwrites it", () {
1019 var check = new CheckContentTransformer("yes", " modified");
1020 initGraph({
1021 "app|foo.txt": "yes"
1022 }, {
1023 "app": [[check, new RewriteTransformer("txt", "txt")]]
1024 });
1025
1026 check.pauseApply();
1027 updateSources(["app|foo.txt"]);
1028 // Ensure we're waiting on [check.apply]
1029 schedule(pumpEventQueue);
1030
1031 modifyAsset("app|foo.txt", "no");
1032 updateSources(["app|foo.txt"]);
1033 check.resumeApply();
1034
1035 expectAsset("app|foo.txt", "no.txt");
1036 buildShouldSucceed();
1037 });
1038
1039 test("doesn't pass an asset through when one overwriting transform becomes "
1040 "non-primary if another transform still overwrites it", () {
1041 initGraph({
1042 "app|foo.txt": "yes"
1043 }, {
1044 "app": [[
1045 new CheckContentTransformer("yes", " modified"),
1046 new RewriteTransformer("txt", "txt")
1047 ]]
1048 });
1049
1050 updateSources(["app|foo.txt"]);
1051 // This could be either the output of [CheckContentTransformer] or
1052 // [RewriteTransformer], depending which completes first.
1053 expectAsset("app|foo.txt", anything);
1054 buildShouldFail([isAssetCollisionException("app|foo.txt")]);
1055
1056 modifyAsset("app|foo.txt", "no");
1057 updateSources(["app|foo.txt"]);
1058 expectAsset("app|foo.txt", "no.txt");
1059 buildShouldSucceed();
1060 });
963 }); 1061 });
964 1062
965 group('cross-package transforms', () { 1063 group('cross-package transforms', () {
966 test("can access other packages' source assets", () { 1064 test("can access other packages' source assets", () {
967 initGraph({ 1065 initGraph({
968 "pkg1|a.txt": "pkg2|a.inc", 1066 "pkg1|a.txt": "pkg2|a.inc",
969 "pkg2|a.inc": "a" 1067 "pkg2|a.inc": "a"
970 }, {"pkg1": [[new ManyToOneTransformer("txt")]]}); 1068 }, {"pkg1": [[new ManyToOneTransformer("txt")]]});
971 1069
972 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); 1070 updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 transformer1.resumeApply(); 1268 transformer1.resumeApply();
1171 1269
1172 expectAsset("app|foo.out", "foo.mid.out"); 1270 expectAsset("app|foo.out", "foo.mid.out");
1173 buildShouldSucceed(); 1271 buildShouldSucceed();
1174 1272
1175 expect(transformer1.numRuns, completion(equals(2))); 1273 expect(transformer1.numRuns, completion(equals(2)));
1176 expect(transformer2.numRuns, completion(equals(2))); 1274 expect(transformer2.numRuns, completion(equals(2)));
1177 }); 1275 });
1178 }); 1276 });
1179 } 1277 }
OLDNEW
« no previous file with comments | « pkg/barback/test/package_graph/lazy_transformer_test.dart ('k') | pkg/barback/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698