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 { ...@@ -145,15 +145,22 @@ Future<void> main(List<String> args) async {
outputPreferences: globals.outputPreferences, outputPreferences: globals.outputPreferences,
), ),
)) ))
else if (verbose && !muteCommandLogging) else if (runMachine && !verbose)
Logger: () => VerboseLogger(StdoutLogger( Logger: () => AppRunLogger(parent: StdoutLogger(
timeoutConfiguration: timeoutConfiguration, timeoutConfiguration: timeoutConfiguration,
stdio: globals.stdio, stdio: globals.stdio,
terminal: globals.terminal, terminal: globals.terminal,
outputPreferences: globals.outputPreferences, outputPreferences: globals.outputPreferences,
)) ))
else if (runMachine) else if (runMachine && verbose)
Logger: () => AppRunLogger(parent: StdoutLogger( 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, timeoutConfiguration: timeoutConfiguration,
stdio: globals.stdio, stdio: globals.stdio,
terminal: globals.terminal, terminal: globals.terminal,
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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/base/io.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:process/process.dart'; import 'package:process/process.dart';
import '../src/common.dart'; import '../src/common.dart';
import 'test_utils.dart';
void main() { void main() {
test('All development tools and deprecated commands are hidden and help text is not verbose', () async { test('All development tools and deprecated commands are hidden and help text is not verbose', () async {
...@@ -54,15 +56,34 @@ void main() { ...@@ -54,15 +56,34 @@ void main() {
}); });
test('flutter run --machine uses AppRunLogger', () async { test('flutter run --machine uses AppRunLogger', () async {
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter'); final Directory directory = createResolvedTempDirectorySync('flutter_run_test.')
final ProcessResult result = await const LocalProcessManager().run(<String>[ .createTempSync('_flutter_run_test.')
flutterBin, ..createSync(recursive: true);
'run',
'--machine', try {
'-v', directory
]); .childFile('pubspec.yaml')
.writeAsStringSync('name: foo');
expect(result.stdout, isNotEmpty); 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 { test('flutter attach --machine uses AppRunLogger', () async {
...@@ -74,7 +95,7 @@ void main() { ...@@ -74,7 +95,7 @@ void main() {
'-v', '-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 { 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