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('../../../pkg/unittest/unittest.dart'); | 10 #import('../../../pkg/unittest/unittest.dart'); |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 schedulePub(args: ['install'], | 29 schedulePub(args: ['install'], |
30 error: const RegExp(@'^"pubspec.yaml" is missing the required "name" ' | 30 error: const RegExp(@'^"pubspec.yaml" is missing the required "name" ' |
31 @'field \(e\.g\. "name: myapp"\)\.'), | 31 @'field \(e\.g\. "name: myapp"\)\.'), |
32 exitCode: 1); | 32 exitCode: 1); |
33 | 33 |
34 run(); | 34 run(); |
35 }); | 35 }); |
36 }); | 36 }); |
37 | 37 |
38 // TODO(rnystrom): Re-enable this when #4820 is fixed. | 38 test('adds itself to the packages', () { |
39 /* | |
40 test('creates a self-referential symlink', () { | |
41 // The symlink should use the name in the pubspec, not the name of the | 39 // The symlink should use the name in the pubspec, not the name of the |
42 // directory. | 40 // directory. |
43 dir(appPath, [ | 41 dir(appPath, [ |
44 pubspec({"name": "myapp_name"}) | 42 pubspec({"name": "myapp_name"}), |
| 43 libDir('foo'), |
45 ]).scheduleCreate(); | 44 ]).scheduleCreate(); |
46 | 45 |
47 schedulePub(args: ['install'], | 46 schedulePub(args: ['install'], |
48 output: const RegExp(@"Dependencies installed!$")); | 47 output: const RegExp(@"Dependencies installed!$")); |
49 | 48 |
50 dir(packagesPath, [ | 49 dir(packagesPath, [ |
51 dir("myapp_name", [pubspec({"name": "myapp_name"})]) | 50 dir("myapp_name", [ |
| 51 file('foo.dart', 'main() => "foo";') |
| 52 ]) |
52 ]).scheduleValidate(); | 53 ]).scheduleValidate(); |
53 | 54 |
54 run(); | 55 run(); |
55 }); | 56 }); |
56 */ | 57 |
| 58 test('does not adds itself to the packages if it has no "lib" directory', () { |
| 59 // The symlink should use the name in the pubspec, not the name of the |
| 60 // directory. |
| 61 dir(appPath, [ |
| 62 pubspec({"name": "myapp_name"}), |
| 63 ]).scheduleCreate(); |
| 64 |
| 65 schedulePub(args: ['install'], |
| 66 output: const RegExp(@"Dependencies installed!$")); |
| 67 |
| 68 dir(packagesPath, [ |
| 69 nothing("myapp_name") |
| 70 ]).scheduleValidate(); |
| 71 |
| 72 run(); |
| 73 }); |
| 74 |
| 75 test('does not add a package if it does not have a "lib" directory', () { |
| 76 // Using an SDK source, but this should be true of all sources. |
| 77 dir(sdkPath, [ |
| 78 file('revision', '1234'), |
| 79 dir('pkg', [ |
| 80 dir('foo', []) |
| 81 ]) |
| 82 ]).scheduleCreate(); |
| 83 |
| 84 dir(appPath, [ |
| 85 pubspec({"name": "myapp", "dependencies": {"foo": {"sdk": "foo"}}}) |
| 86 ]).scheduleCreate(); |
| 87 |
| 88 schedulePub(args: ['install'], |
| 89 error: const RegExp(@'Warning: Package "foo" does not have a "lib" ' |
| 90 'directory.'), |
| 91 output: const RegExp(@"Dependencies installed!$")); |
| 92 |
| 93 run(); |
| 94 }); |
57 | 95 |
58 group('creates a packages directory in', () { | 96 group('creates a packages directory in', () { |
59 test('"test/" and its subdirectories', () { | 97 test('"test/" and its subdirectories', () { |
60 dir(appPath, [ | 98 dir(appPath, [ |
61 appPubspec([]), | 99 appPubspec([]), |
| 100 libDir('foo'), |
62 dir("test", [dir("subtest")]) | 101 dir("test", [dir("subtest")]) |
63 ]).scheduleCreate(); | 102 ]).scheduleCreate(); |
64 | 103 |
65 schedulePub(args: ['install'], | 104 schedulePub(args: ['install'], |
66 output: const RegExp(@"Dependencies installed!$")); | 105 output: const RegExp(@"Dependencies installed!$")); |
67 | 106 |
68 dir(appPath, [ | 107 dir(appPath, [ |
69 dir("test", [ | 108 dir("test", [ |
70 dir("packages", [ | 109 dir("packages", [ |
71 // TODO(rnystrom): Re-enable this when #4820 is fixed. | 110 dir("myapp", [ |
72 /* | 111 file('foo.dart', 'main() => "foo";') |
73 dir("myapp", [appPubspec([])]) | 112 ]) |
74 */ | |
75 ]), | 113 ]), |
76 dir("subtest", [ | 114 dir("subtest", [ |
77 dir("packages", [ | 115 dir("packages", [ |
78 // TODO(rnystrom): Re-enable this when #4820 is fixed. | 116 dir("myapp", [ |
79 /* | 117 file('foo.dart', 'main() => "foo";') |
80 dir("myapp", [appPubspec([])]) | 118 ]) |
81 */ | |
82 ]) | 119 ]) |
83 ]) | 120 ]) |
84 ]) | 121 ]) |
85 ]).scheduleValidate(); | 122 ]).scheduleValidate(); |
86 | 123 |
87 run(); | 124 run(); |
88 }); | 125 }); |
89 | 126 |
90 test('"example/" and its subdirectories', () { | 127 test('"example/" and its subdirectories', () { |
91 dir(appPath, [ | 128 dir(appPath, [ |
92 appPubspec([]), | 129 appPubspec([]), |
| 130 libDir('foo'), |
93 dir("example", [dir("subexample")]) | 131 dir("example", [dir("subexample")]) |
94 ]).scheduleCreate(); | 132 ]).scheduleCreate(); |
95 | 133 |
96 schedulePub(args: ['install'], | 134 schedulePub(args: ['install'], |
97 output: const RegExp(@"Dependencies installed!$")); | 135 output: const RegExp(@"Dependencies installed!$")); |
98 | 136 |
99 dir(appPath, [ | 137 dir(appPath, [ |
100 dir("example", [ | 138 dir("example", [ |
101 dir("packages", [ | 139 dir("packages", [ |
102 // TODO(rnystrom): Re-enable this when #4820 is fixed. | 140 dir("myapp", [ |
103 /* | 141 file('foo.dart', 'main() => "foo";') |
104 dir("myapp", [appPubspec([])]) | 142 ]) |
105 */ | |
106 ]), | 143 ]), |
107 dir("subexample", [ | 144 dir("subexample", [ |
108 dir("packages", [ | 145 dir("packages", [ |
109 // TODO(rnystrom): Re-enable this when #4820 is fixed. | 146 dir("myapp", [ |
110 /* | 147 file('foo.dart', 'main() => "foo";') |
111 dir("myapp", [appPubspec([])]) | 148 ]) |
112 */ | |
113 ]) | 149 ]) |
114 ]) | 150 ]) |
115 ]) | 151 ]) |
116 ]).scheduleValidate(); | 152 ]).scheduleValidate(); |
117 | 153 |
118 run(); | 154 run(); |
119 }); | 155 }); |
120 | 156 |
121 test('"bin/"', () { | 157 test('"bin/"', () { |
122 dir(appPath, [ | 158 dir(appPath, [ |
123 appPubspec([]), | 159 appPubspec([]), |
| 160 libDir('foo'), |
124 dir("bin") | 161 dir("bin") |
125 ]).scheduleCreate(); | 162 ]).scheduleCreate(); |
126 | 163 |
127 schedulePub(args: ['install'], | 164 schedulePub(args: ['install'], |
128 output: const RegExp(@"Dependencies installed!$")); | 165 output: const RegExp(@"Dependencies installed!$")); |
129 | 166 |
130 dir(appPath, [ | 167 dir(appPath, [ |
131 dir("bin", [ | 168 dir("bin", [ |
132 dir("packages", [ | 169 dir("packages", [ |
133 // TODO(rnystrom): Re-enable this when #4820 is fixed. | 170 dir("myapp", [ |
134 /* | 171 file('foo.dart', 'main() => "foo";') |
135 dir("myapp", [appPubspec([])]) | 172 ]) |
136 */ | |
137 ]) | 173 ]) |
138 ]) | 174 ]) |
139 ]).scheduleValidate(); | 175 ]).scheduleValidate(); |
140 | 176 |
141 run(); | 177 run(); |
142 }); | 178 }); |
143 }); | 179 }); |
| 180 |
| 181 // TODO(rnystrom): Remove this when old layout support is removed. (#4964) |
| 182 test('shows a warning if the entrypoint uses the old layout', () { |
| 183 // The symlink should use the name in the pubspec, not the name of the |
| 184 // directory. |
| 185 dir(appPath, [ |
| 186 pubspec({"name": "myapp_name"}), |
| 187 file("foo.dart", 'main() => "foo";'), |
| 188 ]).scheduleCreate(); |
| 189 |
| 190 schedulePub(args: ['install'], |
| 191 error: ''' |
| 192 Warning: Package "myapp_name" is using a deprecated layout. |
| 193 See http://www.dartlang.org/docs/pub-package-manager/package-layout.html
for details. |
| 194 ''', |
| 195 output: const RegExp(@"Dependencies installed!$")); |
| 196 |
| 197 run(); |
| 198 }); |
144 } | 199 } |
OLD | NEW |