OLD | NEW |
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.aggregate_test; | 5 library barback.test.package_graph.transform.aggregate_test; |
6 | 6 |
7 import 'package:barback/src/utils.dart'; | |
8 import 'package:scheduled_test/scheduled_test.dart'; | 7 import 'package:scheduled_test/scheduled_test.dart'; |
9 | 8 |
10 import '../../utils.dart'; | 9 import '../../utils.dart'; |
11 | 10 |
12 main() { | 11 main() { |
13 initConfig(); | 12 initConfig(); |
14 test("an aggregate transformer can read from multiple primary inputs", () { | 13 test("an aggregate transformer can read from multiple primary inputs", () { |
15 var sources = [ | 14 var sources = [ |
16 "app|dir/foo.txt", | 15 "app|dir/foo.txt", |
17 "app|dir/bar.txt", | 16 "app|dir/bar.txt", |
18 "app|dir/baz.jpg", | 17 "app|dir/baz.jpg", |
19 "app|dir/subdir/bang.txt", | 18 "app|dir/subdir/bang.txt", |
20 "app|dir/subdir/qux.txt", | 19 "app|dir/subdir/qux.txt", |
21 "app|dir/subdir/zap.png" | 20 "app|dir/subdir/zap.png" |
22 ]; | 21 ]; |
23 | 22 |
24 initGraph(sources, {"app": [ | 23 initGraph(sources, { |
25 [new AggregateManyToOneTransformer("txt", "out.txt")] | 24 "app": [ |
26 ]}); | 25 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 26 ] |
| 27 }); |
27 | 28 |
28 updateSources(sources); | 29 updateSources(sources); |
29 expectAsset("app|dir/out.txt", "bar\nfoo"); | 30 expectAsset("app|dir/out.txt", "bar\nfoo"); |
30 expectAsset("app|dir/subdir/out.txt", "bang\nqux"); | 31 expectAsset("app|dir/subdir/out.txt", "bang\nqux"); |
31 buildShouldSucceed(); | 32 buildShouldSucceed(); |
32 }); | 33 }); |
33 | 34 |
34 test("an aggregate transformer isn't run if there are no primary inputs", () { | 35 test("an aggregate transformer isn't run if there are no primary inputs", () { |
35 var transformer = new AggregateManyToOneTransformer("txt", "out.txt"); | 36 var transformer = new AggregateManyToOneTransformer("txt", "out.txt"); |
36 initGraph(["app|foo.zip", "app|bar.zap"], {"app": [ | 37 initGraph([ |
37 [transformer] | 38 "app|foo.zip", |
38 ]}); | 39 "app|bar.zap" |
| 40 ], { |
| 41 "app": [ |
| 42 [transformer] |
| 43 ] |
| 44 }); |
39 | 45 |
40 updateSources(["app|foo.zip", "app|bar.zap"]); | 46 updateSources(["app|foo.zip", "app|bar.zap"]); |
41 expectNoAsset("app|out.txt"); | 47 expectNoAsset("app|out.txt"); |
42 buildShouldSucceed(); | 48 buildShouldSucceed(); |
43 | 49 |
44 expect(transformer.numRuns, completion(equals(0))); | 50 expect(transformer.numRuns, completion(equals(0))); |
45 }); | 51 }); |
46 | 52 |
47 test("an aggregate transformer is re-run if a primary input changes", () { | 53 test("an aggregate transformer is re-run if a primary input changes", () { |
48 initGraph(["app|foo.txt", "app|bar.txt"], {"app": [ | 54 initGraph([ |
49 [new AggregateManyToOneTransformer("txt", "out.txt")] | 55 "app|foo.txt", |
50 ]}); | 56 "app|bar.txt" |
| 57 ], { |
| 58 "app": [ |
| 59 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 60 ] |
| 61 }); |
51 | 62 |
52 updateSources(["app|foo.txt", "app|bar.txt"]); | 63 updateSources(["app|foo.txt", "app|bar.txt"]); |
53 expectAsset("app|out.txt", "bar\nfoo"); | 64 expectAsset("app|out.txt", "bar\nfoo"); |
54 buildShouldSucceed(); | 65 buildShouldSucceed(); |
55 | 66 |
56 modifyAsset("app|foo.txt", "new foo"); | 67 modifyAsset("app|foo.txt", "new foo"); |
57 updateSources(["app|foo.txt"]); | 68 updateSources(["app|foo.txt"]); |
58 expectAsset("app|out.txt", "bar\nnew foo"); | 69 expectAsset("app|out.txt", "bar\nnew foo"); |
59 buildShouldSucceed(); | 70 buildShouldSucceed(); |
60 }); | 71 }); |
61 | 72 |
62 test("an aggregate transformer is re-run if a primary input is removed", () { | 73 test("an aggregate transformer is re-run if a primary input is removed", () { |
63 initGraph(["app|foo.txt", "app|bar.txt"], {"app": [ | 74 initGraph([ |
64 [new AggregateManyToOneTransformer("txt", "out.txt")] | 75 "app|foo.txt", |
65 ]}); | 76 "app|bar.txt" |
| 77 ], { |
| 78 "app": [ |
| 79 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 80 ] |
| 81 }); |
66 | 82 |
67 updateSources(["app|foo.txt", "app|bar.txt"]); | 83 updateSources(["app|foo.txt", "app|bar.txt"]); |
68 expectAsset("app|out.txt", "bar\nfoo"); | 84 expectAsset("app|out.txt", "bar\nfoo"); |
69 buildShouldSucceed(); | 85 buildShouldSucceed(); |
70 | 86 |
71 removeSources(["app|foo.txt"]); | 87 removeSources(["app|foo.txt"]); |
72 expectAsset("app|out.txt", "bar"); | 88 expectAsset("app|out.txt", "bar"); |
73 buildShouldSucceed(); | 89 buildShouldSucceed(); |
74 }); | 90 }); |
75 | 91 |
76 test("an aggregate transformer is re-run if a primary input is added", () { | 92 test("an aggregate transformer is re-run if a primary input is added", () { |
77 initGraph(["app|foo.txt", "app|bar.txt", "app|baz.txt"], {"app": [ | 93 initGraph([ |
78 [new AggregateManyToOneTransformer("txt", "out.txt")] | 94 "app|foo.txt", |
79 ]}); | 95 "app|bar.txt", |
| 96 "app|baz.txt" |
| 97 ], { |
| 98 "app": [ |
| 99 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 100 ] |
| 101 }); |
80 | 102 |
81 updateSources(["app|foo.txt", "app|bar.txt"]); | 103 updateSources(["app|foo.txt", "app|bar.txt"]); |
82 expectAsset("app|out.txt", "bar\nfoo"); | 104 expectAsset("app|out.txt", "bar\nfoo"); |
83 buildShouldSucceed(); | 105 buildShouldSucceed(); |
84 | 106 |
85 updateSources(["app|baz.txt"]); | 107 updateSources(["app|baz.txt"]); |
86 expectAsset("app|out.txt", "bar\nbaz\nfoo"); | 108 expectAsset("app|out.txt", "bar\nbaz\nfoo"); |
87 buildShouldSucceed(); | 109 buildShouldSucceed(); |
88 }); | 110 }); |
89 | 111 |
90 test("an aggregate transformer ceases to run if all primary inputs are " | 112 test( |
| 113 "an aggregate transformer ceases to run if all primary inputs are " |
91 "removed", () { | 114 "removed", () { |
92 initGraph(["app|foo.txt", "app|bar.txt"], {"app": [ | 115 initGraph([ |
93 [new AggregateManyToOneTransformer("txt", "out.txt")] | 116 "app|foo.txt", |
94 ]}); | 117 "app|bar.txt" |
| 118 ], { |
| 119 "app": [ |
| 120 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 121 ] |
| 122 }); |
95 | 123 |
96 updateSources(["app|foo.txt", "app|bar.txt"]); | 124 updateSources(["app|foo.txt", "app|bar.txt"]); |
97 expectAsset("app|out.txt", "bar\nfoo"); | 125 expectAsset("app|out.txt", "bar\nfoo"); |
98 buildShouldSucceed(); | 126 buildShouldSucceed(); |
99 | 127 |
100 removeSources(["app|foo.txt", "app|bar.txt"]); | 128 removeSources(["app|foo.txt", "app|bar.txt"]); |
101 expectNoAsset("app|out.txt"); | 129 expectNoAsset("app|out.txt"); |
102 buildShouldSucceed(); | 130 buildShouldSucceed(); |
103 }); | 131 }); |
104 | 132 |
105 test("an aggregate transformer starts to run if new primary inputs are " | 133 test( |
| 134 "an aggregate transformer starts to run if new primary inputs are " |
106 "added", () { | 135 "added", () { |
107 initGraph(["app|foo.txt", "app|bar.txt"], {"app": [ | 136 initGraph([ |
108 [new AggregateManyToOneTransformer("txt", "out.txt")] | 137 "app|foo.txt", |
109 ]}); | 138 "app|bar.txt" |
| 139 ], { |
| 140 "app": [ |
| 141 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 142 ] |
| 143 }); |
110 | 144 |
111 updateSources([]); | 145 updateSources([]); |
112 expectNoAsset("app|out.txt"); | 146 expectNoAsset("app|out.txt"); |
113 buildShouldSucceed(); | 147 buildShouldSucceed(); |
114 | 148 |
115 updateSources(["app|foo.txt", "app|bar.txt"]); | 149 updateSources(["app|foo.txt", "app|bar.txt"]); |
116 expectAsset("app|out.txt", "bar\nfoo"); | 150 expectAsset("app|out.txt", "bar\nfoo"); |
117 buildShouldSucceed(); | 151 buildShouldSucceed(); |
118 }); | 152 }); |
119 | 153 |
120 group("pass-through", () { | 154 group("pass-through", () { |
121 test("an aggregate transformer passes through its primary inputs by " | 155 test( |
| 156 "an aggregate transformer passes through its primary inputs by " |
122 "default", () { | 157 "default", () { |
123 initGraph(["app|foo.txt", "app|bar.txt"], {"app": [ | 158 initGraph([ |
124 [new AggregateManyToOneTransformer("txt", "out.txt")] | 159 "app|foo.txt", |
125 ]}); | 160 "app|bar.txt" |
| 161 ], { |
| 162 "app": [ |
| 163 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 164 ] |
| 165 }); |
126 | 166 |
127 updateSources(["app|foo.txt", "app|bar.txt"]); | 167 updateSources(["app|foo.txt", "app|bar.txt"]); |
128 expectAsset("app|foo.txt", "foo"); | 168 expectAsset("app|foo.txt", "foo"); |
129 expectAsset("app|bar.txt", "bar"); | 169 expectAsset("app|bar.txt", "bar"); |
130 buildShouldSucceed(); | 170 buildShouldSucceed(); |
131 | 171 |
132 modifyAsset("app|foo.txt", "new foo"); | 172 modifyAsset("app|foo.txt", "new foo"); |
133 updateSources(["app|foo.txt"]); | 173 updateSources(["app|foo.txt"]); |
134 expectAsset("app|foo.txt", "new foo"); | 174 expectAsset("app|foo.txt", "new foo"); |
135 buildShouldSucceed(); | 175 buildShouldSucceed(); |
136 }); | 176 }); |
137 | 177 |
138 test("an aggregate transformer can overwrite its primary inputs", () { | 178 test("an aggregate transformer can overwrite its primary inputs", () { |
139 initGraph(["app|foo.txt", "app|bar.txt"], {"app": [ | 179 initGraph([ |
140 [new AggregateManyToManyTransformer("txt")] | 180 "app|foo.txt", |
141 ]}); | 181 "app|bar.txt" |
| 182 ], { |
| 183 "app": [ |
| 184 [new AggregateManyToManyTransformer("txt")] |
| 185 ] |
| 186 }); |
142 | 187 |
143 updateSources(["app|foo.txt", "app|bar.txt"]); | 188 updateSources(["app|foo.txt", "app|bar.txt"]); |
144 expectAsset("app|foo.txt", "modified foo"); | 189 expectAsset("app|foo.txt", "modified foo"); |
145 expectAsset("app|bar.txt", "modified bar"); | 190 expectAsset("app|bar.txt", "modified bar"); |
146 buildShouldSucceed(); | 191 buildShouldSucceed(); |
147 }); | 192 }); |
148 | 193 |
149 test("an aggregate transformer can consume its primary inputs", () { | 194 test("an aggregate transformer can consume its primary inputs", () { |
150 var transformer = new AggregateManyToOneTransformer("txt", "out.txt"); | 195 var transformer = new AggregateManyToOneTransformer("txt", "out.txt"); |
151 transformer.consumePrimaries | 196 transformer.consumePrimaries..add("app|foo.txt")..add("app|bar.txt"); |
152 ..add("app|foo.txt") | |
153 ..add("app|bar.txt"); | |
154 | 197 |
155 initGraph(["app|foo.txt", "app|bar.txt"], {"app": [[transformer]]}); | 198 initGraph([ |
| 199 "app|foo.txt", |
| 200 "app|bar.txt" |
| 201 ], { |
| 202 "app": [ |
| 203 [transformer] |
| 204 ] |
| 205 }); |
156 | 206 |
157 updateSources(["app|foo.txt", "app|bar.txt"]); | 207 updateSources(["app|foo.txt", "app|bar.txt"]); |
158 expectNoAsset("app|foo.txt"); | 208 expectNoAsset("app|foo.txt"); |
159 expectNoAsset("app|bar.txt"); | 209 expectNoAsset("app|bar.txt"); |
160 buildShouldSucceed(); | 210 buildShouldSucceed(); |
161 }); | 211 }); |
162 | 212 |
163 test("an aggregate transformer passes through non-primary inputs", () { | 213 test("an aggregate transformer passes through non-primary inputs", () { |
164 initGraph(["app|foo.jpg", "app|bar.png"], {"app": [ | 214 initGraph([ |
165 [new AggregateManyToManyTransformer("txt")] | 215 "app|foo.jpg", |
166 ]}); | 216 "app|bar.png" |
| 217 ], { |
| 218 "app": [ |
| 219 [new AggregateManyToManyTransformer("txt")] |
| 220 ] |
| 221 }); |
167 | 222 |
168 updateSources(["app|foo.jpg", "app|bar.png"]); | 223 updateSources(["app|foo.jpg", "app|bar.png"]); |
169 expectAsset("app|foo.jpg", "foo"); | 224 expectAsset("app|foo.jpg", "foo"); |
170 expectAsset("app|bar.png", "bar"); | 225 expectAsset("app|bar.png", "bar"); |
171 buildShouldSucceed(); | 226 buildShouldSucceed(); |
172 | 227 |
173 modifyAsset("app|foo.jpg", "new foo"); | 228 modifyAsset("app|foo.jpg", "new foo"); |
174 updateSources(["app|foo.jpg"]); | 229 updateSources(["app|foo.jpg"]); |
175 expectAsset("app|foo.jpg", "new foo"); | 230 expectAsset("app|foo.jpg", "new foo"); |
176 buildShouldSucceed(); | 231 buildShouldSucceed(); |
177 }); | 232 }); |
178 }); | 233 }); |
179 | 234 |
180 group("apply() transform stream", () { | 235 group("apply() transform stream", () { |
181 test("the primary input stream doesn't close if a previous phase is still " | 236 test( |
| 237 "the primary input stream doesn't close if a previous phase is still " |
182 "running", () { | 238 "running", () { |
183 var rewrite = new RewriteTransformer("a", "b"); | 239 var rewrite = new RewriteTransformer("a", "b"); |
184 initGraph(["app|foo.txt", "app|bar.a"], {"app": [ | 240 initGraph([ |
185 [rewrite], | 241 "app|foo.txt", |
186 [new AggregateManyToOneTransformer("txt", "out.txt")] | 242 "app|bar.a" |
187 ]}); | 243 ], { |
| 244 "app": [ |
| 245 [rewrite], |
| 246 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 247 ] |
| 248 }); |
188 | 249 |
189 rewrite.pauseApply(); | 250 rewrite.pauseApply(); |
190 updateSources(["app|foo.txt", "app|bar.a"]); | 251 updateSources(["app|foo.txt", "app|bar.a"]); |
191 expectAssetDoesNotComplete("app|out.txt"); | 252 expectAssetDoesNotComplete("app|out.txt"); |
192 | 253 |
193 rewrite.resumeApply(); | 254 rewrite.resumeApply(); |
194 expectAsset("app|out.txt", "foo"); | 255 expectAsset("app|out.txt", "foo"); |
195 buildShouldSucceed(); | 256 buildShouldSucceed(); |
196 }); | 257 }); |
197 | 258 |
198 test("the primary input stream doesn't close if a previous phase is " | 259 test( |
| 260 "the primary input stream doesn't close if a previous phase is " |
199 "materializing a primary input", () { | 261 "materializing a primary input", () { |
200 var rewrite = new DeclaringRewriteTransformer("in", "txt"); | 262 var rewrite = new DeclaringRewriteTransformer("in", "txt"); |
201 initGraph(["app|foo.txt", "app|bar.in"], {"app": [ | 263 initGraph([ |
202 [rewrite], | 264 "app|foo.txt", |
203 [new AggregateManyToOneTransformer("txt", "out.txt")] | 265 "app|bar.in" |
204 ]}); | 266 ], { |
| 267 "app": [ |
| 268 [rewrite], |
| 269 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 270 ] |
| 271 }); |
205 | 272 |
206 rewrite.pauseApply(); | 273 rewrite.pauseApply(); |
207 updateSources(["app|foo.txt", "app|bar.in"]); | 274 updateSources(["app|foo.txt", "app|bar.in"]); |
208 expectAssetDoesNotComplete("app|out.txt"); | 275 expectAssetDoesNotComplete("app|out.txt"); |
209 | 276 |
210 rewrite.resumeApply(); | 277 rewrite.resumeApply(); |
211 expectAsset("app|out.txt", "bar.txt\nfoo"); | 278 expectAsset("app|out.txt", "bar.txt\nfoo"); |
212 buildShouldSucceed(); | 279 buildShouldSucceed(); |
213 }); | 280 }); |
214 | 281 |
215 test("the primary input stream closes if a previous phase is only " | 282 test( |
| 283 "the primary input stream closes if a previous phase is only " |
216 "materializing non-primary inputs", () { | 284 "materializing non-primary inputs", () { |
217 var rewrite = new DeclaringRewriteTransformer("a", "b"); | 285 var rewrite = new DeclaringRewriteTransformer("a", "b"); |
218 initGraph(["app|foo.txt", "app|bar.a"], {"app": [ | 286 initGraph([ |
219 [rewrite], | 287 "app|foo.txt", |
220 [new AggregateManyToOneTransformer("txt", "out.txt")] | 288 "app|bar.a" |
221 ]}); | 289 ], { |
| 290 "app": [ |
| 291 [rewrite], |
| 292 [new AggregateManyToOneTransformer("txt", "out.txt")] |
| 293 ] |
| 294 }); |
222 | 295 |
223 rewrite.pauseApply(); | 296 rewrite.pauseApply(); |
224 updateSources(["app|foo.txt", "app|bar.a"]); | 297 updateSources(["app|foo.txt", "app|bar.a"]); |
225 expectAsset("app|out.txt", "foo"); | 298 expectAsset("app|out.txt", "foo"); |
226 | 299 |
227 rewrite.resumeApply(); | 300 rewrite.resumeApply(); |
228 buildShouldSucceed(); | 301 buildShouldSucceed(); |
229 }); | 302 }); |
230 | 303 |
231 test("a new primary input that arrives before the stream closes doesn't " | 304 test( |
| 305 "a new primary input that arrives before the stream closes doesn't " |
232 "cause apply to restart", () { | 306 "cause apply to restart", () { |
233 var rewrite = new RewriteTransformer("a", "b"); | 307 var rewrite = new RewriteTransformer("a", "b"); |
234 var aggregate = new AggregateManyToOneTransformer("txt", "out.txt"); | 308 var aggregate = new AggregateManyToOneTransformer("txt", "out.txt"); |
235 initGraph(["app|foo.txt", "app|bar.txt", "app|baz.a"], {"app": [ | 309 initGraph([ |
236 [rewrite], | 310 "app|foo.txt", |
237 [aggregate] | 311 "app|bar.txt", |
238 ]}); | 312 "app|baz.a" |
| 313 ], { |
| 314 "app": [ |
| 315 [rewrite], |
| 316 [aggregate] |
| 317 ] |
| 318 }); |
239 | 319 |
240 // The stream won't close until [rewrite] finishes running `apply()`. | 320 // The stream won't close until [rewrite] finishes running `apply()`. |
241 rewrite.pauseApply(); | 321 rewrite.pauseApply(); |
242 | 322 |
243 updateSources(["app|foo.txt", "app|baz.a"]); | 323 updateSources(["app|foo.txt", "app|baz.a"]); |
244 expectAssetDoesNotComplete("app|out.txt"); | 324 expectAssetDoesNotComplete("app|out.txt"); |
245 | 325 |
246 updateSources(["app|bar.txt"]); | 326 updateSources(["app|bar.txt"]); |
247 expectAssetDoesNotComplete("app|out.txt"); | 327 expectAssetDoesNotComplete("app|out.txt"); |
248 | 328 |
249 rewrite.resumeApply(); | 329 rewrite.resumeApply(); |
250 expectAsset("app|out.txt", "bar\nfoo"); | 330 expectAsset("app|out.txt", "bar\nfoo"); |
251 buildShouldSucceed(); | 331 buildShouldSucceed(); |
252 | 332 |
253 expect(aggregate.numRuns, completion(equals(1))); | 333 expect(aggregate.numRuns, completion(equals(1))); |
254 }); | 334 }); |
255 | 335 |
256 test("a new primary input that arrives after the stream closes causes " | 336 test( |
| 337 "a new primary input that arrives after the stream closes causes " |
257 "apply to restart", () { | 338 "apply to restart", () { |
258 var aggregate = new AggregateManyToOneTransformer("txt", "out.txt"); | 339 var aggregate = new AggregateManyToOneTransformer("txt", "out.txt"); |
259 initGraph(["app|foo.txt", "app|bar.txt"], {"app": [[aggregate]]}); | 340 initGraph([ |
| 341 "app|foo.txt", |
| 342 "app|bar.txt" |
| 343 ], { |
| 344 "app": [ |
| 345 [aggregate] |
| 346 ] |
| 347 }); |
260 | 348 |
261 aggregate.pauseApply(); | 349 aggregate.pauseApply(); |
262 updateSources(["app|foo.txt"]); | 350 updateSources(["app|foo.txt"]); |
263 expectAssetDoesNotComplete("app|out.txt"); | 351 expectAssetDoesNotComplete("app|out.txt"); |
264 | 352 |
265 updateSources(["app|bar.txt"]); | 353 updateSources(["app|bar.txt"]); |
266 expectAssetDoesNotComplete("app|out.txt"); | 354 expectAssetDoesNotComplete("app|out.txt"); |
267 | 355 |
268 aggregate.resumeApply(); | 356 aggregate.resumeApply(); |
269 expectAsset("app|out.txt", "bar\nfoo"); | 357 expectAsset("app|out.txt", "bar\nfoo"); |
270 buildShouldSucceed(); | 358 buildShouldSucceed(); |
271 | 359 |
272 expect(aggregate.numRuns, completion(equals(2))); | 360 expect(aggregate.numRuns, completion(equals(2))); |
273 }); | 361 }); |
274 | 362 |
275 test("a primary input that's modified before the stream closes causes " | 363 test( |
| 364 "a primary input that's modified before the stream closes causes " |
276 "apply to restart", () { | 365 "apply to restart", () { |
277 var rewrite = new RewriteTransformer("a", "b"); | 366 var rewrite = new RewriteTransformer("a", "b"); |
278 var aggregate = new AggregateManyToOneTransformer("txt", "out.txt"); | 367 var aggregate = new AggregateManyToOneTransformer("txt", "out.txt"); |
279 initGraph(["app|foo.txt", "app|bar.a"], {"app": [ | 368 initGraph([ |
280 [rewrite], | 369 "app|foo.txt", |
281 [aggregate] | 370 "app|bar.a" |
282 ]}); | 371 ], { |
| 372 "app": [ |
| 373 [rewrite], |
| 374 [aggregate] |
| 375 ] |
| 376 }); |
283 | 377 |
284 // The stream won't close until [rewrite] finishes running `apply()`. | 378 // The stream won't close until [rewrite] finishes running `apply()`. |
285 rewrite.pauseApply(); | 379 rewrite.pauseApply(); |
286 | 380 |
287 updateSources(["app|foo.txt", "app|bar.a"]); | 381 updateSources(["app|foo.txt", "app|bar.a"]); |
288 expectAssetDoesNotComplete("app|out.txt"); | 382 expectAssetDoesNotComplete("app|out.txt"); |
289 | 383 |
290 modifyAsset("app|foo.txt", "new foo"); | 384 modifyAsset("app|foo.txt", "new foo"); |
291 updateSources(["app|foo.txt"]); | 385 updateSources(["app|foo.txt"]); |
292 expectAssetDoesNotComplete("app|out.txt"); | 386 expectAssetDoesNotComplete("app|out.txt"); |
293 | 387 |
294 rewrite.resumeApply(); | 388 rewrite.resumeApply(); |
295 expectAsset("app|out.txt", "new foo"); | 389 expectAsset("app|out.txt", "new foo"); |
296 buildShouldSucceed(); | 390 buildShouldSucceed(); |
297 | 391 |
298 expect(aggregate.numRuns, completion(equals(2))); | 392 expect(aggregate.numRuns, completion(equals(2))); |
299 }); | 393 }); |
300 | 394 |
301 test("a primary input that's removed before the stream closes causes apply " | 395 test( |
| 396 "a primary input that's removed before the stream closes causes apply " |
302 "to restart", () { | 397 "to restart", () { |
303 var rewrite = new RewriteTransformer("a", "b"); | 398 var rewrite = new RewriteTransformer("a", "b"); |
304 var aggregate = new AggregateManyToOneTransformer("txt", "out.txt"); | 399 var aggregate = new AggregateManyToOneTransformer("txt", "out.txt"); |
305 initGraph(["app|foo.txt", "app|bar.txt", "app|baz.a"], {"app": [ | 400 initGraph([ |
306 [rewrite], | 401 "app|foo.txt", |
307 [aggregate] | 402 "app|bar.txt", |
308 ]}); | 403 "app|baz.a" |
| 404 ], { |
| 405 "app": [ |
| 406 [rewrite], |
| 407 [aggregate] |
| 408 ] |
| 409 }); |
309 | 410 |
310 // The stream won't close until [rewrite] finishes running `apply()`. | 411 // The stream won't close until [rewrite] finishes running `apply()`. |
311 rewrite.pauseApply(); | 412 rewrite.pauseApply(); |
312 | 413 |
313 updateSources(["app|foo.txt", "app|bar.txt", "app|baz.a"]); | 414 updateSources(["app|foo.txt", "app|bar.txt", "app|baz.a"]); |
314 expectAssetDoesNotComplete("app|out.txt"); | 415 expectAssetDoesNotComplete("app|out.txt"); |
315 | 416 |
316 removeSources(["app|bar.txt"]); | 417 removeSources(["app|bar.txt"]); |
317 expectAssetDoesNotComplete("app|out.txt"); | 418 expectAssetDoesNotComplete("app|out.txt"); |
318 | 419 |
319 rewrite.resumeApply(); | 420 rewrite.resumeApply(); |
320 expectAsset("app|out.txt", "foo"); | 421 expectAsset("app|out.txt", "foo"); |
321 buildShouldSucceed(); | 422 buildShouldSucceed(); |
322 | 423 |
323 expect(aggregate.numRuns, completion(equals(2))); | 424 expect(aggregate.numRuns, completion(equals(2))); |
324 }); | 425 }); |
325 }); | 426 }); |
326 } | 427 } |
OLD | NEW |