7c2e379f89
BUG=http://code.google.com/p/dart/issues/detail?id=8487 Review URL: https://codereview.chromium.org//12217156 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18423 260f80e4-7a28-3924-810f-c04153c831b5
150 lines
4.7 KiB
Dart
150 lines
4.7 KiB
Dart
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
library pub_tests;
|
|
|
|
import 'dart:io';
|
|
|
|
import 'test_pub.dart';
|
|
import '../../../pkg/unittest/lib/unittest.dart';
|
|
|
|
final USAGE_STRING = """
|
|
Pub is a package manager for Dart.
|
|
|
|
Usage: pub command [arguments]
|
|
|
|
Global options:
|
|
-h, --help Print this usage information.
|
|
--version Print pub version.
|
|
--[no-]trace Print debugging information when an error occurs.
|
|
--verbosity Control output verbosity.
|
|
|
|
[all] All output including internal tracing messages are shown.
|
|
[io] IO operations are also shown.
|
|
[normal] Errors, warnings, and user messages are shown.
|
|
|
|
-v, --verbose Shortcut for "--verbosity=all"
|
|
|
|
Available commands:
|
|
help Display help information for Pub.
|
|
install Install the current package's dependencies.
|
|
publish Publish the current package to pub.dartlang.org.
|
|
update Update the current package's dependencies to the latest versions.
|
|
uploader Manage uploaders for a package on pub.dartlang.org.
|
|
version Print pub version.
|
|
|
|
Use "pub help [command]" for more information about a command.
|
|
""";
|
|
|
|
final VERSION_STRING = '''
|
|
Pub 0.1.2+3
|
|
''';
|
|
|
|
main() {
|
|
initConfig();
|
|
|
|
integration('running pub with no command displays usage', () {
|
|
schedulePub(args: [], output: USAGE_STRING);
|
|
});
|
|
|
|
integration('running pub with just --help displays usage', () {
|
|
schedulePub(args: ['--help'], output: USAGE_STRING);
|
|
});
|
|
|
|
integration('running pub with just -h displays usage', () {
|
|
schedulePub(args: ['-h'], output: USAGE_STRING);
|
|
});
|
|
|
|
integration('running pub with just --version displays version', () {
|
|
schedulePub(args: ['--version'], output: VERSION_STRING);
|
|
});
|
|
|
|
integration('an unknown command displays an error message', () {
|
|
schedulePub(args: ['quylthulg'],
|
|
error: '''
|
|
Could not find a command named "quylthulg".
|
|
Run "pub help" to see available commands.
|
|
''',
|
|
exitCode: 64);
|
|
});
|
|
|
|
integration('an unknown option displays an error message', () {
|
|
schedulePub(args: ['--blorf'],
|
|
error: '''
|
|
Could not find an option named "blorf".
|
|
Run "pub help" to see available options.
|
|
''',
|
|
exitCode: 64);
|
|
});
|
|
|
|
integration('an unknown command option displays an error message', () {
|
|
// TODO(rnystrom): When pub has command-specific options, a more precise
|
|
// error message would be good here.
|
|
schedulePub(args: ['version', '--blorf'],
|
|
error: '''
|
|
Could not find an option named "blorf".
|
|
Use "pub help" for more information.
|
|
''',
|
|
exitCode: 64);
|
|
});
|
|
|
|
group('help', () {
|
|
integration('shows help for a command', () {
|
|
schedulePub(args: ['help', 'install'],
|
|
output: '''
|
|
Install the current package's dependencies.
|
|
|
|
Usage: pub install
|
|
''');
|
|
});
|
|
|
|
integration('shows help for a command', () {
|
|
schedulePub(args: ['help', 'publish'],
|
|
output: '''
|
|
Publish the current package to pub.dartlang.org.
|
|
|
|
Usage: pub publish [options]
|
|
-n, --dry-run Validate but do not publish the package
|
|
-f, --force Publish without confirmation if there are no errors
|
|
--server The package server to which to upload this package
|
|
(defaults to "https://pub.dartlang.org")
|
|
''');
|
|
});
|
|
|
|
integration('an unknown help command displays an error message', () {
|
|
schedulePub(args: ['help', 'quylthulg'],
|
|
error: '''
|
|
Could not find a command named "quylthulg".
|
|
Run "pub help" to see available commands.
|
|
''',
|
|
exitCode: 64);
|
|
});
|
|
|
|
});
|
|
|
|
group('version', () {
|
|
integration('displays the current version', () {
|
|
schedulePub(args: ['version'], output: VERSION_STRING);
|
|
});
|
|
|
|
integration('parses a release-style version', () {
|
|
dir(sdkPath, [
|
|
file('version', '0.1.2.0_r17645'),
|
|
]).scheduleCreate();
|
|
|
|
schedulePub(args: ['version'], output: "Pub 0.1.2+0.r17645\n");
|
|
});
|
|
|
|
integration('parses a dev-only style version', () {
|
|
// The "version" file generated on developer builds is a little funky and
|
|
// we need to make sure we don't choke on it.
|
|
dir(sdkPath, [
|
|
file('version', '0.1.2.0_r16279_bobross'),
|
|
]).scheduleCreate();
|
|
|
|
schedulePub(args: ['version'], output: "Pub 0.1.2+0.r16279.bobross\n");
|
|
});
|
|
});
|
|
}
|