| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 test("an error emitted in a lazy transformer's declareOuputs method prevents " | 168 test("an error emitted in a lazy transformer's declareOuputs method prevents " |
| 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 |
| 179 test("a lazy transformer passes through inputs it doesn't apply to", () { |
| 180 initGraph(["app|foo.txt"], {"app": [ |
| 181 [new LazyRewriteTransformer("blub", "blab")] |
| 182 ]}); |
| 183 |
| 184 updateSources(["app|foo.txt"]); |
| 185 expectAsset("app|foo.txt"); |
| 186 buildShouldSucceed(); |
| 187 }); |
| 188 |
| 189 test("a lazy transformer passes through inputs it doesn't overwrite", () { |
| 190 initGraph(["app|foo.txt"], {"app": [ |
| 191 [new LazyRewriteTransformer("txt", "out")] |
| 192 ]}); |
| 193 |
| 194 updateSources(["app|foo.txt"]); |
| 195 expectAsset("app|foo.txt"); |
| 196 buildShouldSucceed(); |
| 197 }); |
| 198 |
| 199 test("a lazy transformer doesn't pass through inputs it overwrites", () { |
| 200 initGraph(["app|foo.txt"], {"app": [ |
| 201 [new LazyRewriteTransformer("txt", "txt")] |
| 202 ]}); |
| 203 |
| 204 updateSources(["app|foo.txt"]); |
| 205 expectAsset("app|foo.txt", "foo.txt"); |
| 206 buildShouldSucceed(); |
| 207 }); |
| 208 |
| 209 test("a lazy transformer doesn't pass through inputs it consumes", () { |
| 210 initGraph(["app|foo.txt"], {"app": [ |
| 211 [new LazyRewriteTransformer("txt", "out")..consumePrimary = true] |
| 212 ]}); |
| 213 |
| 214 updateSources(["app|foo.txt"]); |
| 215 expectNoAsset("app|foo.txt"); |
| 216 buildShouldSucceed(); |
| 217 }); |
| 218 |
| 219 test("a lazy transformer that doesn't apply does nothing when forced", () { |
| 220 initGraph(["app|foo.txt"], {"app": [ |
| 221 [new LazyRewriteTransformer("blub", "blab")] |
| 222 ]}); |
| 223 |
| 224 updateSources(["app|foo.txt"]); |
| 225 expectNoAsset("app|foo.blab"); |
| 226 |
| 227 // Getting all assets will force every lazy transformer. This shouldn't |
| 228 // cause the rewrite to apply, because foo.txt isn't primary. |
| 229 expectAllAssets(["app|foo.txt"]); |
| 230 buildShouldSucceed(); |
| 231 }); |
| 178 } | 232 } |
| OLD | NEW |