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

Side by Side Diff: test/must_pub_get_test.dart

Issue 1282533003: Don't implicitly run "pub get". (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 5 years, 4 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/run/allows_dart_extension_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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6 import 'dart:convert';
7
8 import 'package:path/path.dart' as p;
9 import 'package:pub/src/exit_codes.dart' as exit_codes;
10 import 'package:pub/src/io.dart';
11 import 'package:scheduled_test/scheduled_test.dart';
12
13 import 'descriptor.dart' as d;
14 import 'test_pub.dart';
15
16 main() {
17 group("requires the user to run pub get first if", () {
18 setUp(() {
19 d.dir(appPath, [
20 d.appPubspec(),
21 d.dir("web", []),
22 d.dir("bin", [
23 d.file("script.dart", "main() => print('hello!');")
24 ])
25 ]).create();
26
27 pubGet();
28
29 // Delay a bit to make sure the modification times are noticeably
30 // different. 1s seems to be the finest granularity that dart:io reports.
31 schedule(() => new Future.delayed(new Duration(seconds: 1)));
32 });
33
34 group("there's no lockfile", () {
35 setUp(() {
36 schedule(() => deleteEntry(p.join(sandboxDir, "myapp/pubspec.lock")));
37 });
38
39 _forEveryCommand(
40 'No pubspec.lock file found, please run "pub get" first.');
41 });
42
43 group("there's no package spec", () {
44 setUp(() {
45 schedule(() => deleteEntry(p.join(sandboxDir, "myapp/.packages")));
46 });
47
48 _forEveryCommand('No .packages file found, please run "pub get" first.');
49 });
50
51 group("the pubspec is newer than the package spec", () {
52 setUp(() {
53 schedule(() => _touch("pubspec.yaml"));
54 });
55
56 _forEveryCommand('The pubspec.yaml file has changed since the .packages '
57 'file was generated, please run "pub get" again.');
58 });
59
60 group("the lockfile is newer than the package spec", () {
61 setUp(() {
62 schedule(() => _touch("pubspec.lock"));
63 });
64
65 _forEveryCommand('The pubspec.lock file has changed since the .packages '
66 'file was generated, please run "pub get" again.');
67 });
68 });
69 }
70
71 /// Runs every command that care about the world being up-to-date, and asserts
72 /// that it prints [message] as part of its error.
73 void _forEveryCommand(String message) {
74 for (var command in ["build", "serve", "run", "deps"]) {
75 integration("for pub $command", () {
76 var args = [command];
77 if (command == "run") args.add("script");
78
79 var output;
80 var error;
81 if (command == "list-package-dirs") {
82 output = contains(JSON.encode(message));
83 } else {
84 error = contains(message);
85 }
86
87 schedulePub(
88 args: args,
89 output: output,
90 error: error,
91 exitCode: exit_codes.DATA);
92 });
93 }
94 }
95
96 void _touch(String path) {
97 path = p.join(sandboxDir, "myapp", path);
98 writeTextFile(path, readTextFile(path) + " ");
99 }
OLDNEW
« no previous file with comments | « test/lock_file_test.dart ('k') | test/run/allows_dart_extension_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698