| 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.lazy_asset_test; | 5 library barback.test.package_graph.lazy_asset_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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 347 |
| 348 updateSources(["app|foo.txt"]); | 348 updateSources(["app|foo.txt"]); |
| 349 expectNoAsset("app|foo.blab"); | 349 expectNoAsset("app|foo.blab"); |
| 350 | 350 |
| 351 // Getting all assets will force every lazy transformer. This shouldn't | 351 // Getting all assets will force every lazy transformer. This shouldn't |
| 352 // cause the rewrite to apply, because foo.txt isn't primary. | 352 // cause the rewrite to apply, because foo.txt isn't primary. |
| 353 expectAllAssets(["app|foo.txt"]); | 353 expectAllAssets(["app|foo.txt"]); |
| 354 buildShouldSucceed(); | 354 buildShouldSucceed(); |
| 355 }); | 355 }); |
| 356 | 356 |
| 357 // Regression test. | 357 // Regression tests. |
| 358 |
| 358 test("a lazy transformer that doesn't apply updates its passed-through asset", | 359 test("a lazy transformer that doesn't apply updates its passed-through asset", |
| 359 () { | 360 () { |
| 360 initGraph(["app|foo.txt"], {"app": [ | 361 initGraph(["app|foo.txt"], {"app": [ |
| 361 [new LazyRewriteTransformer("blub", "blab")] | 362 [new LazyRewriteTransformer("blub", "blab")] |
| 362 ]}); | 363 ]}); |
| 363 | 364 |
| 364 // Pause the provider so that the transformer will start forwarding the | 365 // Pause the provider so that the transformer will start forwarding the |
| 365 // asset while it's dirty. | 366 // asset while it's dirty. |
| 366 pauseProvider(); | 367 pauseProvider(); |
| 367 updateSources(["app|foo.txt"]); | 368 updateSources(["app|foo.txt"]); |
| 368 expectAssetDoesNotComplete("app|foo.txt"); | 369 expectAssetDoesNotComplete("app|foo.txt"); |
| 369 | 370 |
| 370 resumeProvider(); | 371 resumeProvider(); |
| 371 expectAsset("app|foo.txt", "foo"); | 372 expectAsset("app|foo.txt", "foo"); |
| 372 buildShouldSucceed(); | 373 buildShouldSucceed(); |
| 373 | 374 |
| 374 modifyAsset("app|foo.txt", "bar"); | 375 modifyAsset("app|foo.txt", "bar"); |
| 375 updateSources(["app|foo.txt"]); | 376 updateSources(["app|foo.txt"]); |
| 376 expectAsset("app|foo.txt", "bar"); | 377 expectAsset("app|foo.txt", "bar"); |
| 377 buildShouldSucceed(); | 378 buildShouldSucceed(); |
| 378 }); | 379 }); |
| 380 |
| 381 test("a lazy transformer is forced while the previous lazy transformer is " |
| 382 "available, then the previous transformer becomes unavailable", () { |
| 383 var assets = new LazyAssetsTransformer(["app|out.one", "app|out.two"]); |
| 384 var rewrite = new LazyRewriteTransformer("two", "three"); |
| 385 initGraph(["app|foo.in"], {"app": [[assets], [rewrite]]}); |
| 386 |
| 387 updateSources(["app|foo.in"]); |
| 388 // Request out.one so that [assets] runs but the second does not. |
| 389 expectAsset("app|out.one", "app|out.one"); |
| 390 buildShouldSucceed(); |
| 391 |
| 392 // Start the [rewrite] running. The output from [assets] should still be |
| 393 // available. |
| 394 rewrite.pauseApply(); |
| 395 expectAssetDoesNotComplete("app|out.three"); |
| 396 |
| 397 // Mark [assets] as dirty. It should re-run, since [rewrite] still needs its |
| 398 // input. |
| 399 updateSources(["app|foo.in"]); |
| 400 rewrite.resumeApply(); |
| 401 |
| 402 expectAsset("app|out.three", "app|out.two.three"); |
| 403 buildShouldSucceed(); |
| 404 |
| 405 // [assets] should run once for each time foo.in was updated. |
| 406 expect(assets.numRuns, completion(equals(2))); |
| 407 |
| 408 // [rewrite] should run once against [assets]'s original output and once |
| 409 // against its new output. |
| 410 expect(rewrite.numRuns, completion(equals(2))); |
| 411 }); |
| 379 } | 412 } |
| OLD | NEW |