[flutter_tools] switch order of injection (#61191)
Inject loggers in the right order, test WIP. Otherwise verbose machine would not get the AppRunLogger
This commit is contained in:
@@ -145,6 +145,20 @@ Future<void> main(List<String> args) async {
|
||||
outputPreferences: globals.outputPreferences,
|
||||
),
|
||||
))
|
||||
else if (runMachine && !verbose)
|
||||
Logger: () => AppRunLogger(parent: StdoutLogger(
|
||||
timeoutConfiguration: timeoutConfiguration,
|
||||
stdio: globals.stdio,
|
||||
terminal: globals.terminal,
|
||||
outputPreferences: globals.outputPreferences,
|
||||
))
|
||||
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,
|
||||
@@ -152,12 +166,5 @@ Future<void> main(List<String> args) async {
|
||||
terminal: globals.terminal,
|
||||
outputPreferences: globals.outputPreferences,
|
||||
))
|
||||
else if (runMachine)
|
||||
Logger: () => AppRunLogger(parent: StdoutLogger(
|
||||
timeoutConfiguration: timeoutConfiguration,
|
||||
stdio: globals.stdio,
|
||||
terminal: globals.terminal,
|
||||
outputPreferences: globals.outputPreferences,
|
||||
))
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
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 @@ 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 {
|
||||
|
||||
Reference in New Issue
Block a user