| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 error: ''' | 52 error: ''' |
| 53 Unknown command "quylthulg". | 53 Unknown command "quylthulg". |
| 54 Run "pub help" to see available commands. | 54 Run "pub help" to see available commands. |
| 55 ''', | 55 ''', |
| 56 exitCode: 64); | 56 exitCode: 64); |
| 57 }); | 57 }); |
| 58 }); | 58 }); |
| 59 | 59 |
| 60 group('pub list', listCommand); | 60 group('pub list', listCommand); |
| 61 group('pub install', installCommand); | 61 group('pub install', installCommand); |
| 62 group('pub update', updateCommand); |
| 62 group('pub version', versionCommand); | 63 group('pub version', versionCommand); |
| 63 } | 64 } |
| 64 | 65 |
| 65 listCommand() { | 66 listCommand() { |
| 66 // TODO(rnystrom): We don't currently have any sources that are cached, so | 67 // TODO(rnystrom): We don't currently have any sources that are cached, so |
| 67 // we can't test this right now. | 68 // we can't test this right now. |
| 68 /* | 69 /* |
| 69 group('cache', () { | 70 group('cache', () { |
| 70 test('treats an empty directory as a package', () { | 71 test('treats an empty directory as a package', () { |
| 71 dir(cachePath, [ | 72 dir(cachePath, [ |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 git('bar.git', [ | 881 git('bar.git', [ |
| 881 file('bar.dart', 'main() => "bar";') | 882 file('bar.dart', 'main() => "bar";') |
| 882 ]).scheduleCreate(); | 883 ]).scheduleCreate(); |
| 883 | 884 |
| 884 dir(appPath, [ | 885 dir(appPath, [ |
| 885 file('pubspec.yaml', ''' | 886 file('pubspec.yaml', ''' |
| 886 dependencies: | 887 dependencies: |
| 887 foo: | 888 foo: |
| 888 git: ../foo.git | 889 git: ../foo.git |
| 889 bar: | 890 bar: |
| 890 git: ../foo.git | 891 git: ../bar.git |
| 891 ''') | 892 ''') |
| 892 ]).scheduleCreate(); | 893 ]).scheduleCreate(); |
| 893 | 894 |
| 894 schedulePub(args: ['install'], | 895 schedulePub(args: ['install'], |
| 895 output: const RegExp(@"Dependencies installed!$")); | 896 output: const RegExp(@"Dependencies installed!$")); |
| 896 | 897 |
| 897 dir(packagesPath, [ | 898 dir(packagesPath, [ |
| 898 dir('foo', [ | 899 dir('foo', [ |
| 899 file('foo.dart', 'main() => "foo";') | 900 file('foo.dart', 'main() => "foo";') |
| 900 ]), | 901 ]), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 git('bar.git', [ | 938 git('bar.git', [ |
| 938 file('bar.dart', 'main() => "bar";') | 939 file('bar.dart', 'main() => "bar";') |
| 939 ]).scheduleCreate(); | 940 ]).scheduleCreate(); |
| 940 | 941 |
| 941 dir(appPath, [ | 942 dir(appPath, [ |
| 942 file('pubspec.yaml', ''' | 943 file('pubspec.yaml', ''' |
| 943 dependencies: | 944 dependencies: |
| 944 foo: | 945 foo: |
| 945 git: ../foo.git | 946 git: ../foo.git |
| 946 bar: | 947 bar: |
| 947 git: ../foo.git | 948 git: ../bar.git |
| 948 ''') | 949 ''') |
| 949 ]).scheduleCreate(); | 950 ]).scheduleCreate(); |
| 950 | 951 |
| 951 schedulePub(args: ['install'], | 952 schedulePub(args: ['install'], |
| 952 output: const RegExp(@"Dependencies installed!$")); | 953 output: const RegExp(@"Dependencies installed!$")); |
| 953 | 954 |
| 954 dir(packagesPath, [ | 955 dir(packagesPath, [ |
| 955 dir('foo', [ | 956 dir('foo', [ |
| 956 file('foo.dart', 'main() => "foo";') | 957 file('foo.dart', 'main() => "foo";') |
| 957 ]), | 958 ]), |
| 958 dir('bar', [ | 959 dir('bar', [ |
| 959 file('bar.dart', 'main() => "bar";') | 960 file('bar.dart', 'main() => "bar";') |
| 960 ]) | 961 ]) |
| 961 ]).scheduleValidate(); | 962 ]).scheduleValidate(); |
| 962 | 963 |
| 963 git('foo.git', [ | 964 git('foo.git', [ |
| 964 file('foo.dart', 'main() => "foo 2";') | 965 file('foo.dart', 'main() => "foo 2";') |
| 965 ]).scheduleCommit(); | 966 ]).scheduleCommit(); |
| 966 | 967 |
| 967 git('bar.git', [ | 968 git('bar.git', [ |
| 968 file('bar.dart', 'main() => "bar 2";') | 969 file('bar.dart', 'main() => "bar 2";') |
| 969 ]).scheduleCommit(); | 970 ]).scheduleCommit(); |
| 970 | 971 |
| 971 schedulePub(args: ['update foo'], | 972 schedulePub(args: ['update', 'foo'], |
| 972 output: const RegExp(@"Dependencies updated!$")); | 973 output: const RegExp(@"Dependencies updated!$")); |
| 973 | 974 |
| 974 dir(packagesPath, [ | 975 dir(packagesPath, [ |
| 975 dir('foo', [ | 976 dir('foo', [ |
| 976 file('foo.dart', 'main() => "foo 2";') | 977 file('foo.dart', 'main() => "foo 2";') |
| 977 ]), | 978 ]), |
| 978 dir('bar', [ | 979 dir('bar', [ |
| 979 file('bar.dart', 'main() => "bar";') | 980 file('bar.dart', 'main() => "bar";') |
| 980 ]) | 981 ]) |
| 981 ]).scheduleValidate(); | 982 ]).scheduleValidate(); |
| 982 | 983 |
| 983 run(); | 984 run(); |
| 984 }); | 985 }); |
| 985 | 986 |
| 986 test("updates one locked Git package's dependencies", () { | 987 test("doesn't update one locked Git package's dependencies if it's not " |
| 988 "necessary", () { |
| 987 ensureGit(); | 989 ensureGit(); |
| 988 | 990 |
| 989 git('foo.git', [ | 991 git('foo.git', [ |
| 990 file('foo.dart', 'main() => "foo";'), | 992 file('foo.dart', 'main() => "foo";'), |
| 991 file('pubspec.yaml', ''' | 993 file('pubspec.yaml', ''' |
| 992 dependencies: | 994 dependencies: |
| 993 foo-dep: | 995 foo-dep: |
| 994 git: ../foo-dep.git | 996 git: ../foo-dep.git |
| 995 ''') | 997 ''') |
| 996 ]).scheduleCreate(); | 998 ]).scheduleCreate(); |
| 997 | 999 |
| 998 git('foo-dep.git', [ | 1000 git('foo-dep.git', [ |
| 999 file('foo-dep.dart', 'main() => "foo-dep";') | 1001 file('foo-dep.dart', 'main() => "foo-dep";') |
| 1000 ]).scheduleCreate(); | 1002 ]).scheduleCreate(); |
| 1001 | 1003 |
| 1002 git('bar.git', [ | |
| 1003 file('bar.dart', 'main() => "bar";'), | |
| 1004 file('pubspec.yaml', ''' | |
| 1005 dependencies: | |
| 1006 bar-dep: | |
| 1007 git: ../bar-dep.git | |
| 1008 ''') | |
| 1009 ]).scheduleCreate(); | |
| 1010 | |
| 1011 git('bar-dep.git', [ | |
| 1012 file('bar-dep.dart', 'main() => "bar-dep";') | |
| 1013 ]).scheduleCreate(); | |
| 1014 | |
| 1015 dir(appPath, [ | 1004 dir(appPath, [ |
| 1016 file('pubspec.yaml', ''' | 1005 file('pubspec.yaml', ''' |
| 1017 dependencies: | 1006 dependencies: |
| 1018 foo: | 1007 foo: |
| 1019 git: ../foo.git | 1008 git: ../foo.git |
| 1020 bar: | |
| 1021 git: ../foo.git | |
| 1022 ''') | 1009 ''') |
| 1023 ]).scheduleCreate(); | 1010 ]).scheduleCreate(); |
| 1024 | 1011 |
| 1025 schedulePub(args: ['install'], | 1012 schedulePub(args: ['install'], |
| 1026 output: const RegExp(@"Dependencies installed!$")); | 1013 output: const RegExp(@"Dependencies installed!$")); |
| 1027 | 1014 |
| 1028 dir(packagesPath, [ | 1015 dir(packagesPath, [ |
| 1029 dir('foo', [ | 1016 dir('foo', [ |
| 1030 file('foo.dart', 'main() => "foo";'), | 1017 file('foo.dart', 'main() => "foo";'), |
| 1031 file('pubspec.yaml', ''' | 1018 file('pubspec.yaml', ''' |
| 1032 dependencies: | 1019 dependencies: |
| 1033 foo-dep: | 1020 foo-dep: |
| 1034 git: ../foo-dep.git | 1021 git: ../foo-dep.git |
| 1035 ''') | 1022 ''') |
| 1036 ]), | 1023 ]), |
| 1037 dir('foo-dep', [ | 1024 dir('foo-dep', [ |
| 1038 file('foo-dep.dart', 'main() => "foo-dep";') | 1025 file('foo-dep.dart', 'main() => "foo-dep";') |
| 1039 ]), | |
| 1040 dir('bar', [ | |
| 1041 file('bar.dart', 'main() => "bar";'), | |
| 1042 file('pubspec.yaml', ''' | |
| 1043 dependencies: | |
| 1044 bar-dep: | |
| 1045 git: ../bar-dep.git | |
| 1046 ''') | |
| 1047 ]), | |
| 1048 dir('bar-dep', [ | |
| 1049 file('bar-dep.dart', 'main() => "bar-dep";') | |
| 1050 ]) | 1026 ]) |
| 1051 ]).scheduleValidate(); | 1027 ]).scheduleValidate(); |
| 1052 | 1028 |
| 1029 git('foo.git', [ |
| 1030 file('foo.dart', 'main() => "foo 2";'), |
| 1031 file('pubspec.yaml', ''' |
| 1032 dependencies: |
| 1033 foo-dep: |
| 1034 git: ../foo-dep.git |
| 1035 ''') |
| 1036 ]).scheduleCreate(); |
| 1037 |
| 1053 git('foo-dep.git', [ | 1038 git('foo-dep.git', [ |
| 1054 file('foo-dep.dart', 'main() => "foo-dep 2";') | 1039 file('foo-dep.dart', 'main() => "foo-dep 2";') |
| 1055 ]).scheduleCommit(); | 1040 ]).scheduleCommit(); |
| 1056 | 1041 |
| 1057 git('bar-dep.git', [ | 1042 schedulePub(args: ['update', 'foo'], |
| 1058 file('bar-dep.dart', 'main() => "bar-dep 2";') | |
| 1059 ]).scheduleCommit(); | |
| 1060 | |
| 1061 schedulePub(args: ['update foo'], | |
| 1062 output: const RegExp(@"Dependencies updated!$")); | 1043 output: const RegExp(@"Dependencies updated!$")); |
| 1063 | 1044 |
| 1064 dir(packagesPath, [ | 1045 dir(packagesPath, [ |
| 1065 dir('foo', [ | 1046 dir('foo', [ |
| 1066 file('foo.dart', 'main() => "foo";'), | 1047 file('foo.dart', 'main() => "foo 2";'), |
| 1067 file('pubspec.yaml', ''' | 1048 file('pubspec.yaml', ''' |
| 1068 dependencies: | 1049 dependencies: |
| 1069 foo-dep: | 1050 foo-dep: |
| 1070 git: ../foo-dep.git | 1051 git: ../foo-dep.git |
| 1071 ''') | 1052 ''') |
| 1072 ]), | 1053 ]), |
| 1073 dir('foo-dep', [ | 1054 dir('foo-dep', [ |
| 1074 file('foo-dep.dart', 'main() => "foo-dep 2";') | 1055 file('foo-dep.dart', 'main() => "foo-dep";') |
| 1075 ]), | 1056 ]), |
| 1076 dir('bar', [ | 1057 ]).scheduleValidate(); |
| 1077 file('bar.dart', 'main() => "bar";'), | 1058 |
| 1059 run(); |
| 1060 }); |
| 1061 |
| 1062 test("updates one locked pub server package's dependencies if it's " |
| 1063 "necessary", () { |
| 1064 servePackages("localhost", 3123, [ |
| 1065 ''' |
| 1066 name: foo |
| 1067 version: 1.0.0 |
| 1068 dependencies: |
| 1069 foo-dep: |
| 1070 repo: |
| 1071 name: foo-dep |
| 1072 url: http://localhost:3123 |
| 1073 ''', |
| 1074 '{name: foo-dep, version: 1.0.0}' |
| 1075 ]); |
| 1076 |
| 1077 dir(appPath, [ |
| 1078 file('pubspec.yaml', ''' |
| 1079 dependencies: |
| 1080 foo: |
| 1081 repo: |
| 1082 name: foo |
| 1083 url: http://localhost:3123 |
| 1084 ''') |
| 1085 ]).scheduleCreate(); |
| 1086 |
| 1087 schedulePub(args: ['install'], |
| 1088 output: const RegExp(@"Dependencies installed!$")); |
| 1089 |
| 1090 dir(packagesPath, [ |
| 1091 dir('foo', [ |
| 1092 file('foo.dart', 'main() => print("foo 1.0.0");'), |
| 1078 file('pubspec.yaml', ''' | 1093 file('pubspec.yaml', ''' |
| 1094 name: foo |
| 1095 version: 1.0.0 |
| 1079 dependencies: | 1096 dependencies: |
| 1080 bar-dep: | 1097 foo-dep: |
| 1081 git: ../bar-dep.git | 1098 repo: |
| 1099 name: foo-dep |
| 1100 url: http://localhost:3123 |
| 1082 ''') | 1101 ''') |
| 1083 ]), | 1102 ]), |
| 1084 dir('bar-dep', [ | 1103 dir('foo-dep', [ |
| 1085 file('bar-dep.dart', 'main() => "bar-dep";') | 1104 file('foo-dep.dart', 'main() => print("foo-dep 1.0.0");') |
| 1086 ]) | 1105 ]) |
| 1087 ]).scheduleValidate(); | 1106 ]).scheduleValidate(); |
| 1088 | 1107 |
| 1108 servePackages("localhost", 3123, [ |
| 1109 ''' |
| 1110 name: foo |
| 1111 version: 2.0.0 |
| 1112 dependencies: |
| 1113 foo-dep: |
| 1114 repo: {name: foo-dep, url: http://localhost:3123} |
| 1115 version: ">1.0.0" |
| 1116 ''', |
| 1117 '{name: foo-dep, version: 2.0.0}' |
| 1118 ]); |
| 1119 |
| 1120 schedulePub(args: ['update', 'foo'], |
| 1121 output: const RegExp(@"Dependencies updated!$")); |
| 1122 |
| 1123 dir(packagesPath, [ |
| 1124 dir('foo', [ |
| 1125 file('foo.dart', 'main() => print("foo 2.0.0");'), |
| 1126 file('pubspec.yaml', ''' |
| 1127 name: foo |
| 1128 version: 2.0.0 |
| 1129 dependencies: |
| 1130 foo-dep: |
| 1131 repo: {name: foo-dep, url: http://localhost:3123} |
| 1132 version: ">1.0.0" |
| 1133 ''') |
| 1134 ]), |
| 1135 dir('foo-dep', [ |
| 1136 file('foo-dep.dart', 'main() => print("foo-dep 2.0.0");') |
| 1137 ]) |
| 1138 ]).scheduleValidate(); |
| 1139 |
| 1089 run(); | 1140 run(); |
| 1090 }); | 1141 }); |
| 1091 }); | 1142 }); |
| 1092 } | 1143 } |
| 1093 | 1144 |
| 1094 versionCommand() { | 1145 versionCommand() { |
| 1095 test('displays the current version', () => | 1146 test('displays the current version', () => |
| 1096 runPub(args: ['version'], output: VERSION_STRING)); | 1147 runPub(args: ['version'], output: VERSION_STRING)); |
| 1097 } | 1148 } |
| OLD | NEW |