| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('pub_tests'); | 5 #library('pub_tests'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 | 8 |
| 9 #import('test_pub.dart'); | 9 #import('test_pub.dart'); |
| 10 #import('../../../lib/unittest/unittest.dart'); | 10 #import('../../../lib/unittest/unittest.dart'); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 ]).scheduleValidate(); | 247 ]).scheduleValidate(); |
| 248 | 248 |
| 249 dir(packagesPath, [ | 249 dir(packagesPath, [ |
| 250 dir('foo', [ | 250 dir('foo', [ |
| 251 file('foo.dart', 'main() => "foo";') | 251 file('foo.dart', 'main() => "foo";') |
| 252 ]) | 252 ]) |
| 253 ]).scheduleValidate(); | 253 ]).scheduleValidate(); |
| 254 | 254 |
| 255 // TODO(nweiz): remove this once we support pub update | 255 // TODO(nweiz): remove this once we support pub update |
| 256 dir(packagesPath).scheduleDelete(); | 256 dir(packagesPath).scheduleDelete(); |
| 257 file('$appPath/pubspec.lock', '').scheduleDelete(); | |
| 258 | 257 |
| 259 git('foo.git', [ | 258 git('foo.git', [ |
| 260 file('foo.dart', 'main() => "foo 2";') | 259 file('foo.dart', 'main() => "foo 2";') |
| 261 ]).scheduleCommit(); | 260 ]).scheduleCommit(); |
| 262 | 261 |
| 263 schedulePub(args: ['install'], | 262 schedulePub(args: ['install'], |
| 264 output: const RegExp(@"Dependencies installed!$")); | 263 output: const RegExp(@"Dependencies installed!$")); |
| 265 | 264 |
| 266 // When we download a new version of the git package, we should re-use the | 265 // When we download a new version of the git package, we should re-use the |
| 267 // git/cache directory but create a new git/ directory. | 266 // git/cache directory but create a new git/ directory. |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 file('bar.dart', 'main() => print("bar 2.3.4");') | 575 file('bar.dart', 'main() => print("bar 2.3.4");') |
| 577 ]), | 576 ]), |
| 578 dir('baz', [ | 577 dir('baz', [ |
| 579 file('pubspec.yaml', '{name: baz, version: 2.0.4}'), | 578 file('pubspec.yaml', '{name: baz, version: 2.0.4}'), |
| 580 file('baz.dart', 'main() => print("baz 2.0.4");') | 579 file('baz.dart', 'main() => print("baz 2.0.4");') |
| 581 ]) | 580 ]) |
| 582 ]).scheduleValidate(); | 581 ]).scheduleValidate(); |
| 583 | 582 |
| 584 run(); | 583 run(); |
| 585 }); | 584 }); |
| 586 | |
| 587 test('keeps a Git package locked to the version in the lockfile', () { | |
| 588 ensureGit(); | |
| 589 | |
| 590 git('foo.git', [ | |
| 591 file('foo.dart', 'main() => "foo";') | |
| 592 ]).scheduleCreate(); | |
| 593 | |
| 594 dir(appPath, [ | |
| 595 file('pubspec.yaml', ''' | |
| 596 dependencies: | |
| 597 foo: | |
| 598 git: ../foo.git | |
| 599 ''') | |
| 600 ]).scheduleCreate(); | |
| 601 | |
| 602 // This install should lock the foo.git dependency to the current revision. | |
| 603 schedulePub(args: ['install'], | |
| 604 output: const RegExp(@"Dependencies installed!$")); | |
| 605 | |
| 606 dir(packagesPath, [ | |
| 607 dir('foo', [ | |
| 608 file('foo.dart', 'main() => "foo";') | |
| 609 ]) | |
| 610 ]).scheduleValidate(); | |
| 611 | |
| 612 // Delete the packages path to simulate a new checkout of the application. | |
| 613 dir(packagesPath).scheduleDelete(); | |
| 614 | |
| 615 git('foo.git', [ | |
| 616 file('foo.dart', 'main() => "foo 2";') | |
| 617 ]).scheduleCommit(); | |
| 618 | |
| 619 // This install shouldn't update the foo.git dependency due to the lockfile. | |
| 620 schedulePub(args: ['install'], | |
| 621 output: const RegExp(@"Dependencies installed!$")); | |
| 622 | |
| 623 dir(packagesPath, [ | |
| 624 dir('foo', [ | |
| 625 file('foo.dart', 'main() => "foo";') | |
| 626 ]) | |
| 627 ]).scheduleValidate(); | |
| 628 | |
| 629 run(); | |
| 630 }); | |
| 631 | |
| 632 test('updates a locked Git package with a new incompatible constraint', () { | |
| 633 ensureGit(); | |
| 634 | |
| 635 git('foo.git', [ | |
| 636 file('foo.dart', 'main() => "foo";') | |
| 637 ]).scheduleCreate(); | |
| 638 | |
| 639 dir(appPath, [ | |
| 640 file('pubspec.yaml', ''' | |
| 641 dependencies: | |
| 642 foo: | |
| 643 git: ../foo.git | |
| 644 ''') | |
| 645 ]).scheduleCreate(); | |
| 646 | |
| 647 schedulePub(args: ['install'], | |
| 648 output: const RegExp(@"Dependencies installed!$")); | |
| 649 | |
| 650 dir(packagesPath, [ | |
| 651 dir('foo', [ | |
| 652 file('foo.dart', 'main() => "foo";') | |
| 653 ]) | |
| 654 ]).scheduleValidate(); | |
| 655 | |
| 656 git('foo.git', [ | |
| 657 file('foo.dart', 'main() => "foo 1.0.0";'), | |
| 658 file('pubspec.yaml', 'version: 1.0.0') | |
| 659 ]).scheduleCommit(); | |
| 660 | |
| 661 dir(appPath, [ | |
| 662 file('pubspec.yaml', ''' | |
| 663 dependencies: | |
| 664 foo: | |
| 665 git: ../foo.git | |
| 666 version: ">=1.0.0" | |
| 667 ''') | |
| 668 ]).scheduleCreate(); | |
| 669 | |
| 670 schedulePub(args: ['install'], | |
| 671 output: const RegExp(@"Dependencies installed!$")); | |
| 672 | |
| 673 dir(packagesPath, [ | |
| 674 dir('foo', [ | |
| 675 file('foo.dart', 'main() => "foo 1.0.0";') | |
| 676 ]) | |
| 677 ]).scheduleValidate(); | |
| 678 | |
| 679 run(); | |
| 680 }); | |
| 681 | |
| 682 test("doesn't update a locked Git package with a new compatible " | |
| 683 "constraint", () { | |
| 684 ensureGit(); | |
| 685 | |
| 686 git('foo.git', [ | |
| 687 file('foo.dart', 'main() => "foo 1.0.0";'), | |
| 688 file('pubspec.yaml', 'version: 1.0.0') | |
| 689 ]).scheduleCreate(); | |
| 690 | |
| 691 dir(appPath, [ | |
| 692 file('pubspec.yaml', ''' | |
| 693 dependencies: | |
| 694 foo: | |
| 695 git: ../foo.git | |
| 696 ''') | |
| 697 ]).scheduleCreate(); | |
| 698 | |
| 699 schedulePub(args: ['install'], | |
| 700 output: const RegExp(@"Dependencies installed!$")); | |
| 701 | |
| 702 dir(packagesPath, [ | |
| 703 dir('foo', [ | |
| 704 file('foo.dart', 'main() => "foo 1.0.0";') | |
| 705 ]) | |
| 706 ]).scheduleValidate(); | |
| 707 | |
| 708 git('foo.git', [ | |
| 709 file('foo.dart', 'main() => "foo 1.0.1";'), | |
| 710 file('pubspec.yaml', 'version: 1.0.1') | |
| 711 ]).scheduleCommit(); | |
| 712 | |
| 713 dir(appPath, [ | |
| 714 file('pubspec.yaml', ''' | |
| 715 dependencies: | |
| 716 foo: | |
| 717 git: ../foo.git | |
| 718 version: ">=1.0.0" | |
| 719 ''') | |
| 720 ]).scheduleCreate(); | |
| 721 | |
| 722 schedulePub(args: ['install'], | |
| 723 output: const RegExp(@"Dependencies installed!$")); | |
| 724 | |
| 725 dir(packagesPath, [ | |
| 726 dir('foo', [ | |
| 727 file('foo.dart', 'main() => "foo 1.0.0";') | |
| 728 ]) | |
| 729 ]).scheduleValidate(); | |
| 730 | |
| 731 run(); | |
| 732 }); | |
| 733 | |
| 734 test('keeps a pub server package locked to the version in the lockfile', () { | |
| 735 var serverFuture = | |
| 736 servePackages("localhost", 3123, ['{name: foo, version: 1.0.0}']); | |
| 737 | |
| 738 dir(appPath, [ | |
| 739 file('pubspec.yaml', ''' | |
| 740 dependencies: | |
| 741 foo: | |
| 742 repo: {name: foo, url: http://localhost:3123} | |
| 743 ''') | |
| 744 ]).scheduleCreate(); | |
| 745 | |
| 746 // This install should lock the foo dependency to version 1.0.0. | |
| 747 schedulePub(args: ['install'], | |
| 748 output: const RegExp(@"Dependencies installed!$")); | |
| 749 | |
| 750 dir(packagesPath, [ | |
| 751 dir('foo', [ | |
| 752 file('foo.dart', 'main() => print("foo 1.0.0");') | |
| 753 ]) | |
| 754 ]).scheduleValidate(); | |
| 755 | |
| 756 // Delete the packages path to simulate a new checkout of the application. | |
| 757 dir(packagesPath).scheduleDelete(); | |
| 758 | |
| 759 // Start serving a newer package as well. | |
| 760 servePackages("localhost", 3123, [ | |
| 761 '{name: foo, version: 1.0.0}', | |
| 762 '{name: foo, version: 1.0.1}' | |
| 763 ]); | |
| 764 | |
| 765 // This install shouldn't update the foo dependency due to the lockfile. | |
| 766 schedulePub(args: ['install'], | |
| 767 output: const RegExp(@"Dependencies installed!$")); | |
| 768 | |
| 769 dir(packagesPath, [ | |
| 770 dir('foo', [ | |
| 771 file('foo.dart', 'main() => print("foo 1.0.0");') | |
| 772 ]) | |
| 773 ]).scheduleValidate(); | |
| 774 | |
| 775 run(); | |
| 776 }); | |
| 777 | |
| 778 test('updates a locked pub server package with a new incompatible ' | |
| 779 'constraint', () { | |
| 780 var serverFuture = | |
| 781 servePackages("localhost", 3123, ['{name: foo, version: 1.0.0}']); | |
| 782 | |
| 783 dir(appPath, [ | |
| 784 file('pubspec.yaml', ''' | |
| 785 dependencies: | |
| 786 foo: | |
| 787 repo: {name: foo, url: http://localhost:3123} | |
| 788 ''') | |
| 789 ]).scheduleCreate(); | |
| 790 | |
| 791 schedulePub(args: ['install'], | |
| 792 output: const RegExp(@"Dependencies installed!$")); | |
| 793 | |
| 794 dir(packagesPath, [ | |
| 795 dir('foo', [ | |
| 796 file('foo.dart', 'main() => print("foo 1.0.0");') | |
| 797 ]) | |
| 798 ]).scheduleValidate(); | |
| 799 | |
| 800 servePackages("localhost", 3123, [ | |
| 801 '{name: foo, version: 1.0.0}', | |
| 802 '{name: foo, version: 1.0.1}' | |
| 803 ]); | |
| 804 | |
| 805 dir(appPath, [ | |
| 806 file('pubspec.yaml', ''' | |
| 807 dependencies: | |
| 808 foo: | |
| 809 repo: {name: foo, url: http://localhost:3123} | |
| 810 version: ">1.0.0" | |
| 811 ''') | |
| 812 ]).scheduleCreate(); | |
| 813 | |
| 814 schedulePub(args: ['install'], | |
| 815 output: const RegExp(@"Dependencies installed!$")); | |
| 816 | |
| 817 dir(packagesPath, [ | |
| 818 dir('foo', [ | |
| 819 file('foo.dart', 'main() => print("foo 1.0.1");') | |
| 820 ]) | |
| 821 ]).scheduleValidate(); | |
| 822 | |
| 823 run(); | |
| 824 }); | |
| 825 | |
| 826 test("doesn't update a locked pub server package with a new compatible " | |
| 827 "constraint", () { | |
| 828 var serverFuture = | |
| 829 servePackages("localhost", 3123, ['{name: foo, version: 1.0.0}']); | |
| 830 | |
| 831 dir(appPath, [ | |
| 832 file('pubspec.yaml', ''' | |
| 833 dependencies: | |
| 834 foo: | |
| 835 repo: {name: foo, url: http://localhost:3123} | |
| 836 ''') | |
| 837 ]).scheduleCreate(); | |
| 838 | |
| 839 schedulePub(args: ['install'], | |
| 840 output: const RegExp(@"Dependencies installed!$")); | |
| 841 | |
| 842 dir(packagesPath, [ | |
| 843 dir('foo', [ | |
| 844 file('foo.dart', 'main() => print("foo 1.0.0");') | |
| 845 ]) | |
| 846 ]).scheduleValidate(); | |
| 847 | |
| 848 servePackages("localhost", 3123, [ | |
| 849 '{name: foo, version: 1.0.0}', | |
| 850 '{name: foo, version: 1.0.1}' | |
| 851 ]); | |
| 852 | |
| 853 dir(appPath, [ | |
| 854 file('pubspec.yaml', ''' | |
| 855 dependencies: | |
| 856 foo: | |
| 857 repo: {name: foo, url: http://localhost:3123} | |
| 858 version: ">=1.0.0" | |
| 859 ''') | |
| 860 ]).scheduleCreate(); | |
| 861 | |
| 862 schedulePub(args: ['install'], | |
| 863 output: const RegExp(@"Dependencies installed!$")); | |
| 864 | |
| 865 dir(packagesPath, [ | |
| 866 dir('foo', [ | |
| 867 file('foo.dart', 'main() => print("foo 1.0.0");') | |
| 868 ]) | |
| 869 ]).scheduleValidate(); | |
| 870 | |
| 871 run(); | |
| 872 }); | |
| 873 } | 585 } |
| 874 | 586 |
| 875 versionCommand() { | 587 versionCommand() { |
| 876 test('displays the current version', () => | 588 test('displays the current version', () => |
| 877 runPub(args: ['version'], output: VERSION_STRING)); | 589 runPub(args: ['version'], output: VERSION_STRING)); |
| 878 } | 590 } |
| OLD | NEW |