OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, 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 library pub_tests; | |
6 | |
7 import 'dart:io'; | |
8 | |
9 import 'package:scheduled_test/scheduled_test.dart'; | |
10 | |
11 import 'descriptor.dart' as d; | |
12 import 'test_pub.dart'; | |
13 | |
14 final USAGE_STRING = """ | |
15 Pub is a package manager for Dart. | |
16 | |
17 Usage: pub command [arguments] | |
18 | |
19 Global options: | |
20 -h, --help Print this usage information. | |
21 --version Print pub version. | |
22 --[no-]trace Print debugging information when an error occurs. | |
23 --verbosity Control output verbosity. | |
24 | |
25 [all] Show all output including internal tracing messages. | |
26 [io] Also show IO operations. | |
27 [normal] Show errors, warnings, and user messages. | |
28 [solver] Show steps during version resolution. | |
29 | |
30 -v, --verbose Shortcut for "--verbosity=all" | |
31 | |
32 Available commands: | |
33 cache Inspect the system cache. | |
34 help Display help information for Pub. | |
35 install Install the current package's dependencies. | |
36 publish Publish the current package to pub.dartlang.org. | |
37 update Update the current package's dependencies to the latest version
s. | |
38 uploader Manage uploaders for a package on pub.dartlang.org. | |
39 version Print pub version. | |
40 | |
41 Use "pub help [command]" for more information about a command. | |
42 """; | |
43 | |
44 final VERSION_STRING = ''' | |
45 Pub 0.1.2+3 | |
46 '''; | |
47 | |
48 main() { | |
49 initConfig(); | |
50 | |
51 integration('running pub with no command displays usage', () { | |
52 schedulePub(args: [], output: USAGE_STRING); | |
53 }); | |
54 | |
55 integration('running pub with just --help displays usage', () { | |
56 schedulePub(args: ['--help'], output: USAGE_STRING); | |
57 }); | |
58 | |
59 integration('running pub with just -h displays usage', () { | |
60 schedulePub(args: ['-h'], output: USAGE_STRING); | |
61 }); | |
62 | |
63 integration('running pub with just --version displays version', () { | |
64 schedulePub(args: ['--version'], output: VERSION_STRING); | |
65 }); | |
66 | |
67 integration('an unknown command displays an error message', () { | |
68 schedulePub(args: ['quylthulg'], | |
69 error: ''' | |
70 Could not find a command named "quylthulg". | |
71 Run "pub help" to see available commands. | |
72 ''', | |
73 exitCode: 64); | |
74 }); | |
75 | |
76 integration('an unknown option displays an error message', () { | |
77 schedulePub(args: ['--blorf'], | |
78 error: ''' | |
79 Could not find an option named "blorf". | |
80 Run "pub help" to see available options. | |
81 ''', | |
82 exitCode: 64); | |
83 }); | |
84 | |
85 integration('an unknown command option displays an error message', () { | |
86 // TODO(rnystrom): When pub has command-specific options, a more precise | |
87 // error message would be good here. | |
88 schedulePub(args: ['version', '--blorf'], | |
89 error: ''' | |
90 Could not find an option named "blorf". | |
91 Use "pub help" for more information. | |
92 ''', | |
93 exitCode: 64); | |
94 }); | |
95 | |
96 group('help', () { | |
97 integration('shows help for a command', () { | |
98 schedulePub(args: ['help', 'install'], | |
99 output: ''' | |
100 Install the current package's dependencies. | |
101 | |
102 Usage: pub install | |
103 '''); | |
104 }); | |
105 | |
106 integration('shows help for a command', () { | |
107 schedulePub(args: ['help', 'publish'], | |
108 output: ''' | |
109 Publish the current package to pub.dartlang.org. | |
110 | |
111 Usage: pub publish [options] | |
112 -n, --dry-run Validate but do not publish the package
| |
113 -f, --force Publish without confirmation if there are no errors | |
114 --server The package server to which to upload this package | |
115 (defaults to "https://pub.dartlang.org") | |
116 '''); | |
117 }); | |
118 | |
119 integration('an unknown help command displays an error message', () { | |
120 schedulePub(args: ['help', 'quylthulg'], | |
121 error: ''' | |
122 Could not find a command named "quylthulg". | |
123 Run "pub help" to see available commands. | |
124 ''', | |
125 exitCode: 64); | |
126 }); | |
127 | |
128 }); | |
129 | |
130 group('version', () { | |
131 integration('displays the current version', () { | |
132 schedulePub(args: ['version'], output: VERSION_STRING); | |
133 }); | |
134 | |
135 integration('parses a release-style version', () { | |
136 d.dir(sdkPath, [ | |
137 d.file('version', '0.1.2.0_r17645'), | |
138 ]).create(); | |
139 | |
140 schedulePub(args: ['version'], output: "Pub 0.1.2+0.r17645\n"); | |
141 }); | |
142 | |
143 integration('parses a dev-only style version', () { | |
144 // The "version" file generated on developer builds is a little funky and | |
145 // we need to make sure we don't choke on it. | |
146 d.dir(sdkPath, [ | |
147 d.file('version', '0.1.2.0_r16279_bobross'), | |
148 ]).create(); | |
149 | |
150 schedulePub(args: ['version'], output: "Pub 0.1.2+0.r16279.bobross\n"); | |
151 }); | |
152 }); | |
153 } | |
OLD | NEW |