No longer pass --verbose to implicit pub calls when flutter --verbose is set. (#158898)

Closes https://github.com/flutter/flutter/issues/158896.
This commit is contained in:
Matan Lurey 2024-11-14 08:59:49 -08:00 committed by GitHub
parent 8f62a9904d
commit 752ac20f87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 4 deletions

View File

@ -138,7 +138,7 @@ abstract class Pub {
/// skipped if the package config file has a "generator" other than "pub". /// skipped if the package config file has a "generator" other than "pub".
/// Defaults to true. /// Defaults to true.
/// ///
/// [outputMode] determines how verbose the output from `pub get` will be. /// [outputMode] determines how detailed the output from `pub get` will be.
/// If [PubOutputMode.all] is used, `pub get` will print its typical output /// If [PubOutputMode.all] is used, `pub get` will print its typical output
/// which includes information about all changed dependencies. If /// which includes information about all changed dependencies. If
/// [PubOutputMode.summaryOnly] is used, only summary information will be printed. /// [PubOutputMode.summaryOnly] is used, only summary information will be printed.
@ -353,12 +353,9 @@ class _DefaultPub implements Pub {
} }
final String command = upgrade ? 'upgrade' : 'get'; final String command = upgrade ? 'upgrade' : 'get';
final bool verbose = _logger.isVerbose;
final List<String> args = <String>[ final List<String> args = <String>[
if (_logger.supportsColor) if (_logger.supportsColor)
'--color', '--color',
if (verbose)
'--verbose',
'--directory', '--directory',
_fileSystem.path.relative(directory), _fileSystem.path.relative(directory),
...<String>[ ...<String>[

View File

@ -763,6 +763,49 @@ exit code: 66
expect(processManager, hasNoRemainingExpectations); expect(processManager, hasNoRemainingExpectations);
}); });
testWithoutContext('pub get does not inherit logger.verbose', () async {
final BufferLogger logger = BufferLogger.test(verbose: true);
final FileSystem fileSystem = MemoryFileSystem.test();
fileSystem.currentDirectory.childFile('version').createSync();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: const <String>[
'bin/cache/dart-sdk/bin/dart',
// Note: Omitted --verbose.
'pub',
'--suppress-analytics',
'--directory',
'.',
'get',
'--example',
], onRun: (_) {
fileSystem.currentDirectory
.childDirectory('.dart_tool')
.childFile('package_config.json')
.createSync(recursive: true);
}),
]);
final Pub pub = Pub.test(
platform: FakePlatform(),
fileSystem: fileSystem,
logger: logger,
usage: TestUsage(),
botDetector: const FakeBotDetector(false),
stdio: FakeStdio(),
processManager: processManager,
);
await expectLater(
pub.get(
project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
context: PubContext.flutterTests,
outputMode: PubOutputMode.failuresOnly,
),
completes,
);
});
// Regression test for https://github.com/flutter/flutter/issues/116627 // Regression test for https://github.com/flutter/flutter/issues/116627
testWithoutContext('pub get suppresses progress output', () async { testWithoutContext('pub get suppresses progress output', () async {
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();