Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: test/must_pub_get_test.dart

Issue 2165423002: Add support for Flutter SDK constraints. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/lock_file_test.dart ('k') | test/pubspec_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:io'; 6 import 'dart:io';
7 7
8 import 'package:path/path.dart' as p; 8 import 'package:path/path.dart' as p;
9 import 'package:pub/src/exit_codes.dart' as exit_codes; 9 import 'package:pub/src/exit_codes.dart' as exit_codes;
10 import 'package:pub/src/io.dart'; 10 import 'package:pub/src/io.dart';
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 d.appPubspec({"foo": "3.0.0"}) 279 d.appPubspec({"foo": "3.0.0"})
280 ]).create(); 280 ]).create();
281 281
282 pubGet(environment: {"_PUB_TEST_SDK_VERSION": "1.2.3+4"}); 282 pubGet(environment: {"_PUB_TEST_SDK_VERSION": "1.2.3+4"});
283 }); 283 });
284 284
285 _requiresPubGet("Dart 0.1.2+3 is incompatible with your dependencies' " 285 _requiresPubGet("Dart 0.1.2+3 is incompatible with your dependencies' "
286 "SDK constraints. Please run \"pub get\" again."); 286 "SDK constraints. Please run \"pub get\" again.");
287 }); 287 });
288 288
289 integration("the lock file's Flutter SDK constraint doesn't match the "
290 "current Flutter SDK", () {
291 // Avoid using a path dependency because it triggers the full validation
292 // logic. We want to be sure SDK-validation works without that logic.
293 globalPackageServer.add((builder) {
294 builder.serve("foo", "3.0.0", pubspec: {
295 "environment": {"flutter": ">=1.0.0 <2.0.0"}
296 });
297 });
298
299 d.dir('flutter', [
300 d.file('version', '1.2.3')
301 ]).create();
302
303 d.dir(appPath, [
304 d.appPubspec({"foo": "3.0.0"})
305 ]).create();
306
307 pubGet(environment: {"FLUTTER_ROOT": p.join(sandboxDir, 'flutter')});
308
309 d.dir('flutter', [
310 d.file('version', '2.4.6')
311 ]).create();
312
313 // Run pub manually here because otherwise we don't have access to
314 // sandboxDir.
315 schedulePub(
316 args: ["run", "script"],
317 environment: {"FLUTTER_ROOT": p.join(sandboxDir, 'flutter')},
318 error: "Flutter 2.4.6 is incompatible with your dependencies' SDK "
319 "constraints. Please run \"pub get\" again.",
320 exitCode: exit_codes.DATA);
321 });
322
289 group("a path dependency's dependency doesn't match the lockfile", () { 323 group("a path dependency's dependency doesn't match the lockfile", () {
290 setUp(() { 324 setUp(() {
291 d.dir("bar", [ 325 d.dir("bar", [
292 d.libPubspec("bar", "1.0.0", deps: {"foo": "1.0.0"}) 326 d.libPubspec("bar", "1.0.0", deps: {"foo": "1.0.0"})
293 ]).create(); 327 ]).create();
294 328
295 d.dir(appPath, [ 329 d.dir(appPath, [
296 d.appPubspec({"bar": {"path": "../bar"}}) 330 d.appPubspec({"bar": {"path": "../bar"}})
297 ]).create(); 331 ]).create();
298 332
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 }) 421 })
388 ]).create(); 422 ]).create();
389 423
390 pubGet(); 424 pubGet();
391 425
392 _touch("pubspec.lock"); 426 _touch("pubspec.lock");
393 }); 427 });
394 428
395 _runsSuccessfully(); 429 _runsSuccessfully();
396 }); 430 });
431
432 integration("the lock file has a Flutter SDK but Flutter is unavailable",
433 () {
434 // Avoid using a path dependency because it triggers the full validation
435 // logic. We want to be sure SDK-validation works without that logic.
436 globalPackageServer.add((builder) {
437 builder.serve("foo", "3.0.0", pubspec: {
438 "environment": {"flutter": ">=1.0.0 <2.0.0"}
439 });
440 });
441
442 d.dir('flutter', [
443 d.file('version', '1.2.3')
444 ]).create();
445
446 d.dir(appPath, [
447 d.appPubspec({"foo": "3.0.0"})
448 ]).create();
449
450 pubGet(environment: {"FLUTTER_ROOT": p.join(sandboxDir, 'flutter')});
451
452 d.dir('flutter', [
453 d.file('version', '2.4.6')
454 ]).create();
455
456 // Run pub manually here because otherwise we don't have access to
457 // sandboxDir.
458 schedulePub(args: ["run", "bin/script.dart"]);
459 });
397 }); 460 });
398 } 461 }
399 462
400 /// Runs every command that care about the world being up-to-date, and asserts 463 /// Runs every command that care about the world being up-to-date, and asserts
401 /// that it prints [message] as part of its error. 464 /// that it prints [message] as part of its error.
465 ///
466 /// If [environment] is passed, it's called to produce a map that's merged into
467 /// the OS environment for the pub commands.
402 void _requiresPubGet(String message) { 468 void _requiresPubGet(String message) {
403 for (var command in ["build", "serve", "run", "deps"]) { 469 for (var command in ["build", "serve", "run", "deps"]) {
404 integration("for pub $command", () { 470 integration("for pub $command", () {
405 var args = [command]; 471 var args = [command];
406 if (command == "run") args.add("script"); 472 if (command == "run") args.add("script");
407 473
408 schedulePub( 474 schedulePub(
409 args: args, 475 args: args,
410 error: contains(message), 476 error: contains(message),
411 exitCode: exit_codes.DATA); 477 exitCode: exit_codes.DATA);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 void _touch(String path) { 524 void _touch(String path) {
459 schedule(() async { 525 schedule(() async {
460 // Delay a bit to make sure the modification times are noticeably different. 526 // Delay a bit to make sure the modification times are noticeably different.
461 // 1s seems to be the finest granularity that dart:io reports. 527 // 1s seems to be the finest granularity that dart:io reports.
462 await new Future.delayed(new Duration(seconds: 1)); 528 await new Future.delayed(new Duration(seconds: 1));
463 529
464 path = p.join(sandboxDir, "myapp", path); 530 path = p.join(sandboxDir, "myapp", path);
465 touch(path); 531 touch(path);
466 }, "touching $path"); 532 }, "touching $path");
467 } 533 }
OLDNEW
« no previous file with comments | « test/lock_file_test.dart ('k') | test/pubspec_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698