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

Side by Side Diff: third_party/pkg/barback-0.13.0/test/package_graph/lazy_transformer_test.dart

Issue 291843011: Run pub tests against older versions of barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 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
(Empty)
1 // Copyright (c) 2014, 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.lazy_asset_test;
6
7 import 'package:barback/barback.dart';
8 import 'package:barback/src/utils.dart';
9 import 'package:scheduled_test/scheduled_test.dart';
10
11 import '../utils.dart';
12
13 main() {
14 initConfig();
15 test("requesting a lazy asset should cause it to be generated", () {
16 initGraph(["app|foo.blub"], {"app": [
17 [new LazyRewriteTransformer("blub", "blab")]
18 ]});
19 updateSources(["app|foo.blub"]);
20 expectAsset("app|foo.blab", "foo.blab");
21 buildShouldSucceed();
22 });
23
24 test("calling getAllAssets should cause a lazy asset to be generated", () {
25 var transformer = new LazyRewriteTransformer("blub", "blab");
26 initGraph(["app|foo.blub"], {"app": [[transformer]]});
27 updateSources(["app|foo.blub"]);
28 expectAllAssets(["app|foo.blub", "app|foo.blab"]);
29 buildShouldSucceed();
30 expect(transformer.numRuns, completion(equals(1)));
31 });
32
33 test("requesting a lazy asset multiple times should only cause it to be "
34 "generated once", () {
35 var transformer = new LazyRewriteTransformer("blub", "blab");
36 initGraph(["app|foo.blub"], {"app": [[transformer]]});
37 updateSources(["app|foo.blub"]);
38 expectAsset("app|foo.blab", "foo.blab");
39 expectAsset("app|foo.blab", "foo.blab");
40 expectAsset("app|foo.blab", "foo.blab");
41 buildShouldSucceed();
42 expect(transformer.numRuns, completion(equals(1)));
43 });
44
45 test("a lazy asset can be consumed by a non-lazy transformer", () {
46 initGraph(["app|foo.blub"], {"app": [
47 [new LazyRewriteTransformer("blub", "blab")],
48 [new RewriteTransformer("blab", "blib")]
49 ]});
50 updateSources(["app|foo.blub"]);
51 expectAsset("app|foo.blib", "foo.blab.blib");
52 buildShouldSucceed();
53 });
54
55 test("a lazy asset isn't eagerly compiled", () {
56 var transformer = new LazyRewriteTransformer("blub", "blab");
57 initGraph(["app|foo.blub"], {"app": [[transformer]]});
58 updateSources(["app|foo.blub"]);
59 buildShouldSucceed();
60 expect(transformer.numRuns, completion(equals(0)));
61 });
62
63 test("a lazy asset emitted by a group isn't eagerly compiled", () {
64 var transformer = new LazyRewriteTransformer("blub", "blab");
65 initGraph(["app|foo.blub"], {"app": [
66 [new TransformerGroup([[transformer]])]
67 ]});
68 updateSources(["app|foo.blub"]);
69 buildShouldSucceed();
70 expect(transformer.numRuns, completion(equals(0)));
71 });
72
73 test("a lazy asset piped into a non-lazy transformer is eagerly compiled",
74 () {
75 var transformer = new LazyRewriteTransformer("blub", "blab");
76 initGraph(["app|foo.blub"], {"app": [
77 [transformer],
78 [new RewriteTransformer("blab", "blib")]
79 ]});
80 updateSources(["app|foo.blub"]);
81 buildShouldSucceed();
82 expect(transformer.numRuns, completion(equals(1)));
83 });
84
85 // TODO(nweiz): enable these once DeclaringTransformers forward laziness
86 // properly (issue 16442).
87 //
88 // test("a lazy asset piped into a declaring transformer isn't eagerly "
89 // "compiled", () {
90 // var transformer1 = new LazyRewriteTransformer("blub", "blab");
91 // var transformer2 = new DeclaringRewriteTransformer("blab", "blib");
92 // initGraph(["app|foo.blub"], {"app": [
93 // [transformer1], [transformer2]
94 // ]});
95 // updateSources(["app|foo.blub"]);
96 // buildShouldSucceed();
97 // expect(transformer1.numRuns, completion(equals(0)));
98 // expect(transformer2.numRuns, completion(equals(0)));
99 // });
100 //
101 // test("a lazy asset piped into a declaring transformer is compiled "
102 // "on-demand", () {
103 // initGraph(["app|foo.blub"], {"app": [
104 // [new LazyRewriteTransformer("blub", "blab")],
105 // [new DeclaringRewriteTransformer("blab", "blib")]
106 // ]});
107 // updateSources(["app|foo.blub"]);
108 // expectAsset("app|foo.blib", "foo.blab.blib");
109 // buildShouldSucceed();
110 // });
111
112 test("a lazy asset works as a cross-package input", () {
113 initGraph({
114 "pkg1|foo.blub": "foo",
115 "pkg2|a.txt": "pkg1|foo.blab"
116 }, {"pkg1": [
117 [new LazyRewriteTransformer("blub", "blab")],
118 ], "pkg2": [
119 [new ManyToOneTransformer("txt")]
120 ]});
121
122 updateSources(["pkg1|foo.blub", "pkg2|a.txt"]);
123 expectAsset("pkg2|a.out", "foo.blab");
124 buildShouldSucceed();
125 });
126
127 test("a lazy transformer can consume secondary inputs lazily", () {
128 initGraph({
129 "app|a.inc": "a",
130 "app|a.txt": "a.inc"
131 }, {"app": [
132 [new LazyManyToOneTransformer("txt")]
133 ]});
134
135 updateSources(["app|a.inc", "app|a.txt"]);
136 expectAsset("app|a.out", "a");
137 buildShouldSucceed();
138 });
139
140 test("once a lazy transformer is materialized, it runs eagerly afterwards",
141 () {
142 var transformer = new LazyRewriteTransformer("blub", "blab");
143 initGraph(["app|foo.blub"], {"app": [[transformer]]});
144
145 updateSources(["app|foo.blub"]);
146 buildShouldSucceed();
147
148 // Request the asset once to force it to be materialized.
149 expectAsset("app|foo.blab", "foo.blab");
150 buildShouldSucceed();
151
152 updateSources(["app|foo.blub"]);
153 buildShouldSucceed();
154
155 expect(transformer.numRuns, completion(equals(2)));
156 });
157
158 test("an error emitted in a lazy transformer's declareOutputs method is "
159 "caught and reported", () {
160 initGraph(["app|foo.txt"], {"app": [
161 [new LazyBadTransformer("app|foo.out")]
162 ]});
163
164 updateSources(["app|foo.txt"]);
165 buildShouldFail([isTransformerException(equals(LazyBadTransformer.ERROR))]);
166 });
167
168 test("an error emitted in a lazy transformer's declareOuputs method prevents "
169 "it from being materialized", () {
170 var transformer = new LazyBadTransformer("app|foo.out");
171 initGraph(["app|foo.txt"], {"app": [[transformer]]});
172
173 updateSources(["app|foo.txt"]);
174 expectNoAsset("app|foo.out");
175 buildShouldFail([isTransformerException(equals(LazyBadTransformer.ERROR))]);
176 expect(transformer.numRuns, completion(equals(0)));
177 });
178
179 test("a lazy transformer passes through inputs it doesn't apply to", () {
180 initGraph(["app|foo.txt"], {"app": [
181 [new LazyRewriteTransformer("blub", "blab")]
182 ]});
183
184 updateSources(["app|foo.txt"]);
185 expectAsset("app|foo.txt");
186 buildShouldSucceed();
187 });
188
189 test("a lazy transformer passes through inputs it doesn't overwrite", () {
190 initGraph(["app|foo.txt"], {"app": [
191 [new LazyRewriteTransformer("txt", "out")]
192 ]});
193
194 updateSources(["app|foo.txt"]);
195 expectAsset("app|foo.txt");
196 buildShouldSucceed();
197 });
198
199 test("a lazy transformer doesn't pass through inputs it overwrites", () {
200 initGraph(["app|foo.txt"], {"app": [
201 [new LazyRewriteTransformer("txt", "txt")]
202 ]});
203
204 updateSources(["app|foo.txt"]);
205 expectAsset("app|foo.txt", "foo.txt");
206 buildShouldSucceed();
207 });
208
209 test("a lazy transformer doesn't pass through inputs it consumes", () {
210 initGraph(["app|foo.txt"], {"app": [
211 [new LazyRewriteTransformer("txt", "out")..consumePrimary = true]
212 ]});
213
214 updateSources(["app|foo.txt"]);
215 expectNoAsset("app|foo.txt");
216 buildShouldSucceed();
217 });
218
219 test("a lazy transformer that doesn't apply does nothing when forced", () {
220 initGraph(["app|foo.txt"], {"app": [
221 [new LazyRewriteTransformer("blub", "blab")]
222 ]});
223
224 updateSources(["app|foo.txt"]);
225 expectNoAsset("app|foo.blab");
226
227 // Getting all assets will force every lazy transformer. This shouldn't
228 // cause the rewrite to apply, because foo.txt isn't primary.
229 expectAllAssets(["app|foo.txt"]);
230 buildShouldSucceed();
231 });
232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698