Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: pkg/barback/test/package_graph/errors_test.dart

Issue 22685006: Better handling of asset collisions in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/barback/lib/src/transform_node.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17
17 test("errors if two transformers output the same file", () { 18 test("errors if two transformers output the same file", () {
18 initGraph(["app|foo.a"], {"app": [ 19 initGraph(["app|foo.a"], {"app": [
19 [ 20 [
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 }); 163 });
163 164
164 test("an error loading an asset removes the asset from the graph", () { 165 test("an error loading an asset removes the asset from the graph", () {
165 initGraph(["app|foo.txt"]); 166 initGraph(["app|foo.txt"]);
166 167
167 setAssetError("app|foo.txt"); 168 setAssetError("app|foo.txt");
168 updateSources(["app|foo.txt"]); 169 updateSources(["app|foo.txt"]);
169 expectNoAsset("app|foo.txt"); 170 expectNoAsset("app|foo.txt");
170 buildShouldFail([isMockLoadException("app|foo.txt")]); 171 buildShouldFail([isMockLoadException("app|foo.txt")]);
171 }); 172 });
173
174 test("a collision returns the first-produced output", () {
175 var rewrite1 = new RewriteTransformer("one", "out");
176 var rewrite2 = new RewriteTransformer("two", "out");
177 initGraph({
178 "app|foo.one": "one",
179 "app|foo.two": "two"
180 }, {"app": [[rewrite1, rewrite2]]});
181
182 rewrite1.pauseApply();
183 updateSources(["app|foo.one", "app|foo.two"]);
184 // Wait long enough to ensure that rewrite2 has completed.
185 schedule(pumpEventQueue);
186
187 rewrite1.resumeApply();
188 expectAsset("app|foo.out", "two.out");
189 buildShouldFail([isAssetCollisionException("app|foo.out")]);
190
191 // Even after the collision is discovered, the first-produced output should
192 // be returned.
193 expectAsset("app|foo.out", "two.out");
194
195 // Even if the other output is updated more recently, the first output
196 // should continue to take precedence.
197 updateSources(["app|foo.one"]);
198 expectAsset("app|foo.out", "two.out");
199 });
200
201 test("a collision that is later resolved produces an output", () {
202 initGraph({
203 "app|foo.one": "one",
204 "app|foo.two": "two"
205 }, {"app": [
206 [
207 new RewriteTransformer("one", "out"),
208 new RewriteTransformer("two", "out")
209 ]
210 ]});
211
212 updateSources(["app|foo.one"]);
213 expectAsset("app|foo.out", "one.out");
214 buildShouldSucceed();
215
216 updateSources(["app|foo.two"]);
217 expectAsset("app|foo.out", "one.out");
218 buildShouldFail([isAssetCollisionException("app|foo.out")]);
219
220 removeSources(["app|foo.one"]);
221 expectAsset("app|foo.out", "two.out");
222 buildShouldSucceed();
223 });
224
225 test("a collision that is later resolved runs transforms", () {
226 initGraph({
227 "app|foo.one": "one",
228 "app|foo.two": "two"
229 }, {"app": [
230 [
231 new RewriteTransformer("one", "mid"),
232 new RewriteTransformer("two", "mid")
233 ],
234 [new RewriteTransformer("mid", "out")]
235 ]});
236
237 updateSources(["app|foo.one"]);
238 expectAsset("app|foo.out", "one.mid.out");
239 buildShouldSucceed();
240
241 updateSources(["app|foo.two"]);
242 expectAsset("app|foo.out", "one.mid.out");
243 buildShouldFail([isAssetCollisionException("app|foo.mid")]);
244
245 removeSources(["app|foo.one"]);
246 expectAsset("app|foo.out", "two.mid.out");
247 buildShouldSucceed();
248 });
249
250 test("a collision that is partially resolved returns the second completed "
251 "output", () {
252 var rewrite1 = new RewriteTransformer("one", "out");
253 var rewrite2 = new RewriteTransformer("two", "out");
254 var rewrite3 = new RewriteTransformer("three", "out");
255 initGraph({
256 "app|foo.one": "one",
257 "app|foo.two": "two",
258 "app|foo.three": "three"
259 }, {"app": [[rewrite1, rewrite2, rewrite3]]});
260
261 // Make rewrite3 the most-recently-completed transformer from the first run.
262 rewrite2.pauseApply();
263 rewrite3.pauseApply();
264 updateSources(["app|foo.one", "app|foo.two", "app|foo.three"]);
265 schedule(pumpEventQueue);
266 rewrite2.resumeApply();
267 schedule(pumpEventQueue);
268 rewrite3.resumeApply();
269 buildShouldFail([isAssetCollisionException("app|foo.out")]);
270
271 // Then update rewrite3 in a separate build. rewrite2 should still be the
272 // next version of foo.out in line.
273 // TODO(nweiz): Should this emit a collision error as well? Or should they
274 // only be emitted when a file is added or removed?
275 updateSources(["app|foo.three"]);
276 buildShouldSucceed();
277
278 removeSources(["app|foo.one"]);
279 expectAsset("app|foo.out", "two.out");
280 buildShouldFail([isAssetCollisionException("app|foo.out")]);
281 });
172 } 282 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/transform_node.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698