| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 test("a declaring transformer following a lazy transformer runs eagerly once " | 91 test("a declaring transformer following a lazy transformer runs eagerly once " |
| 92 "its input is available", () { | 92 "its input is available", () { |
| 93 var declaring = new DeclaringRewriteTransformer("two", "three"); | 93 var declaring = new DeclaringRewriteTransformer("two", "three"); |
| 94 initGraph(["app|foo.in"], {"app": [ | 94 initGraph(["app|foo.in"], {"app": [ |
| 95 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], | 95 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], |
| 96 [declaring] | 96 [declaring] |
| 97 ]}); | 97 ]}); |
| 98 | 98 |
| 99 updateSources(["app|foo.in"]); | 99 updateSources(["app|foo.in"]); |
| 100 // Give the transformers time to declare their assets. |
| 101 schedule(pumpEventQueue); |
| 102 |
| 100 expectAsset("app|out.one", "app|out.one"); | 103 expectAsset("app|out.one", "app|out.one"); |
| 101 buildShouldSucceed(); | 104 buildShouldSucceed(); |
| 102 | 105 |
| 103 expect(declaring.numRuns, completion(equals(1))); | 106 expect(declaring.numRuns, completion(equals(1))); |
| 104 }); | 107 }); |
| 105 | 108 |
| 106 test("a declaring transformer following a lazy transformer doesn't re-run if " | 109 test("a declaring transformer following a lazy transformer doesn't re-run if " |
| 107 "its input becomes available and then unavailable", () { | 110 "its input becomes available and then unavailable", () { |
| 108 var declaring = new DeclaringRewriteTransformer("two", "three"); | 111 var declaring = new DeclaringRewriteTransformer("two", "three"); |
| 109 initGraph(["app|foo.in"], {"app": [ | 112 initGraph(["app|foo.in"], {"app": [ |
| 110 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], | 113 [new LazyAssetsTransformer(["app|out.one", "app|out.two"])], |
| 111 [declaring] | 114 [declaring] |
| 112 ]}); | 115 ]}); |
| 113 | 116 |
| 114 // Start [declaring] running, because its input became available. | 117 // Start [declaring] running, because its input became available. |
| 115 declaring.pauseApply(); | 118 declaring.pauseApply(); |
| 116 updateSources(["app|foo.in"]); | 119 updateSources(["app|foo.in"]); |
| 120 // Give the transformers time to declare their assets. |
| 121 schedule(pumpEventQueue); |
| 122 |
| 117 expectAsset("app|out.one", "app|out.one"); | 123 expectAsset("app|out.one", "app|out.one"); |
| 118 expectAssetDoesNotComplete("app|out.three"); | 124 expectAssetDoesNotComplete("app|out.three"); |
| 119 | 125 |
| 120 // Now [declaring]'s input is dirty, so it shouldn't re-run without an | 126 // Now [declaring]'s input is dirty, so it shouldn't re-run without an |
| 121 // explicit request. | 127 // explicit request. |
| 122 updateSources(["app|foo.in"]); | 128 updateSources(["app|foo.in"]); |
| 123 declaring.resumeApply(); | 129 declaring.resumeApply(); |
| 124 buildShouldSucceed(); | 130 buildShouldSucceed(); |
| 125 | 131 |
| 126 // [declaring] should only have run once, despite its input changing. After | 132 // [declaring] should only have run once, despite its input changing. After |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 test("can declare outputs it doesn't emit", () { | 217 test("can declare outputs it doesn't emit", () { |
| 212 initGraph(["app|foo.txt"], {"app": [ | 218 initGraph(["app|foo.txt"], {"app": [ |
| 213 [new DeclareAssetsTransformer(["app|out.txt"], [])] | 219 [new DeclareAssetsTransformer(["app|out.txt"], [])] |
| 214 ]}); | 220 ]}); |
| 215 | 221 |
| 216 updateSources(["app|foo.txt"]); | 222 updateSources(["app|foo.txt"]); |
| 217 expectNoAsset("app|out.txt"); | 223 expectNoAsset("app|out.txt"); |
| 218 buildShouldSucceed(); | 224 buildShouldSucceed(); |
| 219 }); | 225 }); |
| 220 } | 226 } |
| OLD | NEW |