| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 transformer.pauseApply(); | 82 transformer.pauseApply(); |
| 83 updateSources(["app|foo.blub"]); | 83 updateSources(["app|foo.blub"]); |
| 84 expectAssetDoesNotComplete("app|foo.blub"); | 84 expectAssetDoesNotComplete("app|foo.blub"); |
| 85 | 85 |
| 86 transformer.resumeApply(); | 86 transformer.resumeApply(); |
| 87 expectAsset("app|foo.blub", "foo.blub"); | 87 expectAsset("app|foo.blub", "foo.blub"); |
| 88 buildShouldSucceed(); | 88 buildShouldSucceed(); |
| 89 }); | 89 }); |
| 90 | 90 |
| 91 test("a declaring transformer following a lazy transformer runs eagerly once " |
| 92 "its input is available", () { |
| 93 var declaring = new DeclaringRewriteTransformer("two", "three"); |
| 94 initGraph(["app|foo.in"], {"app": [ |
| 95 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], |
| 96 [declaring] |
| 97 ]}); |
| 98 |
| 99 updateSources(["app|foo.in"]); |
| 100 expectAsset("app|out.one", "app|out.one"); |
| 101 buildShouldSucceed(); |
| 102 |
| 103 expect(declaring.numRuns, completion(equals(1))); |
| 104 }); |
| 105 |
| 106 test("a declaring transformer following a lazy transformer doesn't re-run if " |
| 107 "its input becomes available and then unavailable", () { |
| 108 var declaring = new DeclaringRewriteTransformer("two", "three"); |
| 109 initGraph(["app|foo.in"], {"app": [ |
| 110 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], |
| 111 [declaring] |
| 112 ]}); |
| 113 |
| 114 // Start [declaring] running, because its input became available. |
| 115 declaring.pauseApply(); |
| 116 updateSources(["app|foo.in"]); |
| 117 expectAsset("app|out.one", "app|out.one"); |
| 118 expectAssetDoesNotComplete("app|out.three"); |
| 119 |
| 120 // Now [declaring]'s input is dirty, so it shouldn't re-run without an |
| 121 // explicit request. |
| 122 updateSources(["app|foo.in"]); |
| 123 declaring.resumeApply(); |
| 124 buildShouldSucceed(); |
| 125 |
| 126 // [declaring] should only have run once, despite its input changing. After |
| 127 // the first run, it should be awaiting a force() call. |
| 128 expect(declaring.numRuns, completion(equals(1))); |
| 129 |
| 130 // Once we make a request, [declaring] should force the lazy transformer and |
| 131 // then run itself. |
| 132 expectAsset("app|out.three", "app|out.two.three"); |
| 133 buildShouldSucceed(); |
| 134 |
| 135 // Now [declaring] should have run twice. This ensures that it didn't use |
| 136 // its original output for some reason. |
| 137 expect(declaring.numRuns, completion(equals(2))); |
| 138 }); |
| 139 |
| 91 group("with an error in declareOutputs", () { | 140 group("with an error in declareOutputs", () { |
| 92 test("still runs apply", () { | 141 test("still runs apply", () { |
| 93 initGraph(["app|foo.txt"], {"app": [[ | 142 initGraph(["app|foo.txt"], {"app": [[ |
| 94 new DeclaringBadTransformer("app|out.txt", | 143 new DeclaringBadTransformer("app|out.txt", |
| 95 declareError: true, applyError: false) | 144 declareError: true, applyError: false) |
| 96 ]]}); | 145 ]]}); |
| 97 | 146 |
| 98 updateSources(["app|foo.txt"]); | 147 updateSources(["app|foo.txt"]); |
| 99 expectAsset("app|out.txt", "bad out"); | 148 expectAsset("app|out.txt", "bad out"); |
| 100 expectAsset("app|foo.txt", "foo"); | 149 expectAsset("app|foo.txt", "foo"); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 test("can declare outputs it doesn't emit", () { | 211 test("can declare outputs it doesn't emit", () { |
| 163 initGraph(["app|foo.txt"], {"app": [ | 212 initGraph(["app|foo.txt"], {"app": [ |
| 164 [new DeclareAssetsTransformer(["app|out.txt"], [])] | 213 [new DeclareAssetsTransformer(["app|out.txt"], [])] |
| 165 ]}); | 214 ]}); |
| 166 | 215 |
| 167 updateSources(["app|foo.txt"]); | 216 updateSources(["app|foo.txt"]); |
| 168 expectNoAsset("app|out.txt"); | 217 expectNoAsset("app|out.txt"); |
| 169 buildShouldSucceed(); | 218 buildShouldSucceed(); |
| 170 }); | 219 }); |
| 171 } | 220 } |
| OLD | NEW |