| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.source_test; | 5 library barback.test.package_graph.source_test; |
| 6 | 6 |
| 7 import 'package:scheduled_test/scheduled_test.dart'; | 7 import 'package:scheduled_test/scheduled_test.dart'; |
| 8 | 8 |
| 9 import '../utils.dart'; | 9 import '../utils.dart'; |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Sources must be explicitly made visible to barback by calling | 34 // Sources must be explicitly made visible to barback by calling |
| 35 // updateSources() on them. It isn't enough for the provider to be able | 35 // updateSources() on them. It isn't enough for the provider to be able |
| 36 // to provide it. | 36 // to provide it. |
| 37 // | 37 // |
| 38 // This lets you distinguish between sources that you want to be primaries | 38 // This lets you distinguish between sources that you want to be primaries |
| 39 // and the larger set of inputs that those primaries are allowed to pull in. | 39 // and the larger set of inputs that those primaries are allowed to pull in. |
| 40 expectNoAsset("app|foo.txt"); | 40 expectNoAsset("app|foo.txt"); |
| 41 }); | 41 }); |
| 42 | 42 |
| 43 test("gets a source asset if not transformed", () { | 43 test("gets a source asset if not transformed", () { |
| 44 initGraph(["app|foo.txt"], {"app": [ | 44 initGraph([ |
| 45 [new RewriteTransformer("nottxt", "whatever")] | 45 "app|foo.txt" |
| 46 ]}); | 46 ], { |
| 47 "app": [ |
| 48 [new RewriteTransformer("nottxt", "whatever")] |
| 49 ] |
| 50 }); |
| 47 | 51 |
| 48 updateSources(["app|foo.txt"]); | 52 updateSources(["app|foo.txt"]); |
| 49 expectAsset("app|foo.txt"); | 53 expectAsset("app|foo.txt"); |
| 50 buildShouldSucceed(); | 54 buildShouldSucceed(); |
| 51 }); | 55 }); |
| 52 | 56 |
| 53 test("doesn't get a removed source", () { | 57 test("doesn't get a removed source", () { |
| 54 initGraph(["app|foo.txt"]); | 58 initGraph(["app|foo.txt"]); |
| 55 | 59 |
| 56 updateSources(["app|foo.txt"]); | 60 updateSources(["app|foo.txt"]); |
| 57 expectAsset("app|foo.txt"); | 61 expectAsset("app|foo.txt"); |
| 58 buildShouldSucceed(); | 62 buildShouldSucceed(); |
| 59 | 63 |
| 60 removeSources(["app|foo.txt"]); | 64 removeSources(["app|foo.txt"]); |
| 61 expectNoAsset("app|foo.txt"); | 65 expectNoAsset("app|foo.txt"); |
| 62 buildShouldSucceed(); | 66 buildShouldSucceed(); |
| 63 }); | 67 }); |
| 64 | 68 |
| 65 test("collapses redundant updates", () { | 69 test("collapses redundant updates", () { |
| 66 var transformer = new RewriteTransformer("blub", "blab"); | 70 var transformer = new RewriteTransformer("blub", "blab"); |
| 67 initGraph(["app|foo.blub"], {"app": [[transformer]]}); | 71 initGraph([ |
| 72 "app|foo.blub" |
| 73 ], { |
| 74 "app": [ |
| 75 [transformer] |
| 76 ] |
| 77 }); |
| 68 | 78 |
| 69 schedule(() { | 79 schedule(() { |
| 70 // Make a bunch of synchronous update calls. | 80 // Make a bunch of synchronous update calls. |
| 71 updateSourcesSync(["app|foo.blub"]); | 81 updateSourcesSync(["app|foo.blub"]); |
| 72 updateSourcesSync(["app|foo.blub"]); | 82 updateSourcesSync(["app|foo.blub"]); |
| 73 updateSourcesSync(["app|foo.blub"]); | 83 updateSourcesSync(["app|foo.blub"]); |
| 74 updateSourcesSync(["app|foo.blub"]); | 84 updateSourcesSync(["app|foo.blub"]); |
| 75 }); | 85 }); |
| 76 | 86 |
| 77 expectAsset("app|foo.blab", "foo.blab"); | 87 expectAsset("app|foo.blab", "foo.blab"); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 modifyAsset("app|foo.txt", "bar"); | 125 modifyAsset("app|foo.txt", "bar"); |
| 116 updateSources(["app|foo.txt"]); | 126 updateSources(["app|foo.txt"]); |
| 117 | 127 |
| 118 resumeProvider(); | 128 resumeProvider(); |
| 119 expectAsset("app|foo.txt", "bar"); | 129 expectAsset("app|foo.txt", "bar"); |
| 120 buildShouldSucceed(); | 130 buildShouldSucceed(); |
| 121 }); | 131 }); |
| 122 | 132 |
| 123 test("restarts a build if a source is updated while sources are loading", () { | 133 test("restarts a build if a source is updated while sources are loading", () { |
| 124 var transformer = new RewriteTransformer("txt", "out"); | 134 var transformer = new RewriteTransformer("txt", "out"); |
| 125 initGraph(["app|foo.txt", "app|other.bar"], {"app": [[transformer]]}); | 135 initGraph([ |
| 136 "app|foo.txt", |
| 137 "app|other.bar" |
| 138 ], { |
| 139 "app": [ |
| 140 [transformer] |
| 141 ] |
| 142 }); |
| 126 | 143 |
| 127 // Run the whole graph so all nodes are clean. | 144 // Run the whole graph so all nodes are clean. |
| 128 updateSources(["app|foo.txt", "app|other.bar"]); | 145 updateSources(["app|foo.txt", "app|other.bar"]); |
| 129 expectAsset("app|foo.out", "foo.out"); | 146 expectAsset("app|foo.out", "foo.out"); |
| 130 expectAsset("app|other.bar"); | 147 expectAsset("app|other.bar"); |
| 131 | 148 |
| 132 buildShouldSucceed(); | 149 buildShouldSucceed(); |
| 133 | 150 |
| 134 // Make the provider slow to load a source. | 151 // Make the provider slow to load a source. |
| 135 pauseProvider(); | 152 pauseProvider(); |
| 136 | 153 |
| 137 // Update an asset that doesn't trigger any transformers. | 154 // Update an asset that doesn't trigger any transformers. |
| 138 updateSources(["app|other.bar"]); | 155 updateSources(["app|other.bar"]); |
| 139 | 156 |
| 140 // Now update an asset that does trigger a transformer. | 157 // Now update an asset that does trigger a transformer. |
| 141 updateSources(["app|foo.txt"]); | 158 updateSources(["app|foo.txt"]); |
| 142 | 159 |
| 143 resumeProvider(); | 160 resumeProvider(); |
| 144 | 161 |
| 145 buildShouldSucceed(); | 162 buildShouldSucceed(); |
| 146 | 163 |
| 147 expect(transformer.numRuns, completion(equals(2))); | 164 expect(transformer.numRuns, completion(equals(2))); |
| 148 }); | 165 }); |
| 149 } | 166 } |
| OLD | NEW |