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

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

Issue 21275003: Move barback to a more event-based model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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:scheduled_test/scheduled_test.dart'; 10 import 'package:scheduled_test/scheduled_test.dart';
11 11
12 import '../utils.dart'; 12 import '../utils.dart';
13 13
14 main() { 14 main() {
15 initConfig(); 15 initConfig();
16 16
17 test("errors if two transformers output the same file", () { 17 test("errors if two transformers output the same file", () {
18 initGraph(["app|foo.a"], {"app": [ 18 initGraph(["app|foo.a"], {"app": [
19 [ 19 [
20 new RewriteTransformer("a", "b"), 20 new RewriteTransformer("a", "b"),
21 new RewriteTransformer("a", "b") 21 new RewriteTransformer("a", "b")
22 ] 22 ]
23 ]}); 23 ]});
24 updateSources(["app|foo.a"]); 24 updateSources(["app|foo.a"]);
25 25
26 buildShouldFail([isAssetCollisionException("app|foo.b")]); 26 buildShouldFail([isAssetCollisionException("app|foo.b")]);
27 }); 27 });
28 28
29 test("errors if a new transformer outputs the same file as an old "
30 "transformer", () {
31 initGraph(["app|foo.a", "app|foo.b"], {"app": [
32 [
33 new RewriteTransformer("a", "c"),
34 new RewriteTransformer("b", "c")
35 ]
36 ]});
37 updateSources(["app|foo.a"]);
38 expectAsset("app|foo.c", "foo.c");
39 buildShouldSucceed();
40
41 schedule(() => updateSources(["app|foo.b"]));
42 buildShouldFail([isAssetCollisionException("app|foo.c")]);
43 });
44
29 test("does not report asset not found errors in results", () { 45 test("does not report asset not found errors in results", () {
30 initGraph(["app|bar.txt"]); 46 initGraph(["app|bar.txt"]);
31 47
32 // Trigger a build. 48 // Trigger a build.
33 updateSources(["app|bar.txt"]); 49 updateSources(["app|bar.txt"]);
34 50
35 expectNoAsset("app|foo.txt"); 51 expectNoAsset("app|foo.txt");
36 buildShouldSucceed(); 52 buildShouldSucceed();
37 }); 53 });
38 54
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 116
101 schedule(() { 117 schedule(() {
102 updateSources(["app|foo.txt"]); 118 updateSources(["app|foo.txt"]);
103 }); 119 });
104 120
105 expectNoAsset("app|foo.out"); 121 expectNoAsset("app|foo.out");
106 122
107 buildShouldFail([equals(BadTransformer.ERROR)]); 123 buildShouldFail([equals(BadTransformer.ERROR)]);
108 }); 124 });
109 125
110 // TODO(rnystrom): Is this the behavior we expect? If a transformer fails 126 test("doesn't yield a source if a transform fails on it", () {
111 // to transform a file, should we just skip past it to the source?
112 test("yields a source if a transform fails on it", () {
113 initGraph(["app|foo.txt"], {"app": [ 127 initGraph(["app|foo.txt"], {"app": [
114 [new BadTransformer(["app|foo.txt"])] 128 [new BadTransformer(["app|foo.txt"])]
115 ]}); 129 ]});
116 130
117 schedule(() { 131 schedule(() {
118 updateSources(["app|foo.txt"]); 132 updateSources(["app|foo.txt"]);
119 }); 133 });
120 134
121 expectAsset("app|foo.txt"); 135 expectNoAsset("app|foo.txt");
122 }); 136 });
123 137
124 test("catches errors even if nothing is waiting for process results", () { 138 test("catches errors even if nothing is waiting for process results", () {
125 initGraph(["app|foo.txt"], {"app": [[new BadTransformer([])]]}); 139 initGraph(["app|foo.txt"], {"app": [[new BadTransformer([])]]});
126 140
127 schedule(() { 141 schedule(() {
128 updateSources(["app|foo.txt"]); 142 updateSources(["app|foo.txt"]);
129 }); 143 });
130 144
131 // Note: No asset requests here. 145 // Note: No asset requests here.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 179
166 schedule(() { 180 schedule(() {
167 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]); 181 updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
168 }); 182 });
169 183
170 buildShouldFail([ 184 buildShouldFail([
171 equals(BadTransformer.ERROR), 185 equals(BadTransformer.ERROR),
172 equals(BadTransformer.ERROR) 186 equals(BadTransformer.ERROR)
173 ]); 187 ]);
174 }); 188 });
189
190 test("an error loading an asset removes the asset from the graph", () {
191 initGraph(["app|foo.txt"]);
192
193 setAssetError("app|foo.txt");
194 schedule(() => updateSources(["app|foo.txt"]));
195 expectNoAsset("app|foo.txt");
196 buildShouldFail([isMockLoadException("app|foo.txt")]);
197 });
175 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698