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

Side by Side Diff: pkg/barback/test/package_graph/transform/pass_through_test.dart

Issue 183993003: Revert commits r33138, r33135, and r33134. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library barback.test.package_graph.transform.pass_through_test;
6
7 import 'package:barback/src/utils.dart';
8 import 'package:scheduled_test/scheduled_test.dart';
9
10 import '../../utils.dart';
11
12 main() {
13 initConfig();
14 test("passes an asset through a phase in which no transforms apply", () {
15 initGraph([
16 "app|foo.in",
17 "app|bar.zip",
18 ], {"app": [
19 [new RewriteTransformer("in", "mid")],
20 [new RewriteTransformer("zip", "zap")],
21 [new RewriteTransformer("mid", "out")],
22 ]});
23
24 updateSources(["app|foo.in", "app|bar.zip"]);
25 expectAsset("app|foo.out", "foo.mid.out");
26 expectAsset("app|bar.zap", "bar.zap");
27 buildShouldSucceed();
28 });
29
30 test("passes an asset through a phase in which a transform uses it", () {
31 initGraph([
32 "app|foo.in",
33 ], {"app": [
34 [new RewriteTransformer("in", "mid")],
35 [new RewriteTransformer("mid", "phase2")],
36 [new RewriteTransformer("mid", "phase3")],
37 ]});
38
39 updateSources(["app|foo.in"]);
40 expectAsset("app|foo.in", "foo");
41 expectAsset("app|foo.mid", "foo.mid");
42 expectAsset("app|foo.phase2", "foo.mid.phase2");
43 expectAsset("app|foo.phase3", "foo.mid.phase3");
44 buildShouldSucceed();
45 });
46
47 // If the asset were to get passed through, it might either cause a collision
48 // or silently supersede the overwriting asset. We want to assert that that
49 // doesn't happen.
50 test("doesn't pass an asset through a phase in which a transform "
51 "overwrites it", () {
52 initGraph([
53 "app|foo.txt"
54 ], {"app": [[new RewriteTransformer("txt", "txt")]]});
55
56 updateSources(["app|foo.txt"]);
57 expectAsset("app|foo.txt", "foo.txt");
58 buildShouldSucceed();
59 });
60
61 test("removes a pass-through asset when the source is removed", () {
62 initGraph([
63 "app|foo.in",
64 "app|bar.zip",
65 ], {"app": [
66 [new RewriteTransformer("zip", "zap")],
67 [new RewriteTransformer("in", "out")],
68 ]});
69
70 updateSources(["app|foo.in", "app|bar.zip"]);
71 expectAsset("app|foo.out", "foo.out");
72 buildShouldSucceed();
73
74 removeSources(["app|foo.in"]);
75 expectNoAsset("app|foo.in");
76 expectNoAsset("app|foo.out");
77 buildShouldSucceed();
78 });
79
80 test("updates a pass-through asset when the source is updated", () {
81 initGraph([
82 "app|foo.in",
83 "app|bar.zip",
84 ], {"app": [
85 [new RewriteTransformer("zip", "zap")],
86 [new RewriteTransformer("in", "out")],
87 ]});
88
89 updateSources(["app|foo.in", "app|bar.zip"]);
90 expectAsset("app|foo.out", "foo.out");
91 buildShouldSucceed();
92
93 modifyAsset("app|foo.in", "boo");
94 updateSources(["app|foo.in"]);
95 expectAsset("app|foo.out", "boo.out");
96 buildShouldSucceed();
97 });
98
99 test("passes an asset through a phase in which transforms have ceased to "
100 "apply", () {
101 initGraph([
102 "app|foo.in",
103 ], {"app": [
104 [new RewriteTransformer("in", "mid")],
105 [new CheckContentTransformer("foo.mid", ".phase2")],
106 [new CheckContentTransformer(new RegExp(r"\.mid$"), ".phase3")],
107 ]});
108
109 updateSources(["app|foo.in"]);
110 expectAsset("app|foo.mid", "foo.mid.phase2");
111 buildShouldSucceed();
112
113 modifyAsset("app|foo.in", "bar");
114 updateSources(["app|foo.in"]);
115 expectAsset("app|foo.mid", "bar.mid.phase3");
116 buildShouldSucceed();
117 });
118
119 test("doesn't pass an asset through a phase in which transforms have "
120 "started to apply", () {
121 initGraph([
122 "app|foo.in",
123 ], {"app": [
124 [new RewriteTransformer("in", "mid")],
125 [new CheckContentTransformer("bar.mid", ".phase2")],
126 [new CheckContentTransformer(new RegExp(r"\.mid$"), ".phase3")],
127 ]});
128
129 updateSources(["app|foo.in"]);
130 expectAsset("app|foo.mid", "foo.mid.phase3");
131 buildShouldSucceed();
132
133 modifyAsset("app|foo.in", "bar");
134 updateSources(["app|foo.in"]);
135 expectAsset("app|foo.mid", "bar.mid.phase2");
136 buildShouldSucceed();
137 });
138
139 test("doesn't pass an asset through if it's removed during isPrimary", () {
140 var check = new CheckContentTransformer("bar", " modified");
141 initGraph(["app|foo.txt"], {"app": [[check]]});
142
143 updateSources(["app|foo.txt"]);
144 expectAsset("app|foo.txt", "foo");
145 buildShouldSucceed();
146
147 check.pauseIsPrimary("app|foo.txt");
148 modifyAsset("app|foo.txt", "bar");
149 updateSources(["app|foo.txt"]);
150 // Ensure we're waiting on [check.isPrimary]
151 schedule(pumpEventQueue);
152
153 removeSources(["app|foo.txt"]);
154 check.resumeIsPrimary("app|foo.txt");
155 expectNoAsset("app|foo.txt");
156 buildShouldSucceed();
157 });
158
159 test("passes an asset through when its overwriting transform becomes "
160 "non-primary during apply", () {
161 var check = new CheckContentTransformer("yes", " modified");
162 initGraph({"app|foo.txt": "yes"}, {"app": [[check]]});
163
164 check.pauseApply();
165 updateSources(["app|foo.txt"]);
166 expectAssetDoesNotComplete("app|foo.txt");
167
168 modifyAsset("app|foo.txt", "no");
169 updateSources(["app|foo.txt"]);
170 check.resumeApply();
171
172 expectAsset("app|foo.txt", "no");
173 buildShouldSucceed();
174 });
175
176 test("doesn't pass an asset through when its overwriting transform becomes "
177 "non-primary during apply if another transform overwrites it", () {
178 var check = new CheckContentTransformer("yes", " modified");
179 initGraph({
180 "app|foo.txt": "yes"
181 }, {
182 "app": [[check, new RewriteTransformer("txt", "txt")]]
183 });
184
185 check.pauseApply();
186 updateSources(["app|foo.txt"]);
187 // Ensure we're waiting on [check.apply]
188 schedule(pumpEventQueue);
189
190 modifyAsset("app|foo.txt", "no");
191 updateSources(["app|foo.txt"]);
192 check.resumeApply();
193
194 expectAsset("app|foo.txt", "no.txt");
195 buildShouldSucceed();
196 });
197
198 test("doesn't pass an asset through when one overwriting transform becomes "
199 "non-primary if another transform still overwrites it", () {
200 initGraph({
201 "app|foo.txt": "yes"
202 }, {
203 "app": [[
204 new CheckContentTransformer("yes", " modified"),
205 new RewriteTransformer("txt", "txt")
206 ]]
207 });
208
209 updateSources(["app|foo.txt"]);
210 // This could be either the output of [CheckContentTransformer] or
211 // [RewriteTransformer], depending which completes first.
212 expectAsset("app|foo.txt", anything);
213 buildShouldFail([isAssetCollisionException("app|foo.txt")]);
214
215 modifyAsset("app|foo.txt", "no");
216 updateSources(["app|foo.txt"]);
217 expectAsset("app|foo.txt", "no.txt");
218 buildShouldSucceed();
219 });
220
221 test("doesn't return a pass-through asset until we know it won't be "
222 "overwritten", () {
223 var rewrite = new RewriteTransformer("txt", "txt");
224 initGraph(["app|foo.a"], {"app": [[rewrite]]});
225
226 rewrite.pauseIsPrimary("app|foo.a");
227 updateSources(["app|foo.a"]);
228 expectAssetDoesNotComplete("app|foo.a");
229
230 rewrite.resumeIsPrimary("app|foo.a");
231 expectAsset("app|foo.a", "foo");
232 buildShouldSucceed();
233 });
234
235 test("doesn't return a pass-through asset until we know it won't be "
236 "overwritten when secondary inputs change", () {
237 var manyToOne = new ManyToOneTransformer("txt");
238 initGraph({
239 "app|foo.txt": "bar.in",
240 "app|bar.in": "bar"
241 }, {"app": [[manyToOne]]});
242
243 updateSources(["app|foo.txt", "app|bar.in"]);
244 expectAsset("app|foo.txt", "bar.in");
245 expectAsset("app|foo.out", "bar");
246
247 manyToOne.pauseApply();
248 updateSources(["app|bar.in"]);
249 expectAssetDoesNotComplete("app|foo.txt");
250
251 manyToOne.resumeApply();
252 expectAsset("app|foo.txt", "bar.in");
253 buildShouldSucceed();
254 });
255
256 test("doesn't return an overwritten asset until we know it will still "
257 "be overwritten", () {
258 var rewrite = new RewriteTransformer("txt", "txt");
259 initGraph(["app|foo.txt"], {"app": [[rewrite]]});
260
261 updateSources(["app|foo.txt"]);
262 expectAsset("app|foo.txt", "foo.txt");
263 buildShouldSucceed();
264
265 rewrite.pauseIsPrimary("app|foo.txt");
266 updateSources(["app|foo.txt"]);
267 expectAssetDoesNotComplete("app|foo.txt");
268
269 rewrite.resumeIsPrimary("app|foo.txt");
270 expectAsset("app|foo.txt", "foo.txt");
271 buildShouldSucceed();
272 });
273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698