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.declaring_transformer_test; | 5 library barback.test.package_graph.declaring_transformer_test; |
6 | 6 |
7 import 'package:barback/barback.dart'; | 7 import 'package:barback/barback.dart'; |
8 import 'package:barback/src/utils.dart'; | 8 import 'package:barback/src/utils.dart'; |
9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
10 | 10 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 }); | 184 }); |
185 | 185 |
186 test("a declaring transformer following a lazy transformer doesn't re-run if " | 186 test("a declaring transformer following a lazy transformer doesn't re-run if " |
187 "its input becomes available and then unavailable", () { | 187 "its input becomes available and then unavailable", () { |
188 var declaring = new DeclaringRewriteTransformer("two", "three"); | 188 var declaring = new DeclaringRewriteTransformer("two", "three"); |
189 initGraph(["app|foo.in"], {"app": [ | 189 initGraph(["app|foo.in"], {"app": [ |
190 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], | 190 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], |
191 [declaring] | 191 [declaring] |
192 ]}); | 192 ]}); |
193 | 193 |
194 // Start [declaring] running, because its input became available. | |
195 declaring.pauseApply(); | 194 declaring.pauseApply(); |
196 updateSources(["app|foo.in"]); | 195 updateSources(["app|foo.in"]); |
197 // Give the transformers time to declare their assets. | 196 // Give the transformers time to declare their assets. |
198 schedule(pumpEventQueue); | 197 schedule(pumpEventQueue); |
199 | 198 |
| 199 // Start [declaring] running, because its input became available. |
200 expectAsset("app|out.one", "app|out.one"); | 200 expectAsset("app|out.one", "app|out.one"); |
201 expectAssetDoesNotComplete("app|out.three"); | 201 |
| 202 // Make sure we're blocking on [declaring.apply]. |
| 203 schedule(pumpEventQueue); |
202 | 204 |
203 // Now [declaring]'s input is dirty, so it shouldn't re-run without an | 205 // Now [declaring]'s input is dirty, so it shouldn't re-run without an |
204 // explicit request. | 206 // explicit request. |
205 updateSources(["app|foo.in"]); | 207 updateSources(["app|foo.in"]); |
206 declaring.resumeApply(); | 208 declaring.resumeApply(); |
207 buildShouldSucceed(); | 209 buildShouldSucceed(); |
208 | 210 |
209 // [declaring] should only have run once, despite its input changing. After | 211 // [declaring] should only have run once, despite its input changing. After |
210 // the first run, it should be awaiting a force() call. | 212 // the first run, it should be awaiting a force() call. |
211 expect(declaring.numRuns, completion(equals(1))); | 213 expect(declaring.numRuns, completion(equals(1))); |
212 | 214 |
213 // Once we make a request, [declaring] should force the lazy transformer and | 215 // Once we make a request, [declaring] should force the lazy transformer and |
214 // then run itself. | 216 // then run itself. |
215 expectAsset("app|out.three", "app|out.two.three"); | 217 expectAsset("app|out.three", "app|out.two.three"); |
216 buildShouldSucceed(); | 218 buildShouldSucceed(); |
217 | 219 |
218 // Now [declaring] should have run twice. This ensures that it didn't use | 220 // Now [declaring] should have run twice. This ensures that it didn't use |
219 // its original output for some reason. | 221 // its original output for some reason. |
220 expect(declaring.numRuns, completion(equals(2))); | 222 expect(declaring.numRuns, completion(equals(2))); |
221 }); | 223 }); |
222 | 224 |
| 225 test("a declaring transformer following a lazy transformer does re-run if " |
| 226 "its input becomes available, it's forced, and then its input becomes " |
| 227 "unavailable", () { |
| 228 var declaring = new DeclaringRewriteTransformer("two", "three"); |
| 229 initGraph(["app|foo.in"], {"app": [ |
| 230 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], |
| 231 [declaring] |
| 232 ]}); |
| 233 |
| 234 declaring.pauseApply(); |
| 235 updateSources(["app|foo.in"]); |
| 236 |
| 237 // Give the transformers time to declare their assets. |
| 238 schedule(pumpEventQueue); |
| 239 |
| 240 // Start [declaring] running, because its input became available. |
| 241 expectAsset("app|out.one", "app|out.one"); |
| 242 |
| 243 // This shouldn't complete because [declaring.apply] is paused, but it |
| 244 // should force the transformer. |
| 245 expectAssetDoesNotComplete("app|out.three"); |
| 246 |
| 247 // Make sure we're blocking on [declaring.apply] |
| 248 schedule(pumpEventQueue); |
| 249 |
| 250 // Now [declaring]'s input is dirty, so it shouldn't re-run without an |
| 251 // explicit request. |
| 252 updateSources(["app|foo.in"]); |
| 253 declaring.resumeApply(); |
| 254 buildShouldSucceed(); |
| 255 |
| 256 // [declaring] should have run twice, once for its original input and once |
| 257 // after the input changed because it was forced. |
| 258 expect(declaring.numRuns, completion(equals(2))); |
| 259 }); |
| 260 |
223 group("with an error in declareOutputs", () { | 261 group("with an error in declareOutputs", () { |
224 test("still runs apply", () { | 262 test("still runs apply", () { |
225 initGraph(["app|foo.txt"], {"app": [[ | 263 initGraph(["app|foo.txt"], {"app": [[ |
226 new DeclaringBadTransformer("app|out.txt", | 264 new DeclaringBadTransformer("app|out.txt", |
227 declareError: true, applyError: false) | 265 declareError: true, applyError: false) |
228 ]]}); | 266 ]]}); |
229 | 267 |
230 updateSources(["app|foo.txt"]); | 268 updateSources(["app|foo.txt"]); |
231 expectAsset("app|out.txt", "bad out"); | 269 expectAsset("app|out.txt", "bad out"); |
232 expectAsset("app|foo.txt", "foo"); | 270 expectAsset("app|foo.txt", "foo"); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 test("can declare outputs it doesn't emit", () { | 332 test("can declare outputs it doesn't emit", () { |
295 initGraph(["app|foo.txt"], {"app": [ | 333 initGraph(["app|foo.txt"], {"app": [ |
296 [new DeclareAssetsTransformer(["app|out.txt"], [])] | 334 [new DeclareAssetsTransformer(["app|out.txt"], [])] |
297 ]}); | 335 ]}); |
298 | 336 |
299 updateSources(["app|foo.txt"]); | 337 updateSources(["app|foo.txt"]); |
300 expectNoAsset("app|out.txt"); | 338 expectNoAsset("app|out.txt"); |
301 buildShouldSucceed(); | 339 buildShouldSucceed(); |
302 }); | 340 }); |
303 } | 341 } |
OLD | NEW |