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

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

Issue 11363249: Fix error reporting on invalid command line args. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/version_solver.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 '../../../pkg/unittest/lib/unittest.dart'; 10 import '../../../pkg/unittest/lib/unittest.dart';
11 11
12 final USAGE_STRING = """ 12 final USAGE_STRING = """
13 Pub is a package manager for Dart. 13 Pub is a package manager for Dart.
14 14
15 Usage: pub command [arguments] 15 Usage: pub command [arguments]
16 16
17 Global options: 17 Global options:
18 -h, --help Prints this usage information 18 -h, --help Prints this usage information
19 --version Prints the version of Pub 19 --version Prints the version of Pub
20 --[no-]trace Prints a stack trace when an error occurs 20 --[no-]trace Prints a stack trace when an error occurs
21 21
22 The commands are: 22 Available commands:
23 help display help information for Pub 23 help display help information for Pub
24 install install the current package's dependencies 24 install install the current package's dependencies
25 update update the current package's dependencies to the latest versions 25 update update the current package's dependencies to the latest versions
26 version print Pub version 26 version print Pub version
27 27
28 Use "pub help [command]" for more information about a command. 28 Use "pub help [command]" for more information about a command.
29 """; 29 """;
30 30
31 final VERSION_STRING = ''' 31 final VERSION_STRING = '''
32 Pub 0.0.0 32 Pub 0.0.0
33 '''; 33 ''';
34 34
35 main() { 35 main() {
36 test('running pub with no command displays usage', () => 36 test('running pub with no command displays usage', () =>
37 runPub(args: [], output: USAGE_STRING)); 37 runPub(args: [], output: USAGE_STRING));
38 38
39 test('running pub with just --help displays usage', () => 39 test('running pub with just --help displays usage', () =>
40 runPub(args: ['--help'], output: USAGE_STRING)); 40 runPub(args: ['--help'], output: USAGE_STRING));
41 41
42 test('running pub with just -h displays usage', () => 42 test('running pub with just -h displays usage', () =>
43 runPub(args: ['-h'], output: USAGE_STRING)); 43 runPub(args: ['-h'], output: USAGE_STRING));
44 44
45 test('running pub with just --version displays version', () => 45 test('running pub with just --version displays version', () =>
46 runPub(args: ['--version'], output: VERSION_STRING)); 46 runPub(args: ['--version'], output: VERSION_STRING));
47 47
48 group('an unknown command', () { 48 test('an unknown command displays an error message', () {
49 test('displays an error message', () { 49 runPub(args: ['quylthulg'],
50 runPub(args: ['quylthulg'], 50 error: '''
51 error: ''' 51 Could not find a command named "quylthulg".
52 Unknown command "quylthulg". 52 Run "pub help" to see available commands.
53 Run "pub help" to see available commands. 53 ''',
54 ''', 54 exitCode: 64);
55 exitCode: 64); 55 });
56 }); 56
57 test('an unknown option displays an error message', () {
58 runPub(args: ['--blorf'],
59 error: '''
60 Could not find an option named "blorf".
61 Run "pub help" to see available options.
62 ''',
63 exitCode: 64);
64 });
65
66 test('an unknown command option displays an error message', () {
67 // TODO(rnystrom): When pub has command-specific options, a more precise
68 // error message would be good here.
69 runPub(args: ['version', '--blorf'],
70 error: '''
71 Could not find an option named "blorf".
72 Use "pub help" for more information.
73 ''',
74 exitCode: 64);
75 });
76
77 test('an unknown help command displays an error message', () {
78 runPub(args: ['help', 'quylthulg'],
79 error: '''
80 Could not find a command named "quylthulg".
81 Run "pub help" to see available commands.
82 ''',
83 exitCode: 64);
57 }); 84 });
58 85
59 test('displays the current version', () => 86 test('displays the current version', () =>
60 runPub(args: ['version'], output: VERSION_STRING)); 87 runPub(args: ['version'], output: VERSION_STRING));
61 } 88 }
OLDNEW
« no previous file with comments | « utils/pub/version_solver.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698