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

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

Issue 23199004: Support passing barback assets through phases in which they're unused. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a logic error. Created 7 years, 4 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
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 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:barback/src/utils.dart'; 10 import 'package:barback/src/utils.dart';
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 schedule(pumpEventQueue); 596 schedule(pumpEventQueue);
597 597
598 removeSources(["app|foo.txt"]); 598 removeSources(["app|foo.txt"]);
599 rewrite.resumeIsPrimary("app|foo.txt"); 599 rewrite.resumeIsPrimary("app|foo.txt");
600 expectNoAsset("app|foo.txt"); 600 expectNoAsset("app|foo.txt");
601 buildShouldSucceed(); 601 buildShouldSucceed();
602 }); 602 });
603 603
604 test("doesn't transform an asset that goes from primary to non-primary " 604 test("doesn't transform an asset that goes from primary to non-primary "
605 "during isPrimary", () { 605 "during isPrimary", () {
606 var check = new CheckContentTransformer("do", "ne"); 606 var check = new CheckContentTransformer(new RegExp(r"^do$"), "ne");
607 initGraph({ 607 initGraph({
608 "app|foo.txt": "do" 608 "app|foo.txt": "do"
609 }, {"app": [[check]]}); 609 }, {"app": [[check]]});
610 610
611 check.pauseIsPrimary("app|foo.txt"); 611 check.pauseIsPrimary("app|foo.txt");
612 updateSources(["app|foo.txt"]); 612 updateSources(["app|foo.txt"]);
613 // Make sure we're waiting on isPrimary. 613 // Make sure we're waiting on isPrimary.
614 schedule(pumpEventQueue); 614 schedule(pumpEventQueue);
615 615
616 modifyAsset("app|foo.txt", "don't"); 616 modifyAsset("app|foo.txt", "don't");
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 removeSources(["app|foo.txt"]); 655 removeSources(["app|foo.txt"]);
656 rewrite2.resumeIsPrimary("app|foo.md"); 656 rewrite2.resumeIsPrimary("app|foo.md");
657 expectNoAsset("app|foo.txt"); 657 expectNoAsset("app|foo.txt");
658 expectAsset("app|foo.md", "foo.md"); 658 expectAsset("app|foo.md", "foo.md");
659 buildShouldSucceed(); 659 buildShouldSucceed();
660 }); 660 });
661 661
662 test("doesn't transform an asset that goes from primary to non-primary " 662 test("doesn't transform an asset that goes from primary to non-primary "
663 "during another transformer's isPrimary", () { 663 "during another transformer's isPrimary", () {
664 var rewrite = new RewriteTransformer("md", "md"); 664 var rewrite = new RewriteTransformer("md", "md");
665 var check = new CheckContentTransformer("do", "ne"); 665 var check = new CheckContentTransformer(new RegExp(r"^do$"), "ne");
666 initGraph({ 666 initGraph({
667 "app|foo.txt": "do", 667 "app|foo.txt": "do",
668 "app|foo.md": "foo" 668 "app|foo.md": "foo"
669 }, {"app": [[rewrite, check]]}); 669 }, {"app": [[rewrite, check]]});
670 670
671 rewrite.pauseIsPrimary("app|foo.md"); 671 rewrite.pauseIsPrimary("app|foo.md");
672 updateSources(["app|foo.txt", "app|foo.md"]); 672 updateSources(["app|foo.txt", "app|foo.md"]);
673 // Make sure we're waiting on the correct isPrimary. 673 // Make sure we're waiting on the correct isPrimary.
674 schedule(pumpEventQueue); 674 schedule(pumpEventQueue);
675 675
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 updateSources(["pkg2|foo.txt"]); 802 updateSources(["pkg2|foo.txt"]);
803 expectAsset("pkg1|foo.out", "foo.out"); 803 expectAsset("pkg1|foo.out", "foo.out");
804 buildShouldNotBeDone(); 804 buildShouldNotBeDone();
805 805
806 // Now that the provider is unpaused, pkg2's transforms finish and the 806 // Now that the provider is unpaused, pkg2's transforms finish and the
807 // overall build succeeds. 807 // overall build succeeds.
808 resumeProvider(); 808 resumeProvider();
809 buildShouldSucceed(); 809 buildShouldSucceed();
810 }); 810 });
811 811
812 group("pass-through", () {
813 test("passes an asset through a phase in which no transforms apply", () {
814 initGraph([
815 "app|foo.in",
816 "app|bar.zip",
817 ], {"app": [
818 [new RewriteTransformer("in", "mid")],
819 [new RewriteTransformer("zip", "zap")],
820 [new RewriteTransformer("mid", "out")],
821 ]});
822
823 updateSources(["app|foo.in", "app|bar.zip"]);
824 expectAsset("app|foo.out", "foo.mid.out");
825 expectAsset("app|bar.zap", "bar.zap");
826 buildShouldSucceed();
827 });
828
829 test("doesn't pass an asset through a phase in which a transform consumes "
830 "it", () {
831 initGraph([
832 "app|foo.in",
833 ], {"app": [
834 [new RewriteTransformer("in", "mid")],
835 [new RewriteTransformer("mid", "phase2")],
836 [new RewriteTransformer("mid", "phase3")],
837 ]});
838
839 updateSources(["app|foo.in"]);
840 expectAsset("app|foo.phase2", "foo.mid.phase2");
841 expectNoAsset("app|foo.phase3");
842 buildShouldSucceed();
843 });
844
845 test("removes a pass-through asset when the source is removed", () {
846 initGraph([
847 "app|foo.in",
848 "app|bar.zip",
849 ], {"app": [
850 [new RewriteTransformer("zip", "zap")],
851 [new RewriteTransformer("in", "out")],
852 ]});
853
854 updateSources(["app|foo.in", "app|bar.zip"]);
855 expectAsset("app|foo.out", "foo.out");
856 buildShouldSucceed();
857
858 removeSources(["app|foo.in"]);
859 expectNoAsset("app|foo.in");
860 expectNoAsset("app|foo.out");
861 buildShouldSucceed();
862 });
863
864 test("updates a pass-through asset when the source is updated", () {
865 initGraph([
866 "app|foo.in",
867 "app|bar.zip",
868 ], {"app": [
869 [new RewriteTransformer("zip", "zap")],
870 [new RewriteTransformer("in", "out")],
871 ]});
872
873 updateSources(["app|foo.in", "app|bar.zip"]);
874 expectAsset("app|foo.out", "foo.out");
875 buildShouldSucceed();
876
877 modifyAsset("app|foo.in", "boo");
878 updateSources(["app|foo.in"]);
879 expectAsset("app|foo.out", "boo.out");
880 buildShouldSucceed();
881 });
882
883 test("passes an asset through a phase in which transforms have ceased to "
884 "apply", () {
885 initGraph([
886 "app|foo.in",
887 ], {"app": [
888 [new RewriteTransformer("in", "mid")],
889 [new CheckContentTransformer("foo.mid", ".phase2")],
890 [new CheckContentTransformer(new RegExp(r"\.mid$"), ".phase3")],
891 ]});
892
893 updateSources(["app|foo.in"]);
894 expectAsset("app|foo.mid", "foo.mid.phase2");
895 buildShouldSucceed();
896
897 modifyAsset("app|foo.in", "bar");
898 updateSources(["app|foo.in"]);
899 expectAsset("app|foo.mid", "bar.mid.phase3");
900 buildShouldSucceed();
901 });
902
903 test("doesn't pass an asset through a phase in which transforms have "
904 "started to apply", () {
905 initGraph([
906 "app|foo.in",
907 ], {"app": [
908 [new RewriteTransformer("in", "mid")],
909 [new CheckContentTransformer("bar.mid", ".phase2")],
910 [new CheckContentTransformer(new RegExp(r"\.mid$"), ".phase3")],
911 ]});
912
913 updateSources(["app|foo.in"]);
914 expectAsset("app|foo.mid", "foo.mid.phase3");
915 buildShouldSucceed();
916
917 modifyAsset("app|foo.in", "bar");
918 updateSources(["app|foo.in"]);
919 expectAsset("app|foo.mid", "bar.mid.phase2");
920 buildShouldSucceed();
921 });
922 });
923
812 group('cross-package transforms', () { 924 group('cross-package transforms', () {
813 test("can access other packages' source assets", () { 925 test("can access other packages' source assets", () {
814 initGraph({ 926 initGraph({
815 "pkg1|a.txt": "pkg2|a.inc", 927 "pkg1|a.txt": "pkg2|a.inc",
816 "pkg2|a.inc": "a" 928 "pkg2|a.inc": "a"
817 }, {"pkg1": [[new ManyToOneTransformer("txt")]]}); 929 }, {"pkg1": [[new ManyToOneTransformer("txt")]]});
818 930
819 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); 931 updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
820 expectAsset("pkg1|a.out", "a"); 932 expectAsset("pkg1|a.out", "a");
821 buildShouldSucceed(); 933 buildShouldSucceed();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 buildShouldSucceed(); 1033 buildShouldSucceed();
922 1034
923 modifyAsset("pkg2|a.inc", "b"); 1035 modifyAsset("pkg2|a.inc", "b");
924 updateSources(["pkg2|a.inc"]); 1036 updateSources(["pkg2|a.inc"]);
925 expectAsset("pkg1|b", "spread out"); 1037 expectAsset("pkg1|b", "spread out");
926 expectNoAsset("pkg1|c.done"); 1038 expectNoAsset("pkg1|c.done");
927 buildShouldSucceed(); 1039 buildShouldSucceed();
928 }); 1040 });
929 }); 1041 });
930 } 1042 }
OLDNEW
« no previous file with comments | « pkg/barback/test/package_graph/errors_test.dart ('k') | pkg/barback/test/transformer/check_content.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698