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

Side by Side Diff: utils/tests/pub/pub_test.dart

Issue 10214006: Refactor command code and add support for --help and --version. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/tests/pub/test_pub.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) 2012, the Dart project authors. Please see the AUTHORS file 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 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 #library('pub_tests'); 5 #library('pub_tests');
6 6
7 #import('dart:io'); 7 #import('dart:io');
8 8
9 #import('test_pub.dart'); 9 #import('test_pub.dart');
10 #import('../../../lib/unittest/unittest.dart'); 10 #import('../../../lib/unittest/unittest.dart');
11 11
12 final USAGE_STRING = """
13 Pub is a package manager for Dart.
14
15 Usage:
16
17 pub command [arguments]
18
19 The commands are:
20
21 list print the contents of repositories
22 update update the current package's dependencies to the latest versions
23 version print Pub version
24
25 Use "pub help [command]" for more information about a command.
26 """;
27
28 final VERSION_STRING = '''
29 Pub 0.0.0
30 ''';
31
12 main() { 32 main() {
13 group('running pub with no command', () { 33 testPub('running pub with no command displays usage',
14 testPub('displays usage', 34 args: [],
15 args: [], 35 output: USAGE_STRING);
16 output: """
17 Pub is a package manager for Dart.
18 36
19 Usage: 37 testPub('running pub with just --help displays usage',
38 args: ['--help'],
39 output: USAGE_STRING);
20 40
21 pub command [arguments] 41 testPub('running pub with just -h displays usage',
42 args: ['-h'],
43 output: USAGE_STRING);
22 44
23 The commands are: 45 testPub('running pub with just --version displays version',
24 46 args: ['--version'],
25 list print the contents of repositories 47 output: VERSION_STRING);
26 update update a package's dependencies
27 version print Pub version
28
29 Use "pub help [command]" for more information about a command.
30 """);
31 });
32 48
33 group('an unknown command', () { 49 group('an unknown command', () {
34 testPub('displays an error message', 50 testPub('displays an error message',
35 args: ['quylthulg'], 51 args: ['quylthulg'],
36 output: ''' 52 output: '''
37 Unknown command "quylthulg". 53 Unknown command "quylthulg".
38 Run "pub help" to see available commands. 54 Run "pub help" to see available commands.
39 ''', 55 ''',
40 exitCode: 64); 56 exitCode: 64);
41 }); 57 });
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 dir('bar', [ 117 dir('bar', [
102 file('bar.dart', 'main() => "bar";'), 118 file('bar.dart', 'main() => "bar";'),
103 ]) 119 ])
104 ], 120 ],
105 output: ''); 121 output: '');
106 } 122 }
107 123
108 versionCommand() { 124 versionCommand() {
109 testPub('displays the current version', 125 testPub('displays the current version',
110 args: ['version'], 126 args: ['version'],
111 output: ''' 127 output: VERSION_STRING);
112 Pub 0.0.0
113 ''');
114 } 128 }
OLDNEW
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698