d27e14496f
Changes: ``` > git log --format="%C(auto) %h %s" e623652..09c0fca https://dart.googlesource.com/args.git/+/09c0fca Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group (286) https://dart.googlesource.com/args.git/+/9cdc872 Add argument name when throwing a `ArgParserException`. (283) ``` Diff: https://dart.googlesource.com/args.git/+/e623652744c82533829f2e62b1aba1a6cf06e291..09c0fca1785c9df39288a48f767994eed80bed40/ Change-Id: I804c86db060b3c83acd34c00dd76953c6f28f70a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388744 Reviewed-by: Nate Bosch <nbosch@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
98 lines
2.8 KiB
Dart
98 lines
2.8 KiB
Dart
// Copyright (c) 2020, 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.
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
import '../utils.dart';
|
|
|
|
void main() {
|
|
group('pub', pub, timeout: longTimeout);
|
|
}
|
|
|
|
void pub() {
|
|
void assertPubHelpInvoked(ProcessResult result) {
|
|
expect(result, isNotNull);
|
|
expect(result.exitCode, 0);
|
|
expect(result.stdout, contains('Work with packages'));
|
|
expect(result.stdout, contains('Available subcommands:'));
|
|
expect(result.stderr, isEmpty);
|
|
}
|
|
|
|
test('implicit --help', () async {
|
|
final result = await project().run(['pub']);
|
|
expect(result, isNotNull);
|
|
expect(result.exitCode, 64);
|
|
expect(result.stderr, contains('Missing subcommand for "dart pub".'));
|
|
expect(result.stderr, contains('Available subcommands:'));
|
|
expect(result.stdout, isEmpty);
|
|
});
|
|
|
|
test('--help', () async {
|
|
assertPubHelpInvoked(await project().run(['pub', '--help']));
|
|
});
|
|
|
|
test('-h', () async {
|
|
assertPubHelpInvoked(await project().run(['pub', '-h']));
|
|
});
|
|
|
|
test('help cache', () async {
|
|
final p = project();
|
|
var result = await p.run(['help', 'pub', 'cache']);
|
|
var result2 = await p.run(['pub', 'cache', '--help']);
|
|
|
|
expect(result.exitCode, 0);
|
|
|
|
expect(result.stdout, contains('Work with the system cache.'));
|
|
expect(result.stdout, result2.stdout);
|
|
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stderr, result2.stderr);
|
|
});
|
|
|
|
test('help publish', () async {
|
|
final p = project();
|
|
var result = await p.run(['help', 'pub', 'publish']);
|
|
var result2 = await p.run(['pub', 'publish', '--help']);
|
|
|
|
expect(result.exitCode, 0);
|
|
|
|
expect(result.stdout, contains('Publish the current package to pub.dev.'));
|
|
expect(result.stdout, result2.stdout);
|
|
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stderr, result2.stderr);
|
|
});
|
|
|
|
test('solve failure', () async {
|
|
final p = project(pubspecExtras: {
|
|
'name': 'myapp',
|
|
'environment': {'sdk': '^2.19.0'},
|
|
'dependencies': {
|
|
'foo': {'path': '../not_to_be_found'},
|
|
},
|
|
});
|
|
final s = Platform.pathSeparator;
|
|
var result = await p.run(['pub', 'deps']);
|
|
expect(result.exitCode, 66);
|
|
expect(result.stdout, isEmpty);
|
|
expect(
|
|
result.stderr,
|
|
contains(
|
|
'(could not find package foo at "..${s}not_to_be_found"), version solving failed.',
|
|
),
|
|
);
|
|
});
|
|
|
|
test('failure unknown option', () async {
|
|
final p = project(mainSrc: 'int get foo => 1;\n');
|
|
var result = await p.run(['pub', 'deps', '--foo']);
|
|
expect(result.exitCode, 64);
|
|
expect(result.stdout, isEmpty);
|
|
expect(
|
|
result.stderr, startsWith('Could not find an option named "--foo".'));
|
|
});
|
|
}
|