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

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

Issue 22961002: Add more metadata to non-programmatic barback exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Small fix 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/utils.dart ('k') | pkg/barback/test/utils.dart » ('j') | 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:barback/src/utils.dart';
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 test("reports an error for an unprovided package", () { 56 test("reports an error for an unprovided package", () {
57 initGraph(); 57 initGraph();
58 expect(() => updateSourcesSync(["unknown|foo.txt"]), throwsArgumentError); 58 expect(() => updateSourcesSync(["unknown|foo.txt"]), throwsArgumentError);
59 }); 59 });
60 60
61 test("reports an error for an unprovided source", () { 61 test("reports an error for an unprovided source", () {
62 initGraph(["app|known.txt"]); 62 initGraph(["app|known.txt"]);
63 updateSources(["app|unknown.txt"]); 63 updateSources(["app|unknown.txt"]);
64 64
65 buildShouldFail([isAssetNotFoundException("app|unknown.txt")]); 65 buildShouldFail([
66 isAssetLoadException("app|unknown.txt",
67 isAssetNotFoundException("app|unknown.txt"))
68 ]);
66 }); 69 });
67 70
68 test("reports missing input errors in results", () { 71 test("reports missing input errors in results", () {
69 initGraph({"app|a.txt": "a.inc"}, {"app": [ 72 initGraph({"app|a.txt": "a.inc"}, {"app": [
70 [new ManyToOneTransformer("txt")] 73 [new ManyToOneTransformer("txt")]
71 ]}); 74 ]});
72 75
73 updateSources(["app|a.txt"]); 76 updateSources(["app|a.txt"]);
74 expectNoAsset("app|a.out"); 77 expectNoAsset("app|a.out");
75 buildShouldFail([isMissingInputException("app|a.inc")]); 78 buildShouldFail([isMissingInputException("app|a.inc")]);
76 }); 79 });
77 80
78 test("reports an error if a transformer emits an asset for another package", 81 test("reports an error if a transformer emits an asset for another package",
79 () { 82 () {
80 initGraph(["app|foo.txt"], { 83 initGraph(["app|foo.txt"], {
81 "app": [[new CreateAssetTransformer("wrong|foo.txt")]] 84 "app": [[new CreateAssetTransformer("wrong|foo.txt")]]
82 }); 85 });
83 86
84 updateSources(["app|foo.txt"]); 87 updateSources(["app|foo.txt"]);
85 buildShouldFail([isInvalidOutputException("app", "wrong|foo.txt")]); 88 buildShouldFail([isInvalidOutputException("wrong|foo.txt")]);
86 }); 89 });
87 90
88 test("fails if a non-primary input is removed", () { 91 test("fails if a non-primary input is removed", () {
89 initGraph({ 92 initGraph({
90 "app|a.txt": "a.inc,b.inc,c.inc", 93 "app|a.txt": "a.inc,b.inc,c.inc",
91 "app|a.inc": "a", 94 "app|a.inc": "a",
92 "app|b.inc": "b", 95 "app|b.inc": "b",
93 "app|c.inc": "c" 96 "app|c.inc": "c"
94 }, {"app": [ 97 }, {"app": [
95 [new ManyToOneTransformer("txt")] 98 [new ManyToOneTransformer("txt")]
96 ]}); 99 ]});
97 100
98 updateSources(["app|a.txt", "app|a.inc", "app|b.inc", "app|c.inc"]); 101 updateSources(["app|a.txt", "app|a.inc", "app|b.inc", "app|c.inc"]);
99 expectAsset("app|a.out", "abc"); 102 expectAsset("app|a.out", "abc");
100 buildShouldSucceed(); 103 buildShouldSucceed();
101 104
102 removeSources(["app|b.inc"]); 105 removeSources(["app|b.inc"]);
103 buildShouldFail([isMissingInputException("app|b.inc")]); 106 buildShouldFail([isMissingInputException("app|b.inc")]);
104 expectNoAsset("app|a.out"); 107 expectNoAsset("app|a.out");
105 }); 108 });
106 109
107 test("catches transformer exceptions and reports them", () { 110 test("catches transformer exceptions and reports them", () {
108 initGraph(["app|foo.txt"], {"app": [ 111 initGraph(["app|foo.txt"], {"app": [
109 [new BadTransformer(["app|foo.out"])] 112 [new BadTransformer(["app|foo.out"])]
110 ]}); 113 ]});
111 114
112 updateSources(["app|foo.txt"]); 115 updateSources(["app|foo.txt"]);
113 expectNoAsset("app|foo.out"); 116 expectNoAsset("app|foo.out");
114 buildShouldFail([equals(BadTransformer.ERROR)]); 117 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
115 }); 118 });
116 119
117 test("doesn't yield a source if a transform fails on it", () { 120 test("doesn't yield a source if a transform fails on it", () {
118 initGraph(["app|foo.txt"], {"app": [ 121 initGraph(["app|foo.txt"], {"app": [
119 [new BadTransformer(["app|foo.txt"])] 122 [new BadTransformer(["app|foo.txt"])]
120 ]}); 123 ]});
121 124
122 updateSources(["app|foo.txt"]); 125 updateSources(["app|foo.txt"]);
123 expectNoAsset("app|foo.txt"); 126 expectNoAsset("app|foo.txt");
124 }); 127 });
125 128
126 test("catches errors even if nothing is waiting for process results", () { 129 test("catches errors even if nothing is waiting for process results", () {
127 initGraph(["app|foo.txt"], {"app": [[new BadTransformer([])]]}); 130 initGraph(["app|foo.txt"], {"app": [[new BadTransformer([])]]});
128 131
129 updateSources(["app|foo.txt"]); 132 updateSources(["app|foo.txt"]);
130 // Note: No asset requests here. 133 // Note: No asset requests here.
131 buildShouldFail([equals(BadTransformer.ERROR)]); 134 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
132 }); 135 });
133 136
134 test("discards outputs from failed transforms", () { 137 test("discards outputs from failed transforms", () {
135 initGraph(["app|foo.txt"], {"app": [ 138 initGraph(["app|foo.txt"], {"app": [
136 [new BadTransformer(["a.out", "b.out"])] 139 [new BadTransformer(["a.out", "b.out"])]
137 ]}); 140 ]});
138 141
139 updateSources(["app|foo.txt"]); 142 updateSources(["app|foo.txt"]);
140 expectNoAsset("app|a.out"); 143 expectNoAsset("app|a.out");
141 }); 144 });
142 145
143 test("fails if only one package fails", () { 146 test("fails if only one package fails", () {
144 initGraph(["pkg1|foo.txt", "pkg2|foo.txt"], 147 initGraph(["pkg1|foo.txt", "pkg2|foo.txt"],
145 {"pkg1": [[new BadTransformer([])]]}); 148 {"pkg1": [[new BadTransformer([])]]});
146 149
147 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]); 150 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
148 expectAsset("pkg2|foo.txt", "foo"); 151 expectAsset("pkg2|foo.txt", "foo");
149 buildShouldFail([equals(BadTransformer.ERROR)]); 152 buildShouldFail([isTransformerException(equals(BadTransformer.ERROR))]);
150 }); 153 });
151 154
152 test("emits multiple failures if multiple packages fail", () { 155 test("emits multiple failures if multiple packages fail", () {
153 initGraph(["pkg1|foo.txt", "pkg2|foo.txt"], { 156 initGraph(["pkg1|foo.txt", "pkg2|foo.txt"], {
154 "pkg1": [[new BadTransformer([])]], 157 "pkg1": [[new BadTransformer([])]],
155 "pkg2": [[new BadTransformer([])]] 158 "pkg2": [[new BadTransformer([])]]
156 }); 159 });
157 160
158 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]); 161 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
159 buildShouldFail([ 162 buildShouldFail([
160 equals(BadTransformer.ERROR), 163 isTransformerException(equals(BadTransformer.ERROR)),
161 equals(BadTransformer.ERROR) 164 isTransformerException(equals(BadTransformer.ERROR))
162 ]); 165 ]);
163 }); 166 });
164 167
165 test("an error loading an asset removes the asset from the graph", () { 168 test("an error loading an asset removes the asset from the graph", () {
166 initGraph(["app|foo.txt"]); 169 initGraph(["app|foo.txt"]);
167 170
168 setAssetError("app|foo.txt"); 171 setAssetError("app|foo.txt");
169 updateSources(["app|foo.txt"]); 172 updateSources(["app|foo.txt"]);
170 expectNoAsset("app|foo.txt"); 173 expectNoAsset("app|foo.txt");
171 buildShouldFail([isMockLoadException("app|foo.txt")]); 174 buildShouldFail([
175 isAssetLoadException("app|foo.txt", isMockLoadException("app|foo.txt"))
176 ]);
172 }); 177 });
173 178
174 test("a collision returns the first-produced output", () { 179 test("a collision returns the first-produced output", () {
175 var rewrite1 = new RewriteTransformer("one", "out"); 180 var rewrite1 = new RewriteTransformer("one", "out");
176 var rewrite2 = new RewriteTransformer("two", "out"); 181 var rewrite2 = new RewriteTransformer("two", "out");
177 initGraph({ 182 initGraph({
178 "app|foo.one": "one", 183 "app|foo.one": "one",
179 "app|foo.two": "two" 184 "app|foo.two": "two"
180 }, {"app": [[rewrite1, rewrite2]]}); 185 }, {"app": [[rewrite1, rewrite2]]});
181 186
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // TODO(nweiz): Should this emit a collision error as well? Or should they 278 // TODO(nweiz): Should this emit a collision error as well? Or should they
274 // only be emitted when a file is added or removed? 279 // only be emitted when a file is added or removed?
275 updateSources(["app|foo.three"]); 280 updateSources(["app|foo.three"]);
276 buildShouldSucceed(); 281 buildShouldSucceed();
277 282
278 removeSources(["app|foo.one"]); 283 removeSources(["app|foo.one"]);
279 expectAsset("app|foo.out", "two.out"); 284 expectAsset("app|foo.out", "two.out");
280 buildShouldFail([isAssetCollisionException("app|foo.out")]); 285 buildShouldFail([isAssetCollisionException("app|foo.out")]);
281 }); 286 });
282 } 287 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/utils.dart ('k') | pkg/barback/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698