f3fe9dc3b3
This is a reland of 58860f4814
Original change's description:
> Improve handling of disable-dartdev-analytics
>
> This is second try of https://dart-review.googlesource.com/c/sdk/+/171284
> that was reverted to to faulty logic in main_options.
>
> Some other refactorings are piggy-backed along.
>
> TestProject.runSync no longer takes a 'command' argument. It was anyway
> often not an argument.
>
> Also stop the messy handling of pub arguments. It is no longer needed.
>
> BUG: https://github.com/dart-lang/sdk/issues/44135
> Change-Id: I49abf5810d9ea262409ba9d93f0471037cb8a753
> TEST=The VM change is tested via all the pkg/dartdev/test/command/* tests that invoke dart with the --no-analytics flag.
> TEST=Furthermore manual test that the --no-analytics flag is passed to dartdev.
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174261
> Reviewed-by: Jonas Jensen <jonasfj@google.com>
> Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Change-Id: I725662f578d061f87171ceffe9aff3de83688f58
TEST=Furthermore run the vm-kernel-precomp-obfuscate-linux-release-x64-try trybot
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174473
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
134 lines
4.2 KiB
Dart
134 lines
4.2 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:args/command_runner.dart';
|
|
import 'package:dartdev/dartdev.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import '../utils.dart';
|
|
|
|
void main() {
|
|
group('command', command, timeout: longTimeout);
|
|
group('flag', help, timeout: longTimeout);
|
|
}
|
|
|
|
void command() {
|
|
// For each command description, assert that the values are not empty, don't
|
|
// have trailing white space and end with a period.
|
|
test('description formatting', () {
|
|
DartdevRunner(['--no-analytics'])
|
|
.commands
|
|
.forEach((String commandKey, Command command) {
|
|
expect(commandKey, isNotEmpty);
|
|
expect(command.description, isNotEmpty);
|
|
expect(command.description.split('\n').first, endsWith('.'));
|
|
expect(command.description.trim(), equals(command.description));
|
|
});
|
|
});
|
|
|
|
// Assert that all found usageLineLengths are the same and null
|
|
test('argParser usageLineLength', () {
|
|
DartdevRunner(['--no-analytics'])
|
|
.commands
|
|
.forEach((String commandKey, Command command) {
|
|
if (command.argParser != null) {
|
|
if (command.name != 'help' &&
|
|
command.name != 'format' &&
|
|
command.name != 'migrate' &&
|
|
command.name != 'pub') {
|
|
expect(command.argParser.usageLineLength,
|
|
stdout.hasTerminal ? stdout.terminalColumns : null);
|
|
} else if (command.name == 'pub') {
|
|
// TODO(sigurdm): Avoid special casing here.
|
|
// https://github.com/dart-lang/pub/issues/2700
|
|
expect(command.argParser.usageLineLength,
|
|
stdout.hasTerminal ? stdout.terminalColumns : 80);
|
|
} else {
|
|
expect(command.argParser.usageLineLength, isNull);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
void help() {
|
|
TestProject p;
|
|
|
|
tearDown(() => p?.dispose());
|
|
|
|
test('--help', () {
|
|
p = project();
|
|
var result = p.runSync(['--help']);
|
|
|
|
expect(result.exitCode, 0);
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stdout, contains(DartdevRunner.dartdevDescription));
|
|
expect(result.stdout,
|
|
contains('Usage: dart [<vm-flags>] <command|dart-file> [<arguments>]'));
|
|
expect(result.stdout, contains('Global options:'));
|
|
expect(result.stdout, contains('Available commands:'));
|
|
expect(result.stdout, contains('analyze '));
|
|
expect(result.stdout, contains('create '));
|
|
expect(result.stdout, contains('compile '));
|
|
expect(result.stdout, contains('format '));
|
|
expect(result.stdout, contains('migrate '));
|
|
});
|
|
|
|
test('--help --verbose', () {
|
|
p = project();
|
|
var result = p.runSync(['--help', '--verbose']);
|
|
|
|
expect(result.exitCode, 0);
|
|
expect(result.stdout, isEmpty);
|
|
expect(result.stderr,
|
|
contains('The following options are only used for VM development'));
|
|
});
|
|
|
|
test('--help -v', () {
|
|
p = project();
|
|
var result = p.runSync(['--help', '-v']);
|
|
|
|
expect(result.exitCode, 0);
|
|
expect(result.stdout, isEmpty);
|
|
expect(result.stderr,
|
|
contains('The following options are only used for VM development'));
|
|
});
|
|
|
|
test('help', () {
|
|
p = project();
|
|
var result = p.runSync(['help']);
|
|
|
|
expect(result.exitCode, 0);
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stdout, contains(DartdevRunner.dartdevDescription));
|
|
expect(result.stdout,
|
|
contains('Usage: dart [<vm-flags>] <command|dart-file> [<arguments>]'));
|
|
expect(result.stdout, contains('Global options:'));
|
|
expect(result.stdout, contains('Available commands:'));
|
|
expect(result.stdout, contains('analyze '));
|
|
expect(result.stdout, contains('create '));
|
|
expect(result.stdout, contains('compile '));
|
|
expect(result.stdout, contains('format '));
|
|
expect(result.stdout, contains('migrate '));
|
|
});
|
|
|
|
test('help --verbose', () {
|
|
p = project();
|
|
var result = p.runSync(['help', '--verbose']);
|
|
|
|
expect(result.exitCode, 0);
|
|
expect(result.stdout, contains('migrate '));
|
|
});
|
|
|
|
test('help -v', () {
|
|
p = project();
|
|
var result = p.runSync(['help', '-v']);
|
|
|
|
expect(result.exitCode, 0);
|
|
expect(result.stdout, contains('migrate '));
|
|
});
|
|
}
|