| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS d.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 d.file. | |
| 4 | |
| 5 library pub_tests; | |
| 6 | |
| 7 import 'dart:io'; | |
| 8 | |
| 9 import 'package:pathos/path.dart' as path; | |
| 10 import 'package:scheduled_test/scheduled_test.dart'; | |
| 11 | |
| 12 import '../../../pub/io.dart'; | |
| 13 import '../descriptor.dart' as d; | |
| 14 import '../test_pub.dart'; | |
| 15 | |
| 16 main() { | |
| 17 initConfig(); | |
| 18 group('requires', () { | |
| 19 integration('a pubspec', () { | |
| 20 d.dir(appPath, []).create(); | |
| 21 | |
| 22 schedulePub(args: ['install'], | |
| 23 error: new RegExp(r'^Could not find a file named "pubspec\.yaml"'), | |
| 24 exitCode: 1); | |
| 25 }); | |
| 26 | |
| 27 integration('a pubspec with a "name" key', () { | |
| 28 d.dir(appPath, [ | |
| 29 d.pubspec({"dependencies": {"foo": null}}) | |
| 30 ]).create(); | |
| 31 | |
| 32 schedulePub(args: ['install'], | |
| 33 error: new RegExp(r'^pubspec.yaml is missing the required "name" ' | |
| 34 r'field \(e\.g\. "name: myapp"\)\.'), | |
| 35 exitCode: 1); | |
| 36 }); | |
| 37 }); | |
| 38 | |
| 39 integration('adds itself to the packages', () { | |
| 40 // The symlink should use the name in the pubspec, not the name of the | |
| 41 // directory. | |
| 42 d.dir(appPath, [ | |
| 43 d.pubspec({"name": "myapp_name"}), | |
| 44 d.libDir('foo'), | |
| 45 ]).create(); | |
| 46 | |
| 47 schedulePub(args: ['install'], | |
| 48 output: new RegExp(r"Dependencies installed!$")); | |
| 49 | |
| 50 d.dir(packagesPath, [ | |
| 51 d.dir("myapp_name", [ | |
| 52 d.file('foo.dart', 'main() => "foo";') | |
| 53 ]) | |
| 54 ]).validate(); | |
| 55 }); | |
| 56 | |
| 57 integration('does not add itself to the packages if it has no "lib" directory'
, () { | |
| 58 // The symlink should use the name in the pubspec, not the name of the | |
| 59 // directory. | |
| 60 d.dir(appPath, [ | |
| 61 d.pubspec({"name": "myapp_name"}), | |
| 62 ]).create(); | |
| 63 | |
| 64 schedulePub(args: ['install'], | |
| 65 output: new RegExp(r"Dependencies installed!$")); | |
| 66 | |
| 67 d.dir(packagesPath, [ | |
| 68 d.nothing("myapp_name") | |
| 69 ]).validate(); | |
| 70 }); | |
| 71 | |
| 72 integration('does not add a package if it does not have a "lib" directory', ()
{ | |
| 73 // Using a path source, but this should be true of all sources. | |
| 74 d.dir('foo', [ | |
| 75 d.libPubspec('foo', '0.0.0-not.used') | |
| 76 ]).create(); | |
| 77 | |
| 78 d.dir(appPath, [ | |
| 79 d.pubspec({"name": "myapp", "dependencies": {"foo": {"path": "../foo"}}}) | |
| 80 ]).create(); | |
| 81 | |
| 82 schedulePub(args: ['install'], | |
| 83 error: new RegExp(r'Warning: Package "foo" does not have a "lib" ' | |
| 84 'directory so you will not be able to import any libraries from ' | |
| 85 'it.'), | |
| 86 output: new RegExp(r"Dependencies installed!$")); | |
| 87 }); | |
| 88 | |
| 89 integration('reports a solver failure', () { | |
| 90 // myapp depends on foo and bar which both depend on baz with mismatched | |
| 91 // descriptions. | |
| 92 d.dir('deps', [ | |
| 93 d.dir('foo', [ | |
| 94 d.pubspec({"name": "foo", "dependencies": { | |
| 95 "baz": {"path": "../baz1"} | |
| 96 }}) | |
| 97 ]), | |
| 98 d.dir('bar', [ | |
| 99 d.pubspec({"name": "bar", "dependencies": { | |
| 100 "baz": {"path": "../baz2"} | |
| 101 }}) | |
| 102 ]), | |
| 103 d.dir('baz1', [ | |
| 104 d.libPubspec('baz', '0.0.0') | |
| 105 ]), | |
| 106 d.dir('baz2', [ | |
| 107 d.libPubspec('baz', '0.0.0') | |
| 108 ]) | |
| 109 ]).create(); | |
| 110 | |
| 111 d.dir(appPath, [ | |
| 112 d.pubspec({"name": "myapp", "dependencies": { | |
| 113 "foo": {"path": "../deps/foo"}, | |
| 114 "bar": {"path": "../deps/bar"} | |
| 115 }}) | |
| 116 ]).create(); | |
| 117 | |
| 118 schedulePub(args: ['install'], | |
| 119 error: new RegExp(r"^Incompatible dependencies on 'baz':"), | |
| 120 exitCode: 1); | |
| 121 }); | |
| 122 | |
| 123 integration('does not warn if the root package lacks a "lib" directory', () { | |
| 124 d.dir(appPath, [ | |
| 125 d.appPubspec([]) | |
| 126 ]).create(); | |
| 127 | |
| 128 schedulePub(args: ['install'], | |
| 129 error: new RegExp(r'^\s*$'), | |
| 130 output: new RegExp(r"Dependencies installed!$")); | |
| 131 }); | |
| 132 | |
| 133 integration('overwrites the existing packages directory', () { | |
| 134 d.dir(appPath, [ | |
| 135 d.appPubspec([]), | |
| 136 d.dir('packages', [ | |
| 137 d.dir('foo'), | |
| 138 d.dir('myapp'), | |
| 139 ]), | |
| 140 d.libDir('myapp') | |
| 141 ]).create(); | |
| 142 | |
| 143 schedulePub(args: ['install'], | |
| 144 output: new RegExp(r"Dependencies installed!$")); | |
| 145 | |
| 146 d.dir(packagesPath, [ | |
| 147 d.nothing('foo'), | |
| 148 d.dir('myapp', [d.file('myapp.dart', 'main() => "myapp";')]) | |
| 149 ]).validate(); | |
| 150 }); | |
| 151 | |
| 152 integration('overwrites a broken packages directory symlink', () { | |
| 153 d.dir(appPath, [ | |
| 154 d.appPubspec([]), | |
| 155 d.dir('packages'), | |
| 156 d.libDir('myapp'), | |
| 157 d.dir('bin') | |
| 158 ]).create(); | |
| 159 | |
| 160 scheduleSymlink( | |
| 161 path.join(appPath, 'packages'), | |
| 162 path.join(appPath, 'bin', 'packages')); | |
| 163 | |
| 164 schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'packages'))); | |
| 165 | |
| 166 schedulePub(args: ['install'], | |
| 167 output: new RegExp(r"Dependencies installed!$")); | |
| 168 | |
| 169 d.dir(packagesPath, [ | |
| 170 d.nothing('foo'), | |
| 171 d.dir('myapp', [d.file('myapp.dart', 'main() => "myapp";')]) | |
| 172 ]).validate(); | |
| 173 }); | |
| 174 | |
| 175 group('creates a packages directory in', () { | |
| 176 integration('"test/" and its subdirectories', () { | |
| 177 d.dir(appPath, [ | |
| 178 d.appPubspec([]), | |
| 179 d.libDir('foo'), | |
| 180 d.dir("test", [d.dir("subtest")]) | |
| 181 ]).create(); | |
| 182 | |
| 183 schedulePub(args: ['install'], | |
| 184 output: new RegExp(r"Dependencies installed!$")); | |
| 185 | |
| 186 d.dir(appPath, [ | |
| 187 d.dir("test", [ | |
| 188 d.dir("packages", [ | |
| 189 d.dir("myapp", [ | |
| 190 d.file('foo.dart', 'main() => "foo";') | |
| 191 ]) | |
| 192 ]), | |
| 193 d.dir("subtest", [ | |
| 194 d.dir("packages", [ | |
| 195 d.dir("myapp", [ | |
| 196 d.file('foo.dart', 'main() => "foo";') | |
| 197 ]) | |
| 198 ]) | |
| 199 ]) | |
| 200 ]) | |
| 201 ]).validate(); | |
| 202 }); | |
| 203 | |
| 204 integration('"example/" and its subdirectories', () { | |
| 205 d.dir(appPath, [ | |
| 206 d.appPubspec([]), | |
| 207 d.libDir('foo'), | |
| 208 d.dir("example", [d.dir("subexample")]) | |
| 209 ]).create(); | |
| 210 | |
| 211 schedulePub(args: ['install'], | |
| 212 output: new RegExp(r"Dependencies installed!$")); | |
| 213 | |
| 214 d.dir(appPath, [ | |
| 215 d.dir("example", [ | |
| 216 d.dir("packages", [ | |
| 217 d.dir("myapp", [ | |
| 218 d.file('foo.dart', 'main() => "foo";') | |
| 219 ]) | |
| 220 ]), | |
| 221 d.dir("subexample", [ | |
| 222 d.dir("packages", [ | |
| 223 d.dir("myapp", [ | |
| 224 d.file('foo.dart', 'main() => "foo";') | |
| 225 ]) | |
| 226 ]) | |
| 227 ]) | |
| 228 ]) | |
| 229 ]).validate(); | |
| 230 }); | |
| 231 | |
| 232 integration('"tool/" and its subdirectories', () { | |
| 233 d.dir(appPath, [ | |
| 234 d.appPubspec([]), | |
| 235 d.libDir('foo'), | |
| 236 d.dir("tool", [d.dir("subtool")]) | |
| 237 ]).create(); | |
| 238 | |
| 239 schedulePub(args: ['install'], | |
| 240 output: new RegExp(r"Dependencies installed!$")); | |
| 241 | |
| 242 d.dir(appPath, [ | |
| 243 d.dir("tool", [ | |
| 244 d.dir("packages", [ | |
| 245 d.dir("myapp", [ | |
| 246 d.file('foo.dart', 'main() => "foo";') | |
| 247 ]) | |
| 248 ]), | |
| 249 d.dir("subtool", [ | |
| 250 d.dir("packages", [ | |
| 251 d.dir("myapp", [ | |
| 252 d.file('foo.dart', 'main() => "foo";') | |
| 253 ]) | |
| 254 ]) | |
| 255 ]) | |
| 256 ]) | |
| 257 ]).validate(); | |
| 258 }); | |
| 259 | |
| 260 integration('"web/" and its subdirectories', () { | |
| 261 d.dir(appPath, [ | |
| 262 d.appPubspec([]), | |
| 263 d.libDir('foo'), | |
| 264 d.dir("web", [d.dir("subweb")]) | |
| 265 ]).create(); | |
| 266 | |
| 267 schedulePub(args: ['install'], | |
| 268 output: new RegExp(r"Dependencies installed!$")); | |
| 269 | |
| 270 d.dir(appPath, [ | |
| 271 d.dir("web", [ | |
| 272 d.dir("packages", [ | |
| 273 d.dir("myapp", [ | |
| 274 d.file('foo.dart', 'main() => "foo";') | |
| 275 ]) | |
| 276 ]), | |
| 277 d.dir("subweb", [ | |
| 278 d.dir("packages", [ | |
| 279 d.dir("myapp", [ | |
| 280 d.file('foo.dart', 'main() => "foo";') | |
| 281 ]) | |
| 282 ]) | |
| 283 ]) | |
| 284 ]) | |
| 285 ]).validate(); | |
| 286 }); | |
| 287 | |
| 288 integration('"bin/"', () { | |
| 289 d.dir(appPath, [ | |
| 290 d.appPubspec([]), | |
| 291 d.libDir('foo'), | |
| 292 d.dir("bin") | |
| 293 ]).create(); | |
| 294 | |
| 295 schedulePub(args: ['install'], | |
| 296 output: new RegExp(r"Dependencies installed!$")); | |
| 297 | |
| 298 d.dir(appPath, [ | |
| 299 d.dir("bin", [ | |
| 300 d.dir("packages", [ | |
| 301 d.dir("myapp", [ | |
| 302 d.file('foo.dart', 'main() => "foo";') | |
| 303 ]) | |
| 304 ]) | |
| 305 ]) | |
| 306 ]).validate(); | |
| 307 }); | |
| 308 }); | |
| 309 } | |
| OLD | NEW |