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

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

Issue 195993005: Don't pass an asset through a transformer that produces an error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: move more tests into collisions_test Created 6 years, 9 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
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 'package:barback/src/utils.dart'; 7 import 'package:barback/src/utils.dart';
8 import 'package:scheduled_test/scheduled_test.dart'; 8 import 'package:scheduled_test/scheduled_test.dart';
9 9
10 import '../utils.dart'; 10 import '../utils.dart';
(...skipping 22 matching lines...) Expand all
33 ] 33 ]
34 ]}); 34 ]});
35 updateSources(["app|foo.a"]); 35 updateSources(["app|foo.a"]);
36 expectAsset("app|foo.c", "foo.c"); 36 expectAsset("app|foo.c", "foo.c");
37 buildShouldSucceed(); 37 buildShouldSucceed();
38 38
39 updateSources(["app|foo.b"]); 39 updateSources(["app|foo.b"]);
40 buildShouldFail([isAssetCollisionException("app|foo.c")]); 40 buildShouldFail([isAssetCollisionException("app|foo.c")]);
41 }); 41 });
42 42
43 test("does not report asset not found errors in results", () {
44 initGraph(["app|bar.txt"]);
45
46 // Trigger a build.
47 updateSources(["app|bar.txt"]);
48
49 expectNoAsset("app|foo.txt");
50 buildShouldSucceed();
51 });
52
53 test("reports an error for an unprovided package", () {
54 initGraph();
55 expect(() => updateSourcesSync(["unknown|foo.txt"]), throwsArgumentError);
56 });
57
58 test("reports an error for an unprovided source", () {
59 initGraph(["app|known.txt"], {"app": [
60 // Have a dummy transformer so that barback at least tries to load the
61 // asset.
62 [new RewriteTransformer("a", "b")]
63 ]});
64
65 updateSources(["app|unknown.txt"]);
66
67 buildShouldFail([
68 isAssetLoadException("app|unknown.txt",
69 isAssetNotFoundException("app|unknown.txt"))
70 ]);
71 });
72
73 test("reports missing input errors in results", () {
74 initGraph({"app|a.txt": "a.inc"}, {"app": [
75 [new ManyToOneTransformer("txt")]
76 ]});
77
78 updateSources(["app|a.txt"]);
79 expectNoAsset("app|a.out");
80 buildShouldFail([isMissingInputException("app|a.inc")]);
81 });
82
83 test("reports an error if a transformer emits an asset for another package",
84 () {
85 initGraph(["app|foo.txt"], {
86 "app": [[new CreateAssetTransformer("wrong|foo.txt")]]
87 });
88
89 updateSources(["app|foo.txt"]);
90 buildShouldFail([isInvalidOutputException("wrong|foo.txt")]);
91 });
92
93 test("fails if a non-primary input is removed", () {
94 initGraph({
95 "app|a.txt": "a.inc,b.inc,c.inc",
96 "app|a.inc": "a",
97 "app|b.inc": "b",
98 "app|c.inc": "c"
99 }, {"app": [
100 [new ManyToOneTransformer("txt")]
101 ]});
102
103 updateSources(["app|a.txt", "app|a.inc", "app|b.inc", "app|c.inc"]);
104 expectAsset("app|a.out", "abc");
105 buildShouldSucceed();
106
107 removeSources(["app|b.inc"]);
108 buildShouldFail([isMissingInputException("app|b.inc")]);
109 expectNoAsset("app|a.out");
110 });
111
112 test("catches transformer exceptions and reports them", () {
113 initGraph(["app|foo.txt"], {"app": [
114 [new BadTransformer(["app|foo.out"])]
115 ]});
116
117 updateSources(["app|foo.txt"]);
118 expectNoAsset("app|foo.out");
119 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
120 });
121
122 test("catches errors even if nothing is waiting for process results", () {
123 initGraph(["app|foo.txt"], {"app": [[new BadTransformer([])]]});
124
125 updateSources(["app|foo.txt"]);
126 // Note: No asset requests here.
127 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
128 });
129
130 test("discards outputs from failed transforms", () {
131 initGraph(["app|foo.txt"], {"app": [
132 [new BadTransformer(["a.out", "b.out"])]
133 ]});
134
135 updateSources(["app|foo.txt"]);
136 expectNoAsset("app|a.out");
137 });
138
139 test("fails if only one package fails", () {
140 initGraph(["pkg1|foo.txt", "pkg2|foo.txt"],
141 {"pkg1": [[new BadTransformer([])]]});
142
143 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
144 expectAsset("pkg2|foo.txt", "foo");
145 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
146 });
147
148 test("emits multiple failures if multiple packages fail", () {
149 initGraph(["pkg1|foo.txt", "pkg2|foo.txt"], {
150 "pkg1": [[new BadTransformer([])]],
151 "pkg2": [[new BadTransformer([])]]
152 });
153
154 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
155 buildShouldFail([
156 isTransformerException(equals(BadTransformer.ERROR)),
157 isTransformerException(equals(BadTransformer.ERROR))
158 ]);
159 });
160
161 test("an error loading an asset removes the asset from the graph", () {
162 initGraph(["app|foo.txt"], {"app": [
163 // Have a dummy transformer so that barback at least tries to load the
164 // asset.
165 [new RewriteTransformer("a", "b")]
166 ]});
167
168 setAssetError("app|foo.txt");
169 updateSources(["app|foo.txt"]);
170 expectNoAsset("app|foo.txt");
171 buildShouldFail([
172 isAssetLoadException("app|foo.txt", isMockLoadException("app|foo.txt"))
173 ]);
174 });
175
176 test("a collision returns the first-produced output", () { 43 test("a collision returns the first-produced output", () {
177 var rewrite1 = new RewriteTransformer("one", "out"); 44 var rewrite1 = new RewriteTransformer("one", "out");
178 var rewrite2 = new RewriteTransformer("two", "out"); 45 var rewrite2 = new RewriteTransformer("two", "out");
179 initGraph({ 46 initGraph({
180 "app|foo.one": "one", 47 "app|foo.one": "one",
181 "app|foo.two": "two" 48 "app|foo.two": "two"
182 }, {"app": [[rewrite1, rewrite2]]}); 49 }, {"app": [[rewrite1, rewrite2]]});
183 50
184 rewrite1.pauseApply(); 51 rewrite1.pauseApply();
185 updateSources(["app|foo.one", "app|foo.two"]); 52 updateSources(["app|foo.one", "app|foo.two"]);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 194
328 updateSources(["app|foo.txt"]); 195 updateSources(["app|foo.txt"]);
329 expectAsset("app|foo.txt", "foo"); 196 expectAsset("app|foo.txt", "foo");
330 buildShouldSucceed(); 197 buildShouldSucceed();
331 198
332 updateSources(["app|foo.in"]); 199 updateSources(["app|foo.in"]);
333 expectAsset("app|foo.txt", "foo"); 200 expectAsset("app|foo.txt", "foo");
334 buildShouldFail([isAssetCollisionException("app|foo.txt")]); 201 buildShouldFail([isAssetCollisionException("app|foo.txt")]);
335 }); 202 });
336 } 203 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/transform_node.dart ('k') | pkg/barback/test/package_graph/errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698