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:
@@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user