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 |
11 import '../utils.dart'; | 11 import '../utils.dart'; |
12 | 12 |
13 main() { | 13 main() { |
14 initConfig(); | 14 initConfig(); |
15 test("requesting a lazy asset should cause it to be generated", () { | 15 test("requesting a lazy asset should cause it to be generated", () { |
16 initGraph(["app|foo.blub"], {"app": [ | 16 initGraph(["app|foo.blub"], {"app": [ |
17 [new LazyRewriteTransformer("blub", "blab")] | 17 [new LazyRewriteTransformer("blub", "blab")] |
18 ]}); | 18 ]}); |
19 updateSources(["app|foo.blub"]); | 19 updateSources(["app|foo.blub"]); |
20 expectAsset("app|foo.blab", "foo.blab"); | 20 expectAsset("app|foo.blab", "foo.blab"); |
21 buildShouldSucceed(); | 21 buildShouldSucceed(); |
22 }); | 22 }); |
23 | 23 |
24 test("calling getAllAssets should cause a lazy asset to be generated", () { | 24 test("calling getAllAssets should cause a lazy asset to be generated", () { |
25 var transformer = new LazyRewriteTransformer("blub", "blab"); | 25 var transformer = new LazyRewriteTransformer("blub", "blab"); |
26 initGraph(["app|foo.blub"], {"app": [[transformer]]}); | 26 initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
27 updateSources(["app|foo.blub"]); | 27 updateSources(["app|foo.blub"]); |
28 expectAllAssets(["app|foo.blub", "app|foo.blab"]); | 28 expectAllAssets(["app|foo.blab"]); |
29 buildShouldSucceed(); | 29 buildShouldSucceed(); |
30 expect(transformer.numRuns, completion(equals(1))); | 30 expect(transformer.numRuns, completion(equals(1))); |
31 }); | 31 }); |
32 | 32 |
33 test("requesting a lazy asset multiple times should only cause it to be " | 33 test("requesting a lazy asset multiple times should only cause it to be " |
34 "generated once", () { | 34 "generated once", () { |
35 var transformer = new LazyRewriteTransformer("blub", "blab"); | 35 var transformer = new LazyRewriteTransformer("blub", "blab"); |
36 initGraph(["app|foo.blub"], {"app": [[transformer]]}); | 36 initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
37 updateSources(["app|foo.blub"]); | 37 updateSources(["app|foo.blub"]); |
38 expectAsset("app|foo.blab", "foo.blab"); | 38 expectAsset("app|foo.blab", "foo.blab"); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 "it from being materialized", () { | 169 "it from being materialized", () { |
170 var transformer = new LazyBadTransformer("app|foo.out"); | 170 var transformer = new LazyBadTransformer("app|foo.out"); |
171 initGraph(["app|foo.txt"], {"app": [[transformer]]}); | 171 initGraph(["app|foo.txt"], {"app": [[transformer]]}); |
172 | 172 |
173 updateSources(["app|foo.txt"]); | 173 updateSources(["app|foo.txt"]); |
174 expectNoAsset("app|foo.out"); | 174 expectNoAsset("app|foo.out"); |
175 buildShouldFail([isTransformerException(equals(LazyBadTransformer.ERROR))]); | 175 buildShouldFail([isTransformerException(equals(LazyBadTransformer.ERROR))]); |
176 expect(transformer.numRuns, completion(equals(0))); | 176 expect(transformer.numRuns, completion(equals(0))); |
177 }); | 177 }); |
178 } | 178 } |
OLD | NEW |