| 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 '../../lib/src/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 for (var dir in ["benchmark", "example", "test", "tool", "web"]) { | |
| 177 integration('"$dir/" and its subdirectories', () { | |
| 178 d.dir(appPath, [ | |
| 179 d.appPubspec([]), | |
| 180 d.libDir('foo'), | |
| 181 d.dir(dir, [d.dir("sub${dir}")]) | |
| 182 ]).create(); | |
| 183 | |
| 184 schedulePub(args: ['install'], | |
| 185 output: new RegExp(r"Dependencies installed!$")); | |
| 186 | |
| 187 d.dir(appPath, [ | |
| 188 d.dir(dir, [ | |
| 189 d.dir("packages", [ | |
| 190 d.dir("myapp", [ | |
| 191 d.file('foo.dart', 'main() => "foo";') | |
| 192 ]) | |
| 193 ]), | |
| 194 d.dir("sub${dir}", [ | |
| 195 d.dir("packages", [ | |
| 196 d.dir("myapp", [ | |
| 197 d.file('foo.dart', 'main() => "foo";') | |
| 198 ]) | |
| 199 ]) | |
| 200 ]) | |
| 201 ]) | |
| 202 ]).validate(); | |
| 203 }); | |
| 204 } | |
| 205 | |
| 206 integration('"bin/"', () { | |
| 207 d.dir(appPath, [ | |
| 208 d.appPubspec([]), | |
| 209 d.libDir('foo'), | |
| 210 d.dir("bin") | |
| 211 ]).create(); | |
| 212 | |
| 213 schedulePub(args: ['install'], | |
| 214 output: new RegExp(r"Dependencies installed!$")); | |
| 215 | |
| 216 d.dir(appPath, [ | |
| 217 d.dir("bin", [ | |
| 218 d.dir("packages", [ | |
| 219 d.dir("myapp", [ | |
| 220 d.file('foo.dart', 'main() => "foo";') | |
| 221 ]) | |
| 222 ]) | |
| 223 ]) | |
| 224 ]).validate(); | |
| 225 }); | |
| 226 }); | |
| 227 } | |
| OLD | NEW |