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