OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 import 'package:pub/src/exit_codes.dart' as exit_codes; | 10 import 'package:pub/src/exit_codes.dart' as exit_codes; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 createPackagesFile(appPath, sandbox: ["foo"]); | 259 createPackagesFile(appPath, sandbox: ["foo"]); |
260 | 260 |
261 // Ensure that the pubspec looks newer than the lockfile. | 261 // Ensure that the pubspec looks newer than the lockfile. |
262 _touch("pubspec.lock"); | 262 _touch("pubspec.lock"); |
263 }); | 263 }); |
264 | 264 |
265 _requiresPubGet('The pubspec.lock file has changed since the .packages ' | 265 _requiresPubGet('The pubspec.lock file has changed since the .packages ' |
266 'file was generated, please run "pub get" again.'); | 266 'file was generated, please run "pub get" again.'); |
267 }); | 267 }); |
| 268 |
| 269 group("the lock file's SDK constraint doesn't match the current SDK", () { |
| 270 setUp(() { |
| 271 // Avoid using a path dependency because it triggers the full validation |
| 272 // logic. We want to be sure SDK-validation works without that logic. |
| 273 servePackages((builder) { |
| 274 builder.serve("foo", "3.0.0", pubspec: { |
| 275 "environment": {"sdk": ">=1.0.0 <2.0.0"} |
| 276 }); |
| 277 }); |
| 278 |
| 279 d.dir(appPath, [ |
| 280 d.appPubspec({"foo": "3.0.0"}) |
| 281 ]).create(); |
| 282 |
| 283 pubGet(environment: {"_PUB_TEST_SDK_VERSION": "1.2.3+4"}); |
| 284 }); |
| 285 |
| 286 _requiresPubGet("Dart 0.1.2+3 is incompatible with your dependencies' " |
| 287 "SDK constraints. Please run \"pub get\" again."); |
| 288 }); |
| 289 |
| 290 group("a path dependency's dependency doesn't match the lockfile", () { |
| 291 setUp(() { |
| 292 d.dir("bar", [ |
| 293 d.libPubspec("bar", "1.0.0", deps: {"foo": "1.0.0"}) |
| 294 ]).create(); |
| 295 |
| 296 d.dir(appPath, [ |
| 297 d.appPubspec({"foo": {"path": "../foo"}}) |
| 298 ]); |
| 299 |
| 300 pubGet(); |
| 301 |
| 302 // Update foo's pubspec without touching the app's. |
| 303 d.dir("bar", [ |
| 304 d.libPubspec("bar", "1.0.0", deps: {"foo": "2.0.0"}) |
| 305 ]).create(); |
| 306 }); |
| 307 }); |
268 }); | 308 }); |
269 | 309 |
270 group("doesn't require the user to run pub get first if", () { | 310 group("doesn't require the user to run pub get first if", () { |
271 group("the pubspec is older than the lockfile which is older than the " | 311 group("the pubspec is older than the lockfile which is older than the " |
272 "packages file, even if the contents are wrong", () { | 312 "packages file, even if the contents are wrong", () { |
273 setUp(() { | 313 setUp(() { |
274 d.dir(appPath, [ | 314 d.dir(appPath, [ |
275 d.appPubspec({"foo": "1.0.0"}) | 315 d.appPubspec({"foo": "1.0.0"}) |
276 ]).create(); | 316 ]).create(); |
277 | 317 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 void _touch(String path) { | 413 void _touch(String path) { |
374 schedule(() async { | 414 schedule(() async { |
375 // Delay a bit to make sure the modification times are noticeably different. | 415 // Delay a bit to make sure the modification times are noticeably different. |
376 // 1s seems to be the finest granularity that dart:io reports. | 416 // 1s seems to be the finest granularity that dart:io reports. |
377 await new Future.delayed(new Duration(seconds: 1)); | 417 await new Future.delayed(new Duration(seconds: 1)); |
378 | 418 |
379 path = p.join(sandboxDir, "myapp", path); | 419 path = p.join(sandboxDir, "myapp", path); |
380 touch(path); | 420 touch(path); |
381 }, "touching $path"); | 421 }, "touching $path"); |
382 } | 422 } |
OLD | NEW |