Unverified Commit 6eaaf165 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] switch order of injection (#61191)

Inject loggers in the right order, test WIP. Otherwise verbose machine would not get the AppRunLogger
parent 20fe2f88
......@@ -145,15 +145,22 @@ Future<void> main(List<String> args) async {
outputPreferences: globals.outputPreferences,
),
))
else if (verbose && !muteCommandLogging)
Logger: () => VerboseLogger(StdoutLogger(
else if (runMachine && !verbose)
Logger: () => AppRunLogger(parent: StdoutLogger(
timeoutConfiguration: timeoutConfiguration,
stdio: globals.stdio,
terminal: globals.terminal,
outputPreferences: globals.outputPreferences,
))
else if (runMachine)
Logger: () => AppRunLogger(parent: StdoutLogger(
else if (runMachine && verbose)
Logger: () => AppRunLogger(parent: VerboseLogger(StdoutLogger(
timeoutConfiguration: timeoutConfiguration,
stdio: globals.stdio,
terminal: globals.terminal,
outputPreferences: globals.outputPreferences,
)))
else if (verbose && !muteCommandLogging)
Logger: () => VerboseLogger(StdoutLogger(
timeoutConfiguration: timeoutConfiguration,
stdio: globals.stdio,
terminal: globals.terminal,
......
......@@ -2,11 +2,13 @@
// 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/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:process/process.dart';
import '../src/common.dart';
import 'test_utils.dart';
void main() {
test('All development tools and deprecated commands are hidden and help text is not verbose', () async {
......@@ -54,15 +56,34 @@ void main() {
});
test('flutter run --machine uses AppRunLogger', () async {
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
final ProcessResult result = await const LocalProcessManager().run(<String>[
flutterBin,
'run',
'--machine',
'-v',
]);
expect(result.stdout, isNotEmpty);
final Directory directory = createResolvedTempDirectorySync('flutter_run_test.')
.createTempSync('_flutter_run_test.')
..createSync(recursive: true);
try {
directory
.childFile('pubspec.yaml')
.writeAsStringSync('name: foo');
directory
.childFile('.packages')
.writeAsStringSync('\n');
directory
.childDirectory('lib')
.childFile('main.dart')
.createSync(recursive: true);
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
final ProcessResult result = await const LocalProcessManager().run(<String>[
flutterBin,
'run',
'--show-test-device', // ensure command can fail to run and hit injection of correct logger.
'--machine',
'-v',
'--no-resident',
], workingDirectory: directory.path);
expect(result.stderr, isNot(contains('Oops; flutter has exited unexpectedly:')));
} finally {
directory.deleteSync(recursive: true);
}
});
test('flutter attach --machine uses AppRunLogger', () async {
......@@ -74,7 +95,7 @@ void main() {
'-v',
]);
expect(result.stdout, isNotEmpty);
expect(result.stderr, contains('Target file')); // Target file not found, but different paths on Windows and Linux/macOS.
});
test('flutter build aot is deprecated', () async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment