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

Side by Side Diff: test/get/cache_transformed_dependency_test.dart

Issue 1809993003: Add a --no-precompile flag. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 9 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
« no previous file with comments | « lib/src/entrypoint.dart ('k') | test/snapshot/no_precompile_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'package:path/path.dart' as p;
5 import 'package:scheduled_test/scheduled_test.dart'; 6 import 'package:scheduled_test/scheduled_test.dart';
6 7
7 import '../descriptor.dart' as d; 8 import '../descriptor.dart' as d;
8 import '../test_pub.dart'; 9 import '../test_pub.dart';
9 import '../serve/utils.dart'; 10 import '../serve/utils.dart';
10 11
11 const MODE_TRANSFORMER = """ 12 const MODE_TRANSFORMER = """
12 import 'dart:async'; 13 import 'dart:async';
13 14
14 import 'package:barback/barback.dart'; 15 import 'package:barback/barback.dart';
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 411
411 // Upgrade to the new version of foo. 412 // Upgrade to the new version of foo.
412 d.appDir({"foo": "1.2.4"}).create(); 413 d.appDir({"foo": "1.2.4"}).create();
413 414
414 pubGet(output: isNot(contains("Precompiled foo."))); 415 pubGet(output: isNot(contains("Precompiled foo.")));
415 416
416 d.dir(appPath, [ 417 d.dir(appPath, [
417 d.nothing(".pub/deps/debug/foo") 418 d.nothing(".pub/deps/debug/foo")
418 ]).validate(); 419 ]).validate();
419 }); 420 });
421
422 group("with --no-precompile", () {
423 integration("doesn't cache a transformed dependency", () {
424 servePackages((builder) {
425 builder.serveRealPackage('barback');
426
427 builder.serve("foo", "1.2.3",
428 deps: {'barback': 'any'},
429 pubspec: {'transformers': ['foo']},
430 contents: [
431 d.dir("lib", [
432 d.file("transformer.dart", replaceTransformer("Hello", "Goodbye")),
433 d.file("foo.dart", "final message = 'Hello!';")
434 ])
435 ]);
436 });
437
438 d.appDir({"foo": "1.2.3"}).create();
439
440 pubGet(args: ["--no-precompile"], output: isNot(contains("Precompiled")));
441
442 d.nothing(p.join(appPath, ".pub")).validate();
443 });
444
445 integration("deletes the cache when the dependency is updated", () {
446 servePackages((builder) {
447 builder.serveRealPackage('barback');
448
449 builder.serve("foo", "1.2.3",
450 deps: {'barback': 'any'},
451 pubspec: {'transformers': ['foo']},
452 contents: [
453 d.dir("lib", [
454 d.file("transformer.dart", replaceTransformer("Hello", "Goodbye")),
455 d.file("foo.dart", "final message = 'Hello!';")
456 ])
457 ]);
458
459 builder.serve("foo", "1.2.4",
460 deps: {'barback': 'any'},
461 pubspec: {'transformers': ['foo']},
462 contents: [
463 d.dir("lib", [
464 d.file("transformer.dart", replaceTransformer("Hello", "See ya")),
465 d.file("foo.dart", "final message = 'Hello!';")
466 ])
467 ]);
468 });
469
470 d.appDir({"foo": "1.2.3"}).create();
471
472 pubGet(output: contains("Precompiled foo."));
473
474 d.dir(appPath, [
475 d.dir(".pub/deps/debug/foo/lib", [
476 d.file("foo.dart", "final message = 'Goodbye!';")
477 ])
478 ]).validate();
479
480 // Upgrade to the new version of foo.
481 d.appDir({"foo": "1.2.4"}).create();
482
483 pubGet(args: ["--no-precompile"], output: isNot(contains("Precompiled")));
484
485 d.nothing(p.join(appPath, ".pub/deps/debug/foo")).validate();
486 });
487
488 integration("doesn't delete a cache when an unrelated dependency is "
489 "updated", () {
490 servePackages((builder) {
491 builder.serveRealPackage('barback');
492
493 builder.serve("foo", "1.2.3",
494 deps: {'barback': 'any'},
495 pubspec: {'transformers': ['foo']},
496 contents: [
497 d.dir("lib", [
498 d.file("transformer.dart", replaceTransformer("Hello", "Goodbye")),
499 d.file("foo.dart", "final message = 'Hello!';")
500 ])
501 ]);
502
503 builder.serve("bar", "5.6.7");
504 });
505
506 d.appDir({"foo": "1.2.3"}).create();
507 pubGet(output: contains("Precompiled foo."));
508
509
510 d.dir(appPath, [
511 d.dir(".pub/deps/debug/foo/lib", [
512 d.file("foo.dart", "final message = 'Goodbye!';")
513 ])
514 ]).validate();
515
516 globalPackageServer.add((builder) => builder.serve("bar", "6.0.0"));
517 pubUpgrade(
518 args: ["--no-precompile"],
519 output: isNot(contains("Precompiled")));
520
521 d.dir(appPath, [
522 d.dir(".pub/deps/debug/foo/lib", [
523 d.file("foo.dart", "final message = 'Goodbye!';")
524 ])
525 ]).validate();
526 });
527 });
420 } 528 }
421 529
422 String replaceTransformer(String input, String output) { 530 String replaceTransformer(String input, String output) {
423 return """ 531 return """
424 import 'dart:async'; 532 import 'dart:async';
425 533
426 import 'package:barback/barback.dart'; 534 import 'package:barback/barback.dart';
427 535
428 class ReplaceTransformer extends Transformer { 536 class ReplaceTransformer extends Transformer {
429 ReplaceTransformer.asPlugin(); 537 ReplaceTransformer.asPlugin();
430 538
431 String get allowedExtensions => '.dart'; 539 String get allowedExtensions => '.dart';
432 540
433 Future apply(Transform transform) { 541 Future apply(Transform transform) {
434 return transform.primaryInput.readAsString().then((contents) { 542 return transform.primaryInput.readAsString().then((contents) {
435 transform.addOutput(new Asset.fromString( 543 transform.addOutput(new Asset.fromString(
436 transform.primaryInput.id, 544 transform.primaryInput.id,
437 contents.replaceAll("$input", "$output"))); 545 contents.replaceAll("$input", "$output")));
438 }); 546 });
439 } 547 }
440 } 548 }
441 """; 549 """;
442 } 550 }
OLDNEW
« no previous file with comments | « lib/src/entrypoint.dart ('k') | test/snapshot/no_precompile_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698