| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #library('pub_tests'); | |
| 6 | |
| 7 #import('dart:io'); | |
| 8 | |
| 9 #import('test_pub.dart'); | |
| 10 #import('../../../pkg/unittest/unittest.dart'); | |
| 11 | |
| 12 main() { | |
| 13 group('requires', () { | |
| 14 test('a pubspec', () { | |
| 15 dir(appPath, []).scheduleCreate(); | |
| 16 | |
| 17 schedulePub(args: ['install'], | |
| 18 error: const RegExp(r'^Could not find a file named "pubspec\.yaml"'), | |
| 19 exitCode: 1); | |
| 20 | |
| 21 run(); | |
| 22 }); | |
| 23 | |
| 24 test('a pubspec with a "name" key', () { | |
| 25 dir(appPath, [ | |
| 26 pubspec({"dependencies": {"foo": null}}) | |
| 27 ]).scheduleCreate(); | |
| 28 | |
| 29 schedulePub(args: ['install'], | |
| 30 error: const RegExp(r'^pubspec.yaml is missing the required "name" ' | |
| 31 r'field \(e\.g\. "name: myapp"\)\.'), | |
| 32 exitCode: 1); | |
| 33 | |
| 34 run(); | |
| 35 }); | |
| 36 }); | |
| 37 | |
| 38 test('adds itself to the packages', () { | |
| 39 // The symlink should use the name in the pubspec, not the name of the | |
| 40 // directory. | |
| 41 dir(appPath, [ | |
| 42 pubspec({"name": "myapp_name"}), | |
| 43 libDir('foo'), | |
| 44 ]).scheduleCreate(); | |
| 45 | |
| 46 schedulePub(args: ['install'], | |
| 47 output: const RegExp(r"Dependencies installed!$")); | |
| 48 | |
| 49 dir(packagesPath, [ | |
| 50 dir("myapp_name", [ | |
| 51 file('foo.dart', 'main() => "foo";') | |
| 52 ]) | |
| 53 ]).scheduleValidate(); | |
| 54 | |
| 55 run(); | |
| 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(r"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 libPubspec('foo', '0.0.0-not.used') | |
| 82 ]) | |
| 83 ]) | |
| 84 ]).scheduleCreate(); | |
| 85 | |
| 86 dir(appPath, [ | |
| 87 pubspec({"name": "myapp", "dependencies": {"foo": {"sdk": "foo"}}}) | |
| 88 ]).scheduleCreate(); | |
| 89 | |
| 90 schedulePub(args: ['install'], | |
| 91 error: const RegExp(r'Warning: Package "foo" does not have a "lib" ' | |
| 92 'directory.'), | |
| 93 output: const RegExp(r"Dependencies installed!$")); | |
| 94 | |
| 95 run(); | |
| 96 }); | |
| 97 | |
| 98 test('does not warn if the root package lacks a "lib" directory', () { | |
| 99 dir(appPath, [ | |
| 100 appPubspec([]) | |
| 101 ]).scheduleCreate(); | |
| 102 | |
| 103 schedulePub(args: ['install'], | |
| 104 error: '', | |
| 105 output: const RegExp(r"Dependencies installed!$")); | |
| 106 | |
| 107 run(); | |
| 108 }); | |
| 109 | |
| 110 test('overwrites the existing packages directory', () { | |
| 111 dir(appPath, [ | |
| 112 appPubspec([]), | |
| 113 dir('packages', [ | |
| 114 dir('foo'), | |
| 115 dir('myapp'), | |
| 116 ]), | |
| 117 libDir('myapp') | |
| 118 ]).scheduleCreate(); | |
| 119 | |
| 120 schedulePub(args: ['install'], | |
| 121 output: const RegExp(r"Dependencies installed!$")); | |
| 122 | |
| 123 dir(packagesPath, [ | |
| 124 nothing('foo'), | |
| 125 dir('myapp', [file('myapp.dart', 'main() => "myapp";')]) | |
| 126 ]).scheduleValidate(); | |
| 127 | |
| 128 run(); | |
| 129 }); | |
| 130 | |
| 131 group('creates a packages directory in', () { | |
| 132 test('"test/" and its subdirectories', () { | |
| 133 dir(appPath, [ | |
| 134 appPubspec([]), | |
| 135 libDir('foo'), | |
| 136 dir("test", [dir("subtest")]) | |
| 137 ]).scheduleCreate(); | |
| 138 | |
| 139 schedulePub(args: ['install'], | |
| 140 output: const RegExp(r"Dependencies installed!$")); | |
| 141 | |
| 142 dir(appPath, [ | |
| 143 dir("test", [ | |
| 144 dir("packages", [ | |
| 145 dir("myapp", [ | |
| 146 file('foo.dart', 'main() => "foo";') | |
| 147 ]) | |
| 148 ]), | |
| 149 dir("subtest", [ | |
| 150 dir("packages", [ | |
| 151 dir("myapp", [ | |
| 152 file('foo.dart', 'main() => "foo";') | |
| 153 ]) | |
| 154 ]) | |
| 155 ]) | |
| 156 ]) | |
| 157 ]).scheduleValidate(); | |
| 158 | |
| 159 run(); | |
| 160 }); | |
| 161 | |
| 162 test('"example/" and its subdirectories', () { | |
| 163 dir(appPath, [ | |
| 164 appPubspec([]), | |
| 165 libDir('foo'), | |
| 166 dir("example", [dir("subexample")]) | |
| 167 ]).scheduleCreate(); | |
| 168 | |
| 169 schedulePub(args: ['install'], | |
| 170 output: const RegExp(r"Dependencies installed!$")); | |
| 171 | |
| 172 dir(appPath, [ | |
| 173 dir("example", [ | |
| 174 dir("packages", [ | |
| 175 dir("myapp", [ | |
| 176 file('foo.dart', 'main() => "foo";') | |
| 177 ]) | |
| 178 ]), | |
| 179 dir("subexample", [ | |
| 180 dir("packages", [ | |
| 181 dir("myapp", [ | |
| 182 file('foo.dart', 'main() => "foo";') | |
| 183 ]) | |
| 184 ]) | |
| 185 ]) | |
| 186 ]) | |
| 187 ]).scheduleValidate(); | |
| 188 | |
| 189 run(); | |
| 190 }); | |
| 191 | |
| 192 test('"web/" and its subdirectories', () { | |
| 193 dir(appPath, [ | |
| 194 appPubspec([]), | |
| 195 libDir('foo'), | |
| 196 dir("web", [dir("subweb")]) | |
| 197 ]).scheduleCreate(); | |
| 198 | |
| 199 schedulePub(args: ['install'], | |
| 200 output: const RegExp(r"Dependencies installed!$")); | |
| 201 | |
| 202 dir(appPath, [ | |
| 203 dir("web", [ | |
| 204 dir("packages", [ | |
| 205 dir("myapp", [ | |
| 206 file('foo.dart', 'main() => "foo";') | |
| 207 ]) | |
| 208 ]), | |
| 209 dir("subweb", [ | |
| 210 dir("packages", [ | |
| 211 dir("myapp", [ | |
| 212 file('foo.dart', 'main() => "foo";') | |
| 213 ]) | |
| 214 ]) | |
| 215 ]) | |
| 216 ]) | |
| 217 ]).scheduleValidate(); | |
| 218 | |
| 219 run(); | |
| 220 }); | |
| 221 | |
| 222 test('"bin/"', () { | |
| 223 dir(appPath, [ | |
| 224 appPubspec([]), | |
| 225 libDir('foo'), | |
| 226 dir("bin") | |
| 227 ]).scheduleCreate(); | |
| 228 | |
| 229 schedulePub(args: ['install'], | |
| 230 output: const RegExp(r"Dependencies installed!$")); | |
| 231 | |
| 232 dir(appPath, [ | |
| 233 dir("bin", [ | |
| 234 dir("packages", [ | |
| 235 dir("myapp", [ | |
| 236 file('foo.dart', 'main() => "foo";') | |
| 237 ]) | |
| 238 ]) | |
| 239 ]) | |
| 240 ]).scheduleValidate(); | |
| 241 | |
| 242 run(); | |
| 243 }); | |
| 244 }); | |
| 245 | |
| 246 // TODO(rnystrom): Remove this when old layout support is removed. (#4964) | |
| 247 test('shows a warning if the entrypoint uses the old layout', () { | |
| 248 // The symlink should use the name in the pubspec, not the name of the | |
| 249 // directory. | |
| 250 dir(appPath, [ | |
| 251 pubspec({"name": "myapp_name"}), | |
| 252 file("foo.dart", 'main() => "foo";'), | |
| 253 ]).scheduleCreate(); | |
| 254 | |
| 255 schedulePub(args: ['install'], | |
| 256 error: ''' | |
| 257 Warning: Package "myapp_name" is using a deprecated layout. | |
| 258 See http://www.dartlang.org/docs/pub-package-manager/package-layout.html
for details. | |
| 259 ''', | |
| 260 output: const RegExp(r"Dependencies installed!$")); | |
| 261 | |
| 262 run(); | |
| 263 }); | |
| 264 } | |
| OLD | NEW |