Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
|
Bob Nystrom
2013/08/07 22:00:08
This one is particularly hard to follow. How about
nweiz
2013/08/07 22:59:15
Done.
| |
| 975 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); | |
| 976 expectAsset("pkg1|b", "spread out"); | |
| 977 buildShouldSucceed(); | |
| 978 | |
| 979 modifyAsset("pkg2|a.inc", "b,c.md"); | |
| 980 schedule(() => updateSources(["pkg2|a.inc"])); | |
| 981 expectAsset("pkg1|b", "spread out"); | |
| 982 expectAsset("pkg1|c.done", "spread out.done"); | |
| 983 buildShouldSucceed(); | |
| 984 }); | |
| 985 | |
| 986 test("doesn't run a transform that's removed because of a change in " | |
| 987 "another package", () { | |
| 988 initGraph({ | |
| 989 "pkg1|a.txt": "pkg2|a.inc", | |
| 990 "pkg2|a.inc": "b,c.md" | |
| 991 }, { | |
| 992 "pkg1": [ | |
| 993 [new ManyToOneTransformer("txt")], | |
| 994 [new OneToManyTransformer("out")], | |
| 995 [new RewriteTransformer("md", "done")] | |
| 996 ], | |
| 997 }); | |
| 998 | |
| 999 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); | |
| 1000 expectAsset("pkg1|b", "spread out"); | |
| 1001 expectAsset("pkg1|c.done", "spread out.done"); | |
| 1002 buildShouldSucceed(); | |
| 1003 | |
| 1004 modifyAsset("pkg2|a.inc", "b"); | |
| 1005 schedule(() => updateSources(["pkg2|a.inc"])); | |
| 1006 expectAsset("pkg1|b", "spread out"); | |
| 1007 expectNoAsset("pkg1|c.done"); | |
| 1008 buildShouldSucceed(); | |
| 1009 }); | |
| 1010 }); | |
| 897 } | 1011 } |
| OLD | NEW |