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

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

Issue 18178021: Split AssetGraph.results into two streams. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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.asset_graph.source_test; 5 library barback.test.asset_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/asset_graph.dart'; 10 import 'package:barback/src/asset_graph.dart';
11 import 'package:scheduled_test/scheduled_test.dart'; 11 import 'package:scheduled_test/scheduled_test.dart';
12 12
13 import '../utils.dart'; 13 import '../utils.dart';
14 14
15 main() { 15 main() {
16 initConfig(); 16 initConfig();
17 17
18 test("errors if two transformers output the same file", () { 18 test("errors if two transformers output the same file", () {
19 initGraph(["app|foo.a"], [ 19 initGraph(["app|foo.a"], [
20 [ 20 [
21 new RewriteTransformer("a", "b"), 21 new RewriteTransformer("a", "b"),
22 new RewriteTransformer("a", "b") 22 new RewriteTransformer("a", "b")
23 ] 23 ]
24 ]); 24 ]);
25 updateSources(["app|foo.a"]); 25 updateSources(["app|foo.a"]);
26 26
27 expectCollision("app|foo.b"); 27 buildShouldFail([isAssetCollisionException("app|foo.b")]);
28 }); 28 });
29 29
30 test("does not report asset not found errors in results", () { 30 test("does not report asset not found errors in results", () {
31 initGraph(); 31 initGraph();
32 32
33 expectNoAsset("app|foo.txt"); 33 expectNoAsset("app|foo.txt");
34 buildShouldSucceed(); 34 buildShouldSucceed();
35 }); 35 });
36 36
37 test("reports an error for an unprovided source", () { 37 test("reports an error for an unprovided source", () {
38 initGraph(); 38 initGraph();
39 updateSources(["app|unknown.txt"]); 39 updateSources(["app|unknown.txt"]);
40 40
41 buildShouldFail((error) { 41 buildShouldFail([isAssetNotFoundException("app|unknown.txt")]);
42 expect(error, new isInstanceOf<AssetNotFoundException>());
43 expect(error.id, equals(new AssetId.parse("app|unknown.txt")));
44 });
45 }); 42 });
46 43
47 test("reports missing input errors in results", () { 44 test("reports missing input errors in results", () {
48 initGraph({"app|a.txt": "a.inc"}, [ 45 initGraph({"app|a.txt": "a.inc"}, [
49 [new ManyToOneTransformer("txt")] 46 [new ManyToOneTransformer("txt")]
50 ]); 47 ]);
51 48
52 buildShouldFail((error) { 49 buildShouldFail([isMissingInputException("app|a.inc")]);
53 expect(error, new isInstanceOf<MissingInputException>());
54 expect(error.id, equals(new AssetId.parse("app|a.inc")));
55 });
56 50
57 updateSources(["app|a.txt"]); 51 updateSources(["app|a.txt"]);
58 52
59 expectNoAsset("app|a.out"); 53 expectNoAsset("app|a.out");
60 }); 54 });
61 55
62 test("fails if a non-primary input is removed", () { 56 test("fails if a non-primary input is removed", () {
63 initGraph({ 57 initGraph({
64 "app|a.txt": "a.inc,b.inc,c.inc", 58 "app|a.txt": "a.inc,b.inc,c.inc",
65 "app|a.inc": "a", 59 "app|a.inc": "a",
66 "app|b.inc": "b", 60 "app|b.inc": "b",
67 "app|c.inc": "c" 61 "app|c.inc": "c"
68 }, [ 62 }, [
69 [new ManyToOneTransformer("txt")] 63 [new ManyToOneTransformer("txt")]
70 ]); 64 ]);
71 65
72 updateSources(["app|a.txt", "app|a.inc", "app|b.inc", "app|c.inc"]); 66 updateSources(["app|a.txt", "app|a.inc", "app|b.inc", "app|c.inc"]);
73 expectAsset("app|a.out", "abc"); 67 expectAsset("app|a.out", "abc");
74 buildShouldSucceed(); 68 buildShouldSucceed();
75 69
76 schedule(() { 70 schedule(() {
77 removeSources(["app|b.inc"]); 71 removeSources(["app|b.inc"]);
78 }); 72 });
79 73
80 buildShouldFail((error) { 74 buildShouldFail([isMissingInputException("app|b.inc")]);
81 expect(error, new isInstanceOf<MissingInputException>());
82 expect(error.id, equals(new AssetId.parse("app|b.inc")));
83 });
84 expectNoAsset("app|a.out"); 75 expectNoAsset("app|a.out");
85 }); 76 });
86 77
87 test("catches transformer exceptions and reports them", () { 78 test("catches transformer exceptions and reports them", () {
88 initGraph(["app|foo.txt"], [ 79 initGraph(["app|foo.txt"], [
89 [new BadTransformer(["app|foo.out"])] 80 [new BadTransformer(["app|foo.out"])]
90 ]); 81 ]);
91 82
92 schedule(() { 83 schedule(() {
93 updateSources(["app|foo.txt"]); 84 updateSources(["app|foo.txt"]);
94 }); 85 });
95 86
96 expectNoAsset("app|foo.out"); 87 expectNoAsset("app|foo.out");
97 88
98 buildShouldFail((error) { 89 buildShouldFail([equals(BadTransformer.ERROR)]);
99 expect(error, equals(BadTransformer.ERROR));
100 });
101 }); 90 });
102 91
103 // TODO(rnystrom): Is this the behavior we expect? If a transformer fails 92 // TODO(rnystrom): Is this the behavior we expect? If a transformer fails
104 // to transform a file, should we just skip past it to the source? 93 // to transform a file, should we just skip past it to the source?
105 test("yields a source if a transform fails on it", () { 94 test("yields a source if a transform fails on it", () {
106 initGraph(["app|foo.txt"], [ 95 initGraph(["app|foo.txt"], [
107 [new BadTransformer(["app|foo.txt"])] 96 [new BadTransformer(["app|foo.txt"])]
108 ]); 97 ]);
109 98
110 schedule(() { 99 schedule(() {
111 updateSources(["app|foo.txt"]); 100 updateSources(["app|foo.txt"]);
112 }); 101 });
113 102
114 expectAsset("app|foo.txt"); 103 expectAsset("app|foo.txt");
115 }); 104 });
116 105
117 test("catches errors even if nothing is waiting for process results", () { 106 test("catches errors even if nothing is waiting for process results", () {
118 initGraph(["app|foo.txt"], [[new BadTransformer([])]]); 107 initGraph(["app|foo.txt"], [[new BadTransformer([])]]);
119 108
120 schedule(() { 109 schedule(() {
121 updateSources(["app|foo.txt"]); 110 updateSources(["app|foo.txt"]);
122 }); 111 });
123 112
124 // Note: No asset requests here. 113 // Note: No asset requests here.
125 114
126 buildShouldFail((error) { 115 buildShouldFail([equals(BadTransformer.ERROR)]);
127 expect(error, equals(BadTransformer.ERROR));
128 });
129 }); 116 });
130 117
131 test("discards outputs from failed transforms", () { 118 test("discards outputs from failed transforms", () {
132 initGraph(["app|foo.txt"], [ 119 initGraph(["app|foo.txt"], [
133 [new BadTransformer(["a.out", "b.out"])] 120 [new BadTransformer(["a.out", "b.out"])]
134 ]); 121 ]);
135 122
136 schedule(() { 123 schedule(() {
137 updateSources(["app|foo.txt"]); 124 updateSources(["app|foo.txt"]);
138 }); 125 });
139 126
140 expectNoAsset("app|a.out"); 127 expectNoAsset("app|a.out");
141 }); 128 });
142 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698