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

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

Issue 808713003: Remove barback from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library barback.test.package_graph.source_test;
6
7 import 'package:barback/src/utils.dart';
8 import 'package:scheduled_test/scheduled_test.dart';
9
10 import '../utils.dart';
11
12 main() {
13 initConfig();
14
15 test("does not report asset not found errors in results", () {
16 initGraph(["app|bar.txt"]);
17
18 // Trigger a build.
19 updateSources(["app|bar.txt"]);
20
21 expectNoAsset("app|foo.txt");
22 buildShouldSucceed();
23 });
24
25 test("reports an error for an unprovided package", () {
26 initGraph();
27 expect(() => updateSourcesSync(["unknown|foo.txt"]), throwsArgumentError);
28 });
29
30 test("reports an error for an unprovided source", () {
31 initGraph(["app|known.txt"], {"app": [
32 // Have a dummy transformer so that barback at least tries to load the
33 // asset.
34 [new RewriteTransformer("a", "b")]
35 ]});
36
37 updateSources(["app|unknown.txt"]);
38
39 buildShouldFail([
40 isAssetLoadException("app|unknown.txt",
41 isAssetNotFoundException("app|unknown.txt"))
42 ]);
43 });
44
45 test("reports missing input errors in results", () {
46 initGraph({"app|a.txt": "a.inc"}, {"app": [
47 [new ManyToOneTransformer("txt")]
48 ]});
49
50 updateSources(["app|a.txt"]);
51 expectNoAsset("app|a.out");
52 buildShouldFail([isMissingInputException("app|a.inc")]);
53 });
54
55 test("reports an error if a transformer emits an asset for another package",
56 () {
57 initGraph(["app|foo.txt"], {
58 "app": [[new CreateAssetTransformer("wrong|foo.txt")]]
59 });
60
61 updateSources(["app|foo.txt"]);
62 buildShouldFail([isInvalidOutputException("wrong|foo.txt")]);
63 });
64
65 test("fails if a non-primary input is removed", () {
66 initGraph({
67 "app|a.txt": "a.inc,b.inc,c.inc",
68 "app|a.inc": "a",
69 "app|b.inc": "b",
70 "app|c.inc": "c"
71 }, {"app": [
72 [new ManyToOneTransformer("txt")]
73 ]});
74
75 updateSources(["app|a.txt", "app|a.inc", "app|b.inc", "app|c.inc"]);
76 expectAsset("app|a.out", "abc");
77 buildShouldSucceed();
78
79 removeSources(["app|b.inc"]);
80 buildShouldFail([isMissingInputException("app|b.inc")]);
81 expectNoAsset("app|a.out");
82 });
83
84 test("catches transformer exceptions and reports them", () {
85 initGraph(["app|foo.txt"], {"app": [
86 [new BadTransformer(["app|foo.out"])]
87 ]});
88
89 updateSources(["app|foo.txt"]);
90 expectNoAsset("app|foo.out");
91 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
92 });
93
94 test("catches errors even if nothing is waiting for process results", () {
95 initGraph(["app|foo.txt"], {"app": [[new BadTransformer([])]]});
96
97 updateSources(["app|foo.txt"]);
98 // Note: No asset requests here.
99 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
100 });
101
102 test("discards outputs from failed transforms", () {
103 initGraph(["app|foo.txt"], {"app": [
104 [new BadTransformer(["a.out", "b.out"])]
105 ]});
106
107 updateSources(["app|foo.txt"]);
108 expectNoAsset("app|a.out");
109 });
110
111 test("fails if only one package fails", () {
112 initGraph(["pkg1|foo.txt", "pkg2|foo.txt"],
113 {"pkg1": [[new BadTransformer([])]]});
114
115 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
116 expectAsset("pkg2|foo.txt", "foo");
117 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
118 });
119
120 test("emits multiple failures if multiple packages fail", () {
121 initGraph(["pkg1|foo.txt", "pkg2|foo.txt"], {
122 "pkg1": [[new BadTransformer([])]],
123 "pkg2": [[new BadTransformer([])]]
124 });
125
126 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
127 buildShouldFail([
128 isTransformerException(equals(BadTransformer.ERROR)),
129 isTransformerException(equals(BadTransformer.ERROR))
130 ]);
131 });
132
133 test("an error loading an asset removes the asset from the graph", () {
134 initGraph(["app|foo.txt"], {"app": [
135 // Have a dummy transformer so that barback at least tries to load the
136 // asset.
137 [new RewriteTransformer("a", "b")]
138 ]});
139
140 setAssetError("app|foo.txt");
141 updateSources(["app|foo.txt"]);
142 expectNoAsset("app|foo.txt");
143 buildShouldFail([
144 isAssetLoadException("app|foo.txt", isMockLoadException("app|foo.txt"))
145 ]);
146 });
147
148 test("a synchronous error loading an asset removes the asset from the graph",
149 () {
150 initGraph(["app|foo.txt"], {"app": [
151 // Have a dummy transformer so that barback at least tries to load the
152 // asset.
153 [new RewriteTransformer("a", "b")]
154 ]});
155
156 setAssetError("app|foo.txt", async: false);
157 updateSources(["app|foo.txt"]);
158 expectNoAsset("app|foo.txt");
159 buildShouldFail([
160 isAssetLoadException("app|foo.txt", isMockLoadException("app|foo.txt"))
161 ]);
162 });
163
164 test("an asset isn't passed through a transformer with an error", () {
165 initGraph(["app|foo.txt"], {"app": [[new BadTransformer([])]]});
166
167 updateSources(["app|foo.txt"]);
168 expectNoAsset("app|foo.txt");
169 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
170 });
171
172 test("a transformer that logs errors shouldn't produce output", () {
173 initGraph(["app|foo.txt"], {"app": [
174 [new BadLogTransformer(["app|out.txt"])]
175 ]});
176
177 updateSources(["app|foo.txt"]);
178 expectNoAsset("app|foo.txt");
179 expectNoAsset("app|out.txt");
180 buildShouldFail([
181 isTransformerException(equals("first error")),
182 isTransformerException(equals("second error"))
183 ]);
184 });
185
186 test("a transformer can catch an error loading a secondary input", () {
187 initGraph(["app|foo.txt"], {"app": [
188 [new CatchAssetNotFoundTransformer(".txt", "app|nothing")]
189 ]});
190
191 updateSources(["app|foo.txt"]);
192 expectAsset("app|foo.txt", "failed to load app|nothing");
193 buildShouldSucceed();
194 });
195
196 test("a transformer that fails due to a missing secondary input is re-run "
197 "when that input appears", () {
198 initGraph({
199 "app|foo.txt": "bar.inc",
200 "app|bar.inc": "bar"
201 }, {"app": [
202 [new ManyToOneTransformer("txt")]
203 ]});
204
205 updateSources(["app|foo.txt"]);
206 expectNoAsset("app|foo.out");
207 buildShouldFail([isMissingInputException("app|bar.inc")]);
208
209 updateSources(["app|bar.inc"]);
210 expectAsset("app|foo.out", "bar");
211 buildShouldSucceed();
212 });
213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698