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

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

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

Powered by Google App Engine
This is Rietveld 408576698