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

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

Issue 22265002: Support cross-package transforms in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. 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
« no previous file with comments | « pkg/barback/lib/src/transform_node.dart ('k') | pkg/barback/test/transformer/many_to_one.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 '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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 pauseProvider(); 887 pauseProvider();
888 schedule(() => updateSources(["pkg2|foo.txt"])); 888 schedule(() => updateSources(["pkg2|foo.txt"]));
889 expectAsset("pkg1|foo.out", "foo.out"); 889 expectAsset("pkg1|foo.out", "foo.out");
890 buildShouldNotBeDone(); 890 buildShouldNotBeDone();
891 891
892 // Now that the provider is unpaused, pkg2's transforms finish and the 892 // Now that the provider is unpaused, pkg2's transforms finish and the
893 // overall build succeeds. 893 // overall build succeeds.
894 resumeProvider(); 894 resumeProvider();
895 buildShouldSucceed(); 895 buildShouldSucceed();
896 }); 896 });
897
898 group('cross-package transforms', () {
899 test("can access other packages' source assets", () {
900 initGraph({
901 "pkg1|a.txt": "pkg2|a.inc",
902 "pkg2|a.inc": "a"
903 }, {"pkg1": [[new ManyToOneTransformer("txt")]]});
904
905 updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
906 expectAsset("pkg1|a.out", "a");
907 buildShouldSucceed();
908 });
909
910 test("can access other packages' transformed assets", () {
911 initGraph({
912 "pkg1|a.txt": "pkg2|a.inc",
913 "pkg2|a.txt": "a"
914 }, {
915 "pkg1": [[new ManyToOneTransformer("txt")]],
916 "pkg2": [[new RewriteTransformer("txt", "inc")]]
917 });
918
919 updateSources(["pkg1|a.txt", "pkg2|a.txt"]);
920 expectAsset("pkg1|a.out", "a.inc");
921 buildShouldSucceed();
922 });
923
924 test("re-runs a transform when an input from another package changes", () {
925 initGraph({
926 "pkg1|a.txt": "pkg2|a.inc",
927 "pkg2|a.inc": "a"
928 }, {
929 "pkg1": [[new ManyToOneTransformer("txt")]]
930 });
931
932 updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
933 expectAsset("pkg1|a.out", "a");
934 buildShouldSucceed();
935
936 modifyAsset("pkg2|a.inc", "new a");
937 schedule(() => updateSources(["pkg2|a.inc"]));
938 expectAsset("pkg1|a.out", "new a");
939 buildShouldSucceed();
940 });
941
942 test("re-runs a transform when a transformed input from another package "
943 "changes", () {
944 initGraph({
945 "pkg1|a.txt": "pkg2|a.inc",
946 "pkg2|a.txt": "a"
947 }, {
948 "pkg1": [[new ManyToOneTransformer("txt")]],
949 "pkg2": [[new RewriteTransformer("txt", "inc")]]
950 });
951
952 updateSources(["pkg1|a.txt", "pkg2|a.txt"]);
953 expectAsset("pkg1|a.out", "a.inc");
954 buildShouldSucceed();
955
956 modifyAsset("pkg2|a.txt", "new a");
957 schedule(() => updateSources(["pkg2|a.txt"]));
958 expectAsset("pkg1|a.out", "new a.inc");
959 buildShouldSucceed();
960 });
961
962 test("runs a transform that's added because of a change in another package",
963 () {
964 initGraph({
965 "pkg1|a.txt": "pkg2|a.inc",
966 "pkg2|a.inc": "b"
967 }, {
968 "pkg1": [
969 [new ManyToOneTransformer("txt")],
970 [new OneToManyTransformer("out")],
971 [new RewriteTransformer("md", "done")]
972 ],
973 });
974
975 // pkg1|a.txt generates outputs based on the contents of pkg2|a.inc. At
976 // first pkg2|a.inc only includes "b", which is not transformed. Then
977 // pkg2|a.inc is updated to include "b,c.md". pkg1|c.md triggers the
978 // md->done rewrite transformer, producing pkg1|c.done.
979
980 updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
981 expectAsset("pkg1|b", "spread out");
982 buildShouldSucceed();
983
984 modifyAsset("pkg2|a.inc", "b,c.md");
985 schedule(() => updateSources(["pkg2|a.inc"]));
986 expectAsset("pkg1|b", "spread out");
987 expectAsset("pkg1|c.done", "spread out.done");
988 buildShouldSucceed();
989 });
990
991 test("doesn't run a transform that's removed because of a change in "
992 "another package", () {
993 initGraph({
994 "pkg1|a.txt": "pkg2|a.inc",
995 "pkg2|a.inc": "b,c.md"
996 }, {
997 "pkg1": [
998 [new ManyToOneTransformer("txt")],
999 [new OneToManyTransformer("out")],
1000 [new RewriteTransformer("md", "done")]
1001 ],
1002 });
1003
1004 updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
1005 expectAsset("pkg1|b", "spread out");
1006 expectAsset("pkg1|c.done", "spread out.done");
1007 buildShouldSucceed();
1008
1009 modifyAsset("pkg2|a.inc", "b");
1010 schedule(() => updateSources(["pkg2|a.inc"]));
1011 expectAsset("pkg1|b", "spread out");
1012 expectNoAsset("pkg1|c.done");
1013 buildShouldSucceed();
1014 });
1015 });
897 } 1016 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/transform_node.dart ('k') | pkg/barback/test/transformer/many_to_one.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698