Revert "Turn on line wrapping in usage and status messages, adds ANSI color to doctor and analysis messages. (#22656)" (#22759)
This reverts commit e438632165
because it breaks 160 benchmarks, and several devicelab tests,
due to changing the format of the output.
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
// Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/android/android_studio.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/doctor.dart';
|
||||
import 'package:flutter_tools/src/android/android_studio_validator.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
||||
const String home = '/home/me';
|
||||
|
||||
Platform linuxPlatform() {
|
||||
return FakePlatform.fromPlatform(const LocalPlatform())
|
||||
..operatingSystem = 'linux'
|
||||
..environment = <String, String>{'HOME': home};
|
||||
}
|
||||
|
||||
void main() {
|
||||
group('NoAndroidStudioValidator', () {
|
||||
testUsingContext('shows Android Studio as "not available" when not available.', () async {
|
||||
final NoAndroidStudioValidator validator = NoAndroidStudioValidator();
|
||||
expect((await validator.validate()).type, equals(ValidationType.notAvailable));
|
||||
}, overrides: <Type, Generator>{
|
||||
// Note that custom home paths are not supported on macOS nor Windows yet:
|
||||
Platform: () => linuxPlatform(),
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -51,7 +51,7 @@ void main() {
|
||||
expect(mockLogger.traceText, '');
|
||||
expect(
|
||||
mockLogger.errorText,
|
||||
matches('^$red' r'\[ (?: {0,2}\+[0-9]{1,3} ms| )\] ' '${bold}Helpless!$reset' r'\n$'));
|
||||
matches('^$red' r'\[ (?: {0,2}\+[0-9]{1,3} ms| )\] ' '${bold}Helpless!$reset$reset' r'\n$'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -59,6 +59,7 @@ void main() {
|
||||
MockStdio mockStdio;
|
||||
AnsiSpinner ansiSpinner;
|
||||
AnsiStatus ansiStatus;
|
||||
SummaryStatus summaryStatus;
|
||||
int called;
|
||||
const List<String> testPlatforms = <String>['linux', 'macos', 'windows', 'fuchsia'];
|
||||
final RegExp secondDigits = RegExp(r'[^\b]\b\b\b\b\b[0-9]+[.][0-9]+(?:s|ms)');
|
||||
@@ -73,6 +74,12 @@ void main() {
|
||||
padding: 20,
|
||||
onFinish: () => called++,
|
||||
);
|
||||
summaryStatus = SummaryStatus(
|
||||
message: 'Hello world',
|
||||
expectSlowOperation: true,
|
||||
padding: 20,
|
||||
onFinish: () => called++,
|
||||
);
|
||||
});
|
||||
|
||||
List<String> outputStdout() => mockStdio.writtenToStdout.join('').split('\n');
|
||||
@@ -114,9 +121,7 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('Stdout startProgress handle null inputs on colored terminal for $testOs', () async {
|
||||
context[Logger].startProgress(
|
||||
null,
|
||||
progressId: null,
|
||||
context[Logger].startProgress(null, progressId: null,
|
||||
expectSlowOperation: null,
|
||||
progressIndicatorPadding: null,
|
||||
);
|
||||
@@ -187,164 +192,6 @@ void main() {
|
||||
Platform: () => FakePlatform(operatingSystem: testOs),
|
||||
});
|
||||
}
|
||||
});
|
||||
group('Output format', () {
|
||||
MockStdio mockStdio;
|
||||
SummaryStatus summaryStatus;
|
||||
int called;
|
||||
final RegExp secondDigits = RegExp(r'[^\b]\b\b\b\b\b[0-9]+[.][0-9]+(?:s|ms)');
|
||||
|
||||
setUp(() {
|
||||
mockStdio = MockStdio();
|
||||
called = 0;
|
||||
summaryStatus = SummaryStatus(
|
||||
message: 'Hello world',
|
||||
expectSlowOperation: true,
|
||||
padding: 20,
|
||||
onFinish: () => called++,
|
||||
);
|
||||
});
|
||||
|
||||
List<String> outputStdout() => mockStdio.writtenToStdout.join('').split('\n');
|
||||
List<String> outputStderr() => mockStdio.writtenToStderr.join('').split('\n');
|
||||
|
||||
testUsingContext('Error logs are wrapped', () async {
|
||||
context[Logger].printError('0123456789' * 15);
|
||||
final List<String> lines = outputStderr();
|
||||
expect(outputStdout().length, equals(1));
|
||||
expect(outputStdout().first, isEmpty);
|
||||
expect(lines[0], equals('0123456789' * 4));
|
||||
expect(lines[1], equals('0123456789' * 4));
|
||||
expect(lines[2], equals('0123456789' * 4));
|
||||
expect(lines[3], equals('0123456789' * 3));
|
||||
}, overrides: <Type, Generator>{
|
||||
Stdio: () => mockStdio,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
|
||||
Logger: () => StdoutLogger()..supportsColor = false,
|
||||
});
|
||||
|
||||
testUsingContext('Error logs are wrapped and can be indented.', () async {
|
||||
context[Logger].printError('0123456789' * 15, indent: 5);
|
||||
final List<String> lines = outputStderr();
|
||||
expect(outputStdout().length, equals(1));
|
||||
expect(outputStdout().first, isEmpty);
|
||||
expect(lines.length, equals(6));
|
||||
expect(lines[0], equals(' 01234567890123456789012345678901234'));
|
||||
expect(lines[1], equals(' 56789012345678901234567890123456789'));
|
||||
expect(lines[2], equals(' 01234567890123456789012345678901234'));
|
||||
expect(lines[3], equals(' 56789012345678901234567890123456789'));
|
||||
expect(lines[4], equals(' 0123456789'));
|
||||
expect(lines[5], isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
Stdio: () => mockStdio,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
|
||||
Logger: () => StdoutLogger()..supportsColor = false,
|
||||
});
|
||||
|
||||
testUsingContext('Error logs are wrapped and can have hanging indent.', () async {
|
||||
context[Logger].printError('0123456789' * 15, hangingIndent: 5);
|
||||
final List<String> lines = outputStderr();
|
||||
expect(outputStdout().length, equals(1));
|
||||
expect(outputStdout().first, isEmpty);
|
||||
expect(lines.length, equals(6));
|
||||
expect(lines[0], equals('0123456789012345678901234567890123456789'));
|
||||
expect(lines[1], equals(' 01234567890123456789012345678901234'));
|
||||
expect(lines[2], equals(' 56789012345678901234567890123456789'));
|
||||
expect(lines[3], equals(' 01234567890123456789012345678901234'));
|
||||
expect(lines[4], equals(' 56789'));
|
||||
expect(lines[5], isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
Stdio: () => mockStdio,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
|
||||
Logger: () => StdoutLogger()..supportsColor = false,
|
||||
});
|
||||
|
||||
testUsingContext('Error logs are wrapped, indented, and can have hanging indent.', () async {
|
||||
context[Logger].printError('0123456789' * 15, indent: 4, hangingIndent: 5);
|
||||
final List<String> lines = outputStderr();
|
||||
expect(outputStdout().length, equals(1));
|
||||
expect(outputStdout().first, isEmpty);
|
||||
expect(lines.length, equals(6));
|
||||
expect(lines[0], equals(' 012345678901234567890123456789012345'));
|
||||
expect(lines[1], equals(' 6789012345678901234567890123456'));
|
||||
expect(lines[2], equals(' 7890123456789012345678901234567'));
|
||||
expect(lines[3], equals(' 8901234567890123456789012345678'));
|
||||
expect(lines[4], equals(' 901234567890123456789'));
|
||||
expect(lines[5], isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
Stdio: () => mockStdio,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
|
||||
Logger: () => StdoutLogger()..supportsColor = false,
|
||||
});
|
||||
|
||||
testUsingContext('Stdout logs are wrapped', () async {
|
||||
context[Logger].printStatus('0123456789' * 15);
|
||||
final List<String> lines = outputStdout();
|
||||
expect(outputStderr().length, equals(1));
|
||||
expect(outputStderr().first, isEmpty);
|
||||
expect(lines[0], equals('0123456789' * 4));
|
||||
expect(lines[1], equals('0123456789' * 4));
|
||||
expect(lines[2], equals('0123456789' * 4));
|
||||
expect(lines[3], equals('0123456789' * 3));
|
||||
}, overrides: <Type, Generator>{
|
||||
Stdio: () => mockStdio,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
|
||||
Logger: () => StdoutLogger()..supportsColor = false,
|
||||
});
|
||||
|
||||
testUsingContext('Stdout logs are wrapped and can be indented.', () async {
|
||||
context[Logger].printStatus('0123456789' * 15, indent: 5);
|
||||
final List<String> lines = outputStdout();
|
||||
expect(outputStderr().length, equals(1));
|
||||
expect(outputStderr().first, isEmpty);
|
||||
expect(lines.length, equals(6));
|
||||
expect(lines[0], equals(' 01234567890123456789012345678901234'));
|
||||
expect(lines[1], equals(' 56789012345678901234567890123456789'));
|
||||
expect(lines[2], equals(' 01234567890123456789012345678901234'));
|
||||
expect(lines[3], equals(' 56789012345678901234567890123456789'));
|
||||
expect(lines[4], equals(' 0123456789'));
|
||||
expect(lines[5], isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
Stdio: () => mockStdio,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
|
||||
Logger: () => StdoutLogger()..supportsColor = false,
|
||||
});
|
||||
|
||||
testUsingContext('Stdout logs are wrapped and can have hanging indent.', () async {
|
||||
context[Logger].printStatus('0123456789' * 15, hangingIndent: 5);
|
||||
final List<String> lines = outputStdout();
|
||||
expect(outputStderr().length, equals(1));
|
||||
expect(outputStderr().first, isEmpty);
|
||||
expect(lines.length, equals(6));
|
||||
expect(lines[0], equals('0123456789012345678901234567890123456789'));
|
||||
expect(lines[1], equals(' 01234567890123456789012345678901234'));
|
||||
expect(lines[2], equals(' 56789012345678901234567890123456789'));
|
||||
expect(lines[3], equals(' 01234567890123456789012345678901234'));
|
||||
expect(lines[4], equals(' 56789'));
|
||||
expect(lines[5], isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
Stdio: () => mockStdio,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
|
||||
Logger: () => StdoutLogger()..supportsColor = false,
|
||||
});
|
||||
|
||||
testUsingContext('Stdout logs are wrapped, indented, and can have hanging indent.', () async {
|
||||
context[Logger].printStatus('0123456789' * 15, indent: 4, hangingIndent: 5);
|
||||
final List<String> lines = outputStdout();
|
||||
expect(outputStderr().length, equals(1));
|
||||
expect(outputStderr().first, isEmpty);
|
||||
expect(lines.length, equals(6));
|
||||
expect(lines[0], equals(' 012345678901234567890123456789012345'));
|
||||
expect(lines[1], equals(' 6789012345678901234567890123456'));
|
||||
expect(lines[2], equals(' 7890123456789012345678901234567'));
|
||||
expect(lines[3], equals(' 8901234567890123456789012345678'));
|
||||
expect(lines[4], equals(' 901234567890123456789'));
|
||||
expect(lines[5], isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
Stdio: () => mockStdio,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
|
||||
Logger: () => StdoutLogger()..supportsColor = false,
|
||||
});
|
||||
|
||||
testUsingContext('Error logs are red', () async {
|
||||
context[Logger].printError('Pants on fire!');
|
||||
@@ -369,7 +216,10 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('Stdout printStatus handle null inputs on colored terminal', () async {
|
||||
context[Logger].printStatus(null, emphasis: null, color: null, newline: null, indent: null);
|
||||
context[Logger].printStatus(null, emphasis: null,
|
||||
color: null,
|
||||
newline: null,
|
||||
indent: null);
|
||||
final List<String> lines = outputStdout();
|
||||
expect(outputStderr().length, equals(1));
|
||||
expect(outputStderr().first, isEmpty);
|
||||
@@ -380,7 +230,10 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('Stdout printStatus handle null inputs on regular terminal', () async {
|
||||
context[Logger].printStatus(null, emphasis: null, color: null, newline: null, indent: null);
|
||||
context[Logger].printStatus(null, emphasis: null,
|
||||
color: null,
|
||||
newline: null,
|
||||
indent: null);
|
||||
final List<String> lines = outputStdout();
|
||||
expect(outputStderr().length, equals(1));
|
||||
expect(outputStderr().first, isEmpty);
|
||||
@@ -391,9 +244,7 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('Stdout startProgress handle null inputs on regular terminal', () async {
|
||||
context[Logger].startProgress(
|
||||
null,
|
||||
progressId: null,
|
||||
context[Logger].startProgress(null, progressId: null,
|
||||
expectSlowOperation: null,
|
||||
progressIndicatorPadding: null,
|
||||
);
|
||||
|
||||
@@ -4,31 +4,12 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/globals.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
||||
void main() {
|
||||
group('output preferences', () {
|
||||
testUsingContext('can wrap output', () async {
|
||||
printStatus('0123456789' * 8);
|
||||
expect(testLogger.statusText, equals(('0123456789' * 4 + '\n') * 2));
|
||||
}, overrides: <Type, Generator>{
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
|
||||
});
|
||||
|
||||
testUsingContext('can turn off wrapping', () async {
|
||||
final String testString = '0123456789' * 20;
|
||||
printStatus(testString);
|
||||
expect(testLogger.statusText, equals('$testString\n'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => FakePlatform()..stdoutSupportsAnsi = true,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: false),
|
||||
});
|
||||
});
|
||||
group('character input prompt', () {
|
||||
AnsiTerminal terminalUnderTest;
|
||||
|
||||
@@ -42,34 +23,38 @@ void main() {
|
||||
Future<String>.value('\n'), // Not in accepted list
|
||||
Future<String>.value('b'),
|
||||
]).asBroadcastStream();
|
||||
final String choice = await terminalUnderTest.promptForCharInput(
|
||||
<String>['a', 'b', 'c'],
|
||||
prompt: 'Please choose something',
|
||||
);
|
||||
final String choice =
|
||||
await terminalUnderTest.promptForCharInput(
|
||||
<String>['a', 'b', 'c'],
|
||||
prompt: 'Please choose something',
|
||||
);
|
||||
expect(choice, 'b');
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
'Please choose something [a|b|c]: d\n'
|
||||
'Please choose something [a|b|c]: \n'
|
||||
'\n'
|
||||
'Please choose something [a|b|c]: b\n');
|
||||
testLogger.statusText,
|
||||
'Please choose something [a|b|c]: d\n'
|
||||
'Please choose something [a|b|c]: \n'
|
||||
'\n'
|
||||
'Please choose something [a|b|c]: b\n'
|
||||
);
|
||||
});
|
||||
|
||||
testUsingContext('default character choice without displayAcceptedCharacters', () async {
|
||||
mockStdInStream = Stream<String>.fromFutures(<Future<String>>[
|
||||
Future<String>.value('\n'), // Not in accepted list
|
||||
]).asBroadcastStream();
|
||||
final String choice = await terminalUnderTest.promptForCharInput(
|
||||
<String>['a', 'b', 'c'],
|
||||
prompt: 'Please choose something',
|
||||
displayAcceptedCharacters: false,
|
||||
defaultChoiceIndex: 1, // which is b.
|
||||
);
|
||||
final String choice =
|
||||
await terminalUnderTest.promptForCharInput(
|
||||
<String>['a', 'b', 'c'],
|
||||
prompt: 'Please choose something',
|
||||
displayAcceptedCharacters: false,
|
||||
defaultChoiceIndex: 1, // which is b.
|
||||
);
|
||||
expect(choice, 'b');
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
'Please choose something: \n'
|
||||
'\n');
|
||||
testLogger.statusText,
|
||||
'Please choose something: \n'
|
||||
'\n'
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
testUsingContext('flutter create', () async {
|
||||
await runCommand(
|
||||
command: CreateCommand(),
|
||||
arguments: <String>['--no-wrap', 'create', projectPath],
|
||||
arguments: <String>['create', projectPath],
|
||||
statusTextContains: <String>[
|
||||
'All done!',
|
||||
'Your application code is in ${fs.path.normalize(fs.path.join(fs.path.relative(projectPath), 'lib', 'main.dart'))}',
|
||||
|
||||
@@ -375,7 +375,7 @@ void main() {
|
||||
]);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
|
||||
testUsingContext('has correct content and formatting with application template', () async {
|
||||
testUsingContext('has correct content and formatting with applicaiton template', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
|
||||
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/doctor.dart';
|
||||
import 'package:flutter_tools/src/vscode/vscode.dart';
|
||||
import 'package:flutter_tools/src/vscode/vscode_validator.dart';
|
||||
@@ -133,7 +132,7 @@ void main() {
|
||||
'[!] Partial Validator with only a Hint\n'
|
||||
' ! There is a hint here\n'
|
||||
'[!] Partial Validator with Errors\n'
|
||||
' ✗ An error message indicating partial installation\n'
|
||||
' ✗ A error message indicating partial installation\n'
|
||||
' ! Maybe a hint will help the user\n'
|
||||
'[✓] Another Passing Validator (with statusInfo)\n'
|
||||
'\n'
|
||||
@@ -155,7 +154,7 @@ void main() {
|
||||
'[!] Partial Validator with only a Hint\n'
|
||||
' ! There is a hint here\n'
|
||||
'[!] Partial Validator with Errors\n'
|
||||
' ✗ An error message indicating partial installation\n'
|
||||
' ✗ A error message indicating partial installation\n'
|
||||
' ! Maybe a hint will help the user\n'
|
||||
'\n'
|
||||
'! Doctor found issues in 4 categories.\n'
|
||||
@@ -184,7 +183,7 @@ void main() {
|
||||
' • But there is no error\n'
|
||||
'\n'
|
||||
'[!] Partial Validator with Errors\n'
|
||||
' ✗ An error message indicating partial installation\n'
|
||||
' ✗ A error message indicating partial installation\n'
|
||||
' ! Maybe a hint will help the user\n'
|
||||
' • An extra message with some verbose details\n'
|
||||
'\n'
|
||||
@@ -193,84 +192,6 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testUsingContext('validate non-verbose output wrapping', () async {
|
||||
expect(await FakeDoctor().diagnose(verbose: false), isFalse);
|
||||
expect(testLogger.statusText, equals(
|
||||
'Doctor summary (to see all\n'
|
||||
'details, run flutter doctor\n'
|
||||
'-v):\n'
|
||||
'[✓] Passing Validator (with\n'
|
||||
' statusInfo)\n'
|
||||
'[✗] Missing Validator\n'
|
||||
' ✗ A useful error message\n'
|
||||
' ! A hint message\n'
|
||||
'[!] Not Available Validator\n'
|
||||
' ✗ A useful error message\n'
|
||||
' ! A hint message\n'
|
||||
'[!] Partial Validator with\n'
|
||||
' only a Hint\n'
|
||||
' ! There is a hint here\n'
|
||||
'[!] Partial Validator with\n'
|
||||
' Errors\n'
|
||||
' ✗ An error message\n'
|
||||
' indicating partial\n'
|
||||
' installation\n'
|
||||
' ! Maybe a hint will help\n'
|
||||
' the user\n'
|
||||
'\n'
|
||||
'! Doctor found issues in 4\n'
|
||||
' categories.\n'
|
||||
''
|
||||
));
|
||||
}, overrides: <Type, Generator>{
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 30),
|
||||
});
|
||||
|
||||
testUsingContext('validate verbose output wrapping', () async {
|
||||
expect(await FakeDoctor().diagnose(verbose: true), isFalse);
|
||||
expect(testLogger.statusText, equals(
|
||||
'[✓] Passing Validator (with\n'
|
||||
' statusInfo)\n'
|
||||
' • A helpful message\n'
|
||||
' • A second, somewhat\n'
|
||||
' longer helpful message\n'
|
||||
'\n'
|
||||
'[✗] Missing Validator\n'
|
||||
' ✗ A useful error message\n'
|
||||
' • A message that is not an\n'
|
||||
' error\n'
|
||||
' ! A hint message\n'
|
||||
'\n'
|
||||
'[!] Not Available Validator\n'
|
||||
' ✗ A useful error message\n'
|
||||
' • A message that is not an\n'
|
||||
' error\n'
|
||||
' ! A hint message\n'
|
||||
'\n'
|
||||
'[!] Partial Validator with\n'
|
||||
' only a Hint\n'
|
||||
' ! There is a hint here\n'
|
||||
' • But there is no error\n'
|
||||
'\n'
|
||||
'[!] Partial Validator with\n'
|
||||
' Errors\n'
|
||||
' ✗ An error message\n'
|
||||
' indicating partial\n'
|
||||
' installation\n'
|
||||
' ! Maybe a hint will help\n'
|
||||
' the user\n'
|
||||
' • An extra message with\n'
|
||||
' some verbose details\n'
|
||||
'\n'
|
||||
'! Doctor found issues in 4\n'
|
||||
' categories.\n'
|
||||
''
|
||||
));
|
||||
}, overrides: <Type, Generator>{
|
||||
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 30),
|
||||
});
|
||||
|
||||
|
||||
group('doctor with grouped validators', () {
|
||||
testUsingContext('validate diagnose combines validator output', () async {
|
||||
expect(await FakeGroupedDoctor().diagnose(), isTrue);
|
||||
@@ -407,7 +328,7 @@ class PartialValidatorWithErrors extends DoctorValidator {
|
||||
@override
|
||||
Future<ValidationResult> validate() async {
|
||||
final List<ValidationMessage> messages = <ValidationMessage>[];
|
||||
messages.add(ValidationMessage.error('An error message indicating partial installation'));
|
||||
messages.add(ValidationMessage.error('A error message indicating partial installation'));
|
||||
messages.add(ValidationMessage.hint('Maybe a hint will help the user'));
|
||||
messages.add(ValidationMessage('An extra message with some verbose details'));
|
||||
return ValidationResult(ValidationType.partial, messages);
|
||||
|
||||
@@ -123,7 +123,6 @@ void main() {
|
||||
final String appFile = fs.path.join(tempDir.dirname, 'other_app', 'app.dart');
|
||||
fs.file(appFile).createSync(recursive: true);
|
||||
final List<String> args = <String>[
|
||||
'--no-wrap',
|
||||
'drive',
|
||||
'--target=$appFile',
|
||||
];
|
||||
@@ -144,7 +143,6 @@ void main() {
|
||||
final String appFile = fs.path.join(tempDir.path, 'main.dart');
|
||||
fs.file(appFile).createSync(recursive: true);
|
||||
final List<String> args = <String>[
|
||||
'--no-wrap',
|
||||
'drive',
|
||||
'--target=$appFile',
|
||||
];
|
||||
|
||||
@@ -53,8 +53,6 @@ void main() {
|
||||
expect(testLogger.statusText, equals(
|
||||
'Automatically signing iOS for device deployment using specified development team in Xcode project: abc\n'
|
||||
));
|
||||
}, overrides: <Type, Generator>{
|
||||
OutputPreferences: () => OutputPreferences(wrapText: false),
|
||||
});
|
||||
|
||||
testUsingContext('No auto-sign if security or openssl not available', () async {
|
||||
@@ -90,7 +88,6 @@ void main() {
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: false),
|
||||
});
|
||||
|
||||
testUsingContext('Test single identity and certificate organization works', () async {
|
||||
@@ -150,7 +147,6 @@ void main() {
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: false),
|
||||
});
|
||||
|
||||
testUsingContext('Test Google cert also manually selects a provisioning profile', () async {
|
||||
@@ -214,7 +210,6 @@ void main() {
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: false),
|
||||
});
|
||||
|
||||
testUsingContext('Test multiple identity and certificate organization works', () async {
|
||||
@@ -289,7 +284,6 @@ void main() {
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Config: () => mockConfig,
|
||||
AnsiTerminal: () => testTerminal,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: false),
|
||||
});
|
||||
|
||||
testUsingContext('Test multiple identity in machine mode works', () async {
|
||||
@@ -358,7 +352,6 @@ void main() {
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Config: () => mockConfig,
|
||||
AnsiTerminal: () => testTerminal,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: false),
|
||||
});
|
||||
|
||||
testUsingContext('Test saved certificate used', () async {
|
||||
@@ -429,7 +422,6 @@ void main() {
|
||||
overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Config: () => mockConfig,
|
||||
OutputPreferences: () => OutputPreferences(wrapText: false),
|
||||
});
|
||||
|
||||
testUsingContext('Test invalid saved certificate shows error and prompts again', () async {
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter_tools/src/base/utils.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
|
||||
import 'src/common.dart';
|
||||
|
||||
@@ -180,143 +179,4 @@ baz=qux
|
||||
expect(snakeCase('ABC'), equals('a_b_c'));
|
||||
});
|
||||
});
|
||||
|
||||
group('text wrapping', () {
|
||||
const int _lineLength = 40;
|
||||
const String _longLine = 'This is a long line that needs to be wrapped.';
|
||||
final String _longLineWithNewlines = 'This is a long line with newlines that\n'
|
||||
'needs to be wrapped.\n\n' +
|
||||
'0123456789' * 5;
|
||||
final String _longAnsiLineWithNewlines = '${AnsiTerminal.red}This${AnsiTerminal.reset} is a long line with newlines that\n'
|
||||
'needs to be wrapped.\n\n'
|
||||
'${AnsiTerminal.green}0123456789${AnsiTerminal.reset}' +
|
||||
'0123456789' * 3 +
|
||||
'${AnsiTerminal.green}0123456789${AnsiTerminal.reset}';
|
||||
const String _onlyAnsiSequences = '${AnsiTerminal.red}${AnsiTerminal.reset}';
|
||||
final String _indentedLongLineWithNewlines = ' This is an indented long line with newlines that\n'
|
||||
'needs to be wrapped.\n\tAnd preserves tabs.\n \n ' +
|
||||
'0123456789' * 5;
|
||||
const String _shortLine = 'Short line.';
|
||||
const String _indentedLongLine = ' This is an indented long line that needs to be '
|
||||
'wrapped and indentation preserved.';
|
||||
|
||||
test('does not wrap short lines.', () {
|
||||
expect(wrapText(_shortLine, columnWidth: _lineLength), equals(_shortLine));
|
||||
});
|
||||
test('does not wrap at all if not given a length', () {
|
||||
expect(wrapText(_longLine), equals(_longLine));
|
||||
});
|
||||
test('able to wrap long lines', () {
|
||||
expect(wrapText(_longLine, columnWidth: _lineLength), equals('''
|
||||
This is a long line that needs to be
|
||||
wrapped.'''));
|
||||
});
|
||||
test('wrap long lines with no whitespace', () {
|
||||
expect(wrapText('0123456789' * 5, columnWidth: _lineLength), equals('''
|
||||
0123456789012345678901234567890123456789
|
||||
0123456789'''));
|
||||
});
|
||||
test('refuses to wrap to a column smaller than 10 characters', () {
|
||||
expect(wrapText('$_longLine ' + '0123456789' * 4, columnWidth: 1), equals('''
|
||||
This is a
|
||||
long line
|
||||
that needs
|
||||
to be
|
||||
wrapped.
|
||||
0123456789
|
||||
0123456789
|
||||
0123456789
|
||||
0123456789'''));
|
||||
});
|
||||
test('preserves indentation', () {
|
||||
expect(wrapText(_indentedLongLine, columnWidth: _lineLength), equals('''
|
||||
This is an indented long line that
|
||||
needs to be wrapped and indentation
|
||||
preserved.'''));
|
||||
});
|
||||
test('preserves indentation and stripping trailing whitespace', () {
|
||||
expect(wrapText('$_indentedLongLine ', columnWidth: _lineLength), equals('''
|
||||
This is an indented long line that
|
||||
needs to be wrapped and indentation
|
||||
preserved.'''));
|
||||
});
|
||||
test('wraps text with newlines', () {
|
||||
expect(wrapText(_longLineWithNewlines, columnWidth: _lineLength), equals('''
|
||||
This is a long line with newlines that
|
||||
needs to be wrapped.
|
||||
|
||||
0123456789012345678901234567890123456789
|
||||
0123456789'''));
|
||||
});
|
||||
test('wraps text with ANSI sequences embedded', () {
|
||||
expect(wrapText(_longAnsiLineWithNewlines, columnWidth: _lineLength), equals('''
|
||||
${AnsiTerminal.red}This${AnsiTerminal.reset} is a long line with newlines that
|
||||
needs to be wrapped.
|
||||
|
||||
${AnsiTerminal.green}0123456789${AnsiTerminal.reset}012345678901234567890123456789
|
||||
${AnsiTerminal.green}0123456789${AnsiTerminal.reset}'''));
|
||||
});
|
||||
test('wraps text with only ANSI sequences', () {
|
||||
expect(wrapText(_onlyAnsiSequences, columnWidth: _lineLength),
|
||||
equals('${AnsiTerminal.red}${AnsiTerminal.reset}'));
|
||||
});
|
||||
test('preserves indentation in the presence of newlines', () {
|
||||
expect(wrapText(_indentedLongLineWithNewlines, columnWidth: _lineLength), equals('''
|
||||
This is an indented long line with
|
||||
newlines that
|
||||
needs to be wrapped.
|
||||
\tAnd preserves tabs.
|
||||
|
||||
01234567890123456789012345678901234567
|
||||
890123456789'''));
|
||||
});
|
||||
test('removes trailing whitespace when wrapping', () {
|
||||
expect(wrapText('$_longLine \t', columnWidth: _lineLength), equals('''
|
||||
This is a long line that needs to be
|
||||
wrapped.'''));
|
||||
});
|
||||
test('honors hangingIndent parameter', () {
|
||||
expect(wrapText(_longLine, columnWidth: _lineLength, hangingIndent: 6), equals('''
|
||||
This is a long line that needs to be
|
||||
wrapped.'''));
|
||||
});
|
||||
test('handles hangingIndent with a single unwrapped line.', () {
|
||||
expect(wrapText(_shortLine, columnWidth: _lineLength, hangingIndent: 6), equals('''
|
||||
Short line.'''));
|
||||
});
|
||||
test('handles hangingIndent with two unwrapped lines and the second is empty.', () {
|
||||
expect(wrapText('$_shortLine\n', columnWidth: _lineLength, hangingIndent: 6), equals('''
|
||||
Short line.
|
||||
'''));
|
||||
});
|
||||
test('honors hangingIndent parameter on already indented line.', () {
|
||||
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, hangingIndent: 6), equals('''
|
||||
This is an indented long line that
|
||||
needs to be wrapped and
|
||||
indentation preserved.'''));
|
||||
});
|
||||
test('honors hangingIndent and indent parameters at the same time.', () {
|
||||
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, indent: 6, hangingIndent: 6), equals('''
|
||||
This is an indented long line
|
||||
that needs to be wrapped
|
||||
and indentation
|
||||
preserved.'''));
|
||||
});
|
||||
test('honors indent parameter on already indented line.', () {
|
||||
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, indent: 6), equals('''
|
||||
This is an indented long line
|
||||
that needs to be wrapped and
|
||||
indentation preserved.'''));
|
||||
});
|
||||
test('honors hangingIndent parameter on already indented line.', () {
|
||||
expect(wrapText(_indentedLongLineWithNewlines, columnWidth: _lineLength, hangingIndent: 6), equals('''
|
||||
This is an indented long line with
|
||||
newlines that
|
||||
needs to be wrapped.
|
||||
And preserves tabs.
|
||||
|
||||
01234567890123456789012345678901234567
|
||||
890123456789'''));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user