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 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
| 10 import 'package:barback/src/utils.dart'; |
10 import 'package:scheduled_test/scheduled_test.dart'; | 11 import 'package:scheduled_test/scheduled_test.dart'; |
11 | 12 |
12 import '../utils.dart'; | 13 import '../utils.dart'; |
13 | 14 |
14 main() { | 15 main() { |
15 initConfig(); | 16 initConfig(); |
16 test("gets a source asset", () { | 17 test("gets a source asset", () { |
17 initGraph(["app|foo.txt"]); | 18 initGraph(["app|foo.txt"]); |
18 updateSources(["app|foo.txt"]); | 19 updateSources(["app|foo.txt"]); |
19 expectAsset("app|foo.txt"); | 20 expectAsset("app|foo.txt"); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 106 |
106 schedule(() { | 107 schedule(() { |
107 removeSources(["app|foo.txt"]); | 108 removeSources(["app|foo.txt"]); |
108 updateSources(["app|foo.txt"]); | 109 updateSources(["app|foo.txt"]); |
109 }); | 110 }); |
110 | 111 |
111 expectAsset("app|foo.txt"); | 112 expectAsset("app|foo.txt"); |
112 buildShouldSucceed(); | 113 buildShouldSucceed(); |
113 }); | 114 }); |
114 | 115 |
| 116 test("reloads an asset that's updated while loading", () { |
| 117 initGraph({"app|foo.txt": "foo"}); |
| 118 |
| 119 pauseProvider(); |
| 120 schedule(() { |
| 121 // The mock provider synchronously loads the value of the assets, so this |
| 122 // will kick off two loads with different values. The second one should |
| 123 // win. |
| 124 updateSources(["app|foo.txt"]); |
| 125 modifyAsset("app|foo.txt", "bar"); |
| 126 updateSources(["app|foo.txt"]); |
| 127 }); |
| 128 |
| 129 resumeProvider(); |
| 130 expectAsset("app|foo.txt", "bar"); |
| 131 buildShouldSucceed(); |
| 132 }); |
| 133 |
115 test("restarts a build if a source is updated while sources are loading", () { | 134 test("restarts a build if a source is updated while sources are loading", () { |
116 var transformer = new RewriteTransformer("txt", "out"); | 135 var transformer = new RewriteTransformer("txt", "out"); |
117 initGraph(["app|foo.txt", "app|other.bar"], {"app": [[transformer]]}); | 136 initGraph(["app|foo.txt", "app|other.bar"], {"app": [[transformer]]}); |
118 | 137 |
119 // Run the whole graph so all nodes are clean. | 138 // Run the whole graph so all nodes are clean. |
120 updateSources(["app|foo.txt", "app|other.bar"]); | 139 updateSources(["app|foo.txt", "app|other.bar"]); |
121 expectAsset("app|foo.out", "foo.out"); | 140 expectAsset("app|foo.out", "foo.out"); |
122 expectAsset("app|other.bar"); | 141 expectAsset("app|other.bar"); |
123 | 142 |
124 buildShouldSucceed(); | 143 buildShouldSucceed(); |
(...skipping 14 matching lines...) Expand all Loading... |
139 resumeProvider(); | 158 resumeProvider(); |
140 | 159 |
141 buildShouldSucceed(); | 160 buildShouldSucceed(); |
142 waitForBuild(); | 161 waitForBuild(); |
143 | 162 |
144 schedule(() { | 163 schedule(() { |
145 expect(transformer.numRuns, equals(2)); | 164 expect(transformer.numRuns, equals(2)); |
146 }); | 165 }); |
147 }); | 166 }); |
148 } | 167 } |
OLD | NEW |