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

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: 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 "app|a.txt": "a.inc" 157 "app|a.txt": "a.inc"
158 }, {"app": [ 158 }, {"app": [
159 [new LazyManyToOneTransformer("txt")] 159 [new LazyManyToOneTransformer("txt")]
160 ]}); 160 ]});
161 161
162 updateSources(["app|a.inc", "app|a.txt"]); 162 updateSources(["app|a.inc", "app|a.txt"]);
163 expectAsset("app|a.out", "a"); 163 expectAsset("app|a.out", "a");
164 buildShouldSucceed(); 164 buildShouldSucceed();
165 }); 165 });
166 166
167 test("once a lazy transformer is materialized, it runs eagerly afterwards", 167 test("after being materialized a lazy transformer is still lazy", () {
168 () {
169 var transformer = new LazyRewriteTransformer("blub", "blab"); 168 var transformer = new LazyRewriteTransformer("blub", "blab");
170 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 169 initGraph(["app|foo.blub"], {"app": [[transformer]]});
171 170
172 updateSources(["app|foo.blub"]); 171 updateSources(["app|foo.blub"]);
173 buildShouldSucceed(); 172 buildShouldSucceed();
174 173
175 // Request the asset once to force it to be materialized. 174 // Request the asset once to force it to be materialized.
176 expectAsset("app|foo.blab", "foo.blab"); 175 expectAsset("app|foo.blab", "foo.blab");
177 buildShouldSucceed(); 176 buildShouldSucceed();
178 177
179 updateSources(["app|foo.blub"]); 178 updateSources(["app|foo.blub"]);
180 buildShouldSucceed(); 179 buildShouldSucceed();
181 180
182 expect(transformer.numRuns, completion(equals(2))); 181 expect(transformer.numRuns, completion(equals(1)));
182 });
183
184 test("after being materialized a lazy transformer can be materialized again",
185 () {
186 var transformer = new LazyRewriteTransformer("blub", "blab");
187 initGraph(["app|foo.blub"], {"app": [[transformer]]});
188
189 updateSources(["app|foo.blub"]);
190 buildShouldSucceed();
191
192 // Request the asset once to force it to be materialized.
193 expectAsset("app|foo.blab", "foo.blab");
194 buildShouldSucceed();
195
196 modifyAsset("app|foo.blub", "bar");
197 updateSources(["app|foo.blub"]);
198 expectAsset("app|foo.blab", "bar.blab");
199 buildShouldSucceed();
183 }); 200 });
184 201
185 test("an error emitted in a lazy transformer's declareOutputs method is " 202 test("an error emitted in a lazy transformer's declareOutputs method is "
186 "caught and reported", () { 203 "caught and reported", () {
187 initGraph(["app|foo.txt"], {"app": [ 204 initGraph(["app|foo.txt"], {"app": [
188 [new LazyBadTransformer("app|foo.out")] 205 [new LazyBadTransformer("app|foo.out")]
189 ]}); 206 ]});
190 207
191 updateSources(["app|foo.txt"]); 208 updateSources(["app|foo.txt"]);
192 buildShouldFail([isTransformerException(equals(LazyBadTransformer.ERROR))]); 209 buildShouldFail([isTransformerException(equals(LazyBadTransformer.ERROR))]);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 resumeProvider(); 290 resumeProvider();
274 expectAsset("app|foo.txt", "foo"); 291 expectAsset("app|foo.txt", "foo");
275 buildShouldSucceed(); 292 buildShouldSucceed();
276 293
277 modifyAsset("app|foo.txt", "bar"); 294 modifyAsset("app|foo.txt", "bar");
278 updateSources(["app|foo.txt"]); 295 updateSources(["app|foo.txt"]);
279 expectAsset("app|foo.txt", "bar"); 296 expectAsset("app|foo.txt", "bar");
280 buildShouldSucceed(); 297 buildShouldSucceed();
281 }); 298 });
282 } 299 }
OLDNEW
« pkg/barback/lib/src/transform_node.dart ('K') | « pkg/barback/lib/src/transform_node.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698