Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 updated" , | |
|
Bob Nystrom
2016/03/17 20:05:06
Long line.
nweiz
2016/03/17 20:09:56
Done.
| |
| 489 () { | |
| 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 } |
| OLD | NEW |