[flutter_tools] switch order of injection (#61191)
Inject loggers in the right order, test WIP. Otherwise verbose machine would not get the AppRunLogger
diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart
index c58ca5b..b0eb4ad 100644
--- a/packages/flutter_tools/lib/executable.dart
+++ b/packages/flutter_tools/lib/executable.dart
@@ -145,15 +145,22 @@
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,
diff --git a/packages/flutter_tools/test/integration.shard/command_output_test.dart b/packages/flutter_tools/test/integration.shard/command_output_test.dart
index f93e91d..0b79d94 100644
--- a/packages/flutter_tools/test/integration.shard/command_output_test.dart
+++ b/packages/flutter_tools/test/integration.shard/command_output_test.dart
@@ -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 @@
});
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',
- ]);
+ final Directory directory = createResolvedTempDirectorySync('flutter_run_test.')
+ .createTempSync('_flutter_run_test.')
+ ..createSync(recursive: true);
- expect(result.stdout, isNotEmpty);
+ 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 @@
'-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 {