| 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 test("a lazy transformer that generates fewer outputs than it declares is " |
| 358 "forced when a declared but ungenerated output is requested", () { |
| 359 initGraph({"app|foo.txt": "no"}, {"app": [ |
| 360 [new LazyCheckContentAndRenameTransformer( |
| 361 "txt", "yes", "out", "done")] |
| 362 ]}); |
| 363 |
| 364 updateSources(["app|foo.txt"]); |
| 365 expectNoAsset("app|foo.out"); |
| 366 buildShouldSucceed(); |
| 367 |
| 368 modifyAsset("app|foo.txt", "yes"); |
| 369 updateSources(["app|foo.txt"]); |
| 370 expectAsset("app|foo.out", "done"); |
| 371 buildShouldSucceed(); |
| 372 }); |
| 373 |
| 357 // Regression tests. | 374 // Regression tests. |
| 358 | 375 |
| 359 test("a lazy transformer that doesn't apply updates its passed-through asset", | 376 test("a lazy transformer that doesn't apply updates its passed-through asset", |
| 360 () { | 377 () { |
| 361 initGraph(["app|foo.txt"], {"app": [ | 378 initGraph(["app|foo.txt"], {"app": [ |
| 362 [new LazyRewriteTransformer("blub", "blab")] | 379 [new LazyRewriteTransformer("blub", "blab")] |
| 363 ]}); | 380 ]}); |
| 364 | 381 |
| 365 // Pause the provider so that the transformer will start forwarding the | 382 // Pause the provider so that the transformer will start forwarding the |
| 366 // asset while it's dirty. | 383 // asset while it's dirty. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 buildShouldSucceed(); | 420 buildShouldSucceed(); |
| 404 | 421 |
| 405 // [assets] should run once for each time foo.in was updated. | 422 // [assets] should run once for each time foo.in was updated. |
| 406 expect(assets.numRuns, completion(equals(2))); | 423 expect(assets.numRuns, completion(equals(2))); |
| 407 | 424 |
| 408 // [rewrite] should run once against [assets]'s original output and once | 425 // [rewrite] should run once against [assets]'s original output and once |
| 409 // against its new output. | 426 // against its new output. |
| 410 expect(rewrite.numRuns, completion(equals(2))); | 427 expect(rewrite.numRuns, completion(equals(2))); |
| 411 }); | 428 }); |
| 412 } | 429 } |
| OLD | NEW |