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

Side by Side Diff: sdk/lib/_internal/pub/test/transformer/cache_test.dart

Issue 651993006: "pub get" doesn't choke on previously-cached unknown transformers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 d.file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.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 pub_tests; 5 library pub_tests;
6 6
7 import 'package:scheduled_test/scheduled_stream.dart';
7 import 'package:scheduled_test/scheduled_test.dart'; 8 import 'package:scheduled_test/scheduled_test.dart';
8 9
9 import '../descriptor.dart' as d; 10 import '../descriptor.dart' as d;
10 import '../test_pub.dart'; 11 import '../test_pub.dart';
11 import '../serve/utils.dart'; 12 import '../serve/utils.dart';
12 13
13 const REPLACE_FROM_LIBRARY_TRANSFORMER = """ 14 const REPLACE_FROM_LIBRARY_TRANSFORMER = """
14 import 'dart:async'; 15 import 'dart:async';
15 16
16 import 'package:barback/barback.dart'; 17 import 'package:barback/barback.dart';
(...skipping 29 matching lines...) Expand all
46 ]) 47 ])
47 ]); 48 ]);
48 49
49 builder.serve("bar", "1.2.3", 50 builder.serve("bar", "1.2.3",
50 deps: {'barback': 'any'}, 51 deps: {'barback': 'any'},
51 contents: [ 52 contents: [
52 d.dir("lib", [ 53 d.dir("lib", [
53 d.file("transformer.dart", replaceTransformer("Goodbye", "See ya")) 54 d.file("transformer.dart", replaceTransformer("Goodbye", "See ya"))
54 ]) 55 ])
55 ]); 56 ]);
57
58 builder.serve("baz", "1.2.3");
56 }); 59 });
57 60
58 d.dir(appPath, [ 61 d.dir(appPath, [
59 d.pubspec({ 62 d.pubspec({
60 "name": "myapp", 63 "name": "myapp",
61 "dependencies": { 64 "dependencies": {
62 "foo": "1.2.3", 65 "foo": "1.2.3",
63 "bar": "1.2.3" 66 "bar": "1.2.3"
64 }, 67 },
65 "transformers": ["foo"] 68 "transformers": ["foo"]
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 "transformers": ["foo"] 262 "transformers": ["foo"]
260 }) 263 })
261 ]).create(); 264 ]).create();
262 265
263 pubUpgrade(); 266 pubUpgrade();
264 267
265 process = pubRun(args: ['myapp']); 268 process = pubRun(args: ['myapp']);
266 process.stdout.expect("See ya!"); 269 process.stdout.expect("See ya!");
267 process.shouldExit(); 270 process.shouldExit();
268 }); 271 });
272
273 // Issue 21298.
274 solo_integration("doesn't recache when a transformer is removed", () {
275 setUp();
276
277 d.dir(appPath, [
278 d.pubspec({
279 "name": "myapp",
280 "dependencies": {
281 "foo": "1.2.3",
282 "bar": "1.2.3"
283 },
284 "transformers": ["foo", "bar"]
285 }),
286 d.dir("bin", [
287 d.file("myapp.dart", "main() => print('Hello!');")
288 ])
289 ]).create();
290
291 var process = pubRun(args: ['myapp']);
292 process.stdout.expect("See ya!");
293 process.shouldExit();
294
295 d.dir(appPath, [
296 d.pubspec({
297 "name": "myapp",
298 "dependencies": {
299 "foo": "1.2.3",
300 // Add a new dependency to trigger another "pub get". This works
301 // around issue 20498.
302 "baz": "1.2.3"
303 },
304 "transformers": ["foo"]
305 }),
306 d.dir("bin", [
307 d.file("myapp.dart", "main() => print('Hello!');")
308 ])
309 ]).create();
310
311 process = pubRun(args: ['myapp']);
312 process.stdout.expect("Your pubspec has changed, so we need to update your l ockfile:");
Alan Knight 2014/10/13 23:06:42 80 cols
nweiz 2014/10/13 23:09:08 Done.
313 process.stdout.expect(consumeThrough("Goodbye!"));
314 process.shouldExit();
315
316 // "bar" should still be in the manifest, since there's no reason to
317 // recompile the cache.
318 d.dir(appPath, [
319 d.dir(".pub/transformers", [
320 d.file("manifest.txt", "0.1.2+3\nbar,foo"),
321 d.matcherFile("transformers.snapshot", isNot(isEmpty))
322 ])
323 ]).validate();
324 });
269 } 325 }
270 326
271 String replaceTransformer(String input, String output) { 327 String replaceTransformer(String input, String output) {
272 return """ 328 return """
273 import 'dart:async'; 329 import 'dart:async';
274 330
275 import 'package:barback/barback.dart'; 331 import 'package:barback/barback.dart';
276 332
277 class ReplaceTransformer extends Transformer { 333 class ReplaceTransformer extends Transformer {
278 ReplaceTransformer.asPlugin(); 334 ReplaceTransformer.asPlugin();
279 335
280 String get allowedExtensions => '.dart'; 336 String get allowedExtensions => '.dart';
281 337
282 Future apply(Transform transform) { 338 Future apply(Transform transform) {
283 return transform.primaryInput.readAsString().then((contents) { 339 return transform.primaryInput.readAsString().then((contents) {
284 transform.addOutput(new Asset.fromString( 340 transform.addOutput(new Asset.fromString(
285 transform.primaryInput.id, 341 transform.primaryInput.id,
286 contents.replaceAll("$input", "$output"))); 342 contents.replaceAll("$input", "$output")));
287 }); 343 });
288 } 344 }
289 } 345 }
290 """; 346 """;
291 } 347 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698