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>
75 lines
2.3 KiB
Dart
75 lines
2.3 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('format', format, timeout: longTimeout);
|
|
}
|
|
|
|
void format() {
|
|
TestProject p;
|
|
|
|
tearDown(() => p?.dispose());
|
|
|
|
test('--help', () {
|
|
p = project();
|
|
var result = p.runSync(['format', '--help']);
|
|
expect(result.exitCode, 0);
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stdout, contains('Idiomatically format Dart source code.'));
|
|
expect(result.stdout,
|
|
contains('Usage: dart format [options...] <files or directories...>'));
|
|
|
|
// Does not show verbose help.
|
|
expect(result.stdout.contains('--stdin-name'), isFalse);
|
|
});
|
|
|
|
test('--help --verbose', () {
|
|
p = project();
|
|
var result = p.runSync(['format', '--help', '--verbose']);
|
|
expect(result.exitCode, 0);
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stdout, contains('Idiomatically format Dart source code.'));
|
|
expect(result.stdout,
|
|
contains('Usage: dart format [options...] <files or directories...>'));
|
|
|
|
// Shows verbose help.
|
|
expect(result.stdout, contains('--stdin-name'));
|
|
});
|
|
|
|
test('unchanged', () {
|
|
p = project(mainSrc: 'int get foo => 1;\n');
|
|
ProcessResult result = p.runSync(['format', p.relativeFilePath]);
|
|
expect(result.exitCode, 0);
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stdout, startsWith('Formatted 1 file (0 changed) in '));
|
|
});
|
|
|
|
test('formatted', () {
|
|
p = project(mainSrc: 'int get foo => 1;\n');
|
|
ProcessResult result = p.runSync(['format', p.relativeFilePath]);
|
|
expect(result.exitCode, 0);
|
|
expect(result.stderr, isEmpty);
|
|
expect(
|
|
result.stdout,
|
|
startsWith(
|
|
'Formatted lib/main.dart\nFormatted 1 file (1 changed) in '));
|
|
});
|
|
|
|
test('unknown file', () {
|
|
p = project(mainSrc: 'int get foo => 1;\n');
|
|
var unknownFilePath = '${p.relativeFilePath}-unknown-file.dart';
|
|
ProcessResult result = p.runSync(['format', unknownFilePath]);
|
|
expect(result.exitCode, 0);
|
|
expect(result.stderr,
|
|
startsWith('No file or directory found at "$unknownFilePath".'));
|
|
expect(result.stdout, startsWith('Formatted no files in '));
|
|
});
|
|
}
|