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

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

Issue 233843002: Don't make lazy transformers eager when an asset is requested. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review + disabling test Created 6 years, 8 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) 2014, the Dart project authors. Please see the AUTHORS file 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 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.lazy_asset_test; 5 library barback.test.package_graph.lazy_asset_test;
6 6
7 import 'package:barback/barback.dart'; 7 import 'package:barback/barback.dart';
8 import 'package:barback/src/utils.dart'; 8 import 'package:barback/src/utils.dart';
9 import 'package:scheduled_test/scheduled_test.dart'; 9 import 'package:scheduled_test/scheduled_test.dart';
10 10
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 [new LazyRewriteTransformer("one", "two")], 129 [new LazyRewriteTransformer("one", "two")],
130 [new DeclaringRewriteTransformer("two", "three")], 130 [new DeclaringRewriteTransformer("two", "three")],
131 [new DeclaringRewriteTransformer("three", "four")], 131 [new DeclaringRewriteTransformer("three", "four")],
132 [new DeclaringRewriteTransformer("four", "five")] 132 [new DeclaringRewriteTransformer("four", "five")]
133 ]}); 133 ]});
134 updateSources(["app|foo.one"]); 134 updateSources(["app|foo.one"]);
135 expectAsset("app|foo.five", "foo.two.three.four.five"); 135 expectAsset("app|foo.five", "foo.two.three.four.five");
136 buildShouldSucceed(); 136 buildShouldSucceed();
137 }); 137 });
138 138
139 test("a lazy transformer followed by a non-lazy transformer is re-run "
140 "eagerly", () {
141 var rewrite = new LazyRewriteTransformer("one", "two");
142 initGraph(["app|foo.one"], {"app": [
143 [rewrite],
144 [new RewriteTransformer("two", "three")]
145 ]});
146
147 updateSources(["app|foo.one"]);
148 expectAsset("app|foo.three", "foo.two.three");
149 buildShouldSucceed();
150
151 updateSources(["app|foo.one"]);
152 buildShouldSucceed();
153
154 expect(rewrite.numRuns, completion(equals(2)));
155 });
156
157 test("a lazy transformer followed by a declaring transformer isn't re-run "
158 "eagerly", () {
159 var rewrite = new LazyRewriteTransformer("one", "two");
160 initGraph(["app|foo.one"], {"app": [
161 [rewrite],
162 [new DeclaringRewriteTransformer("two", "three")]
163 ]});
164
165 updateSources(["app|foo.one"]);
166 expectAsset("app|foo.three", "foo.two.three");
167 buildShouldSucceed();
168
169 updateSources(["app|foo.one"]);
170 buildShouldSucceed();
171
172 expect(rewrite.numRuns, completion(equals(1)));
173 });
174
175 test("a declaring transformer added after a materialized lazy transformer "
176 "is still deferred", () {
177 var lazy = new LazyRewriteTransformer("one", "two");
178 var declaring = new DeclaringRewriteTransformer("two", "three");
179 initGraph(["app|foo.one"], {"app": [[lazy]]});
180
181 updateSources(["app|foo.one"]);
182 expectAsset("app|foo.two", "foo.two");
183 buildShouldSucceed();
184
185 updateTransformers("app", [[lazy], [declaring]]);
186 expectAsset("app|foo.three", "foo.two.three");
187 buildShouldSucceed();
188
189 updateSources(["app|foo.one"]);
190 buildShouldSucceed();
191
192 expect(lazy.numRuns, completion(equals(1)));
193 expect(declaring.numRuns, completion(equals(1)));
194 });
195
139 test("a lazy asset works as a cross-package input", () { 196 test("a lazy asset works as a cross-package input", () {
140 initGraph({ 197 initGraph({
141 "pkg1|foo.blub": "foo", 198 "pkg1|foo.blub": "foo",
142 "pkg2|a.txt": "pkg1|foo.blab" 199 "pkg2|a.txt": "pkg1|foo.blab"
143 }, {"pkg1": [ 200 }, {"pkg1": [
144 [new LazyRewriteTransformer("blub", "blab")], 201 [new LazyRewriteTransformer("blub", "blab")],
145 ], "pkg2": [ 202 ], "pkg2": [
146 [new ManyToOneTransformer("txt")] 203 [new ManyToOneTransformer("txt")]
147 ]}); 204 ]});
148 205
149 updateSources(["pkg1|foo.blub", "pkg2|a.txt"]); 206 updateSources(["pkg1|foo.blub", "pkg2|a.txt"]);
150 expectAsset("pkg2|a.out", "foo.blab"); 207 expectAsset("pkg2|a.out", "foo.blab");
151 buildShouldSucceed(); 208 buildShouldSucceed();
152 }); 209 });
153 210
154 test("a lazy transformer can consume secondary inputs lazily", () { 211 test("a lazy transformer can consume secondary inputs lazily", () {
155 initGraph({ 212 initGraph({
156 "app|a.inc": "a", 213 "app|a.inc": "a",
157 "app|a.txt": "a.inc" 214 "app|a.txt": "a.inc"
158 }, {"app": [ 215 }, {"app": [
159 [new LazyManyToOneTransformer("txt")] 216 [new LazyManyToOneTransformer("txt")]
160 ]}); 217 ]});
161 218
162 updateSources(["app|a.inc", "app|a.txt"]); 219 updateSources(["app|a.inc", "app|a.txt"]);
163 expectAsset("app|a.out", "a"); 220 expectAsset("app|a.out", "a");
164 buildShouldSucceed(); 221 buildShouldSucceed();
165 }); 222 });
166 223
167 test("once a lazy transformer is materialized, it runs eagerly afterwards", 224 test("after being materialized a lazy transformer is still lazy", () {
168 () {
169 var transformer = new LazyRewriteTransformer("blub", "blab"); 225 var transformer = new LazyRewriteTransformer("blub", "blab");
170 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 226 initGraph(["app|foo.blub"], {"app": [[transformer]]});
171 227
172 updateSources(["app|foo.blub"]); 228 updateSources(["app|foo.blub"]);
173 buildShouldSucceed(); 229 buildShouldSucceed();
174 230
175 // Request the asset once to force it to be materialized. 231 // Request the asset once to force it to be materialized.
176 expectAsset("app|foo.blab", "foo.blab"); 232 expectAsset("app|foo.blab", "foo.blab");
177 buildShouldSucceed(); 233 buildShouldSucceed();
178 234
179 updateSources(["app|foo.blub"]); 235 updateSources(["app|foo.blub"]);
180 buildShouldSucceed(); 236 buildShouldSucceed();
181 237
182 expect(transformer.numRuns, completion(equals(2))); 238 expect(transformer.numRuns, completion(equals(1)));
239 });
240
241 test("after being materialized a lazy transformer can be materialized again",
242 () {
243 var transformer = new LazyRewriteTransformer("blub", "blab");
244 initGraph(["app|foo.blub"], {"app": [[transformer]]});
245
246 updateSources(["app|foo.blub"]);
247 buildShouldSucceed();
248
249 // Request the asset once to force it to be materialized.
250 expectAsset("app|foo.blab", "foo.blab");
251 buildShouldSucceed();
252
253 modifyAsset("app|foo.blub", "bar");
254 updateSources(["app|foo.blub"]);
255 expectAsset("app|foo.blab", "bar.blab");
256 buildShouldSucceed();
183 }); 257 });
184 258
185 test("an error emitted in a lazy transformer's declareOutputs method is " 259 test("an error emitted in a lazy transformer's declareOutputs method is "
186 "caught and reported", () { 260 "caught and reported", () {
187 initGraph(["app|foo.txt"], {"app": [ 261 initGraph(["app|foo.txt"], {"app": [
188 [new LazyBadTransformer("app|foo.out")] 262 [new LazyBadTransformer("app|foo.out")]
189 ]}); 263 ]});
190 264
191 updateSources(["app|foo.txt"]); 265 updateSources(["app|foo.txt"]);
192 buildShouldFail([isTransformerException(equals(LazyBadTransformer.ERROR))]); 266 buildShouldFail([isTransformerException(equals(LazyBadTransformer.ERROR))]);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 resumeProvider(); 347 resumeProvider();
274 expectAsset("app|foo.txt", "foo"); 348 expectAsset("app|foo.txt", "foo");
275 buildShouldSucceed(); 349 buildShouldSucceed();
276 350
277 modifyAsset("app|foo.txt", "bar"); 351 modifyAsset("app|foo.txt", "bar");
278 updateSources(["app|foo.txt"]); 352 updateSources(["app|foo.txt"]);
279 expectAsset("app|foo.txt", "bar"); 353 expectAsset("app|foo.txt", "bar");
280 buildShouldSucceed(); 354 buildShouldSucceed();
281 }); 355 });
282 } 356 }
OLDNEW
« no previous file with comments | « pkg/barback/test/package_graph/declaring_transformer_test.dart ('k') | pkg/barback/test/transformer/declaring_rewrite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698