Fix publish-check output (#3953)

This commit is contained in:
stuartmorgan
2021-05-24 08:39:05 -07:00
committed by GitHub
parent c6a5122ace
commit 04181cf38c
2 changed files with 24 additions and 1 deletions

View File

@ -175,7 +175,10 @@ class PublishCheckCommand extends PluginCommand {
(List<int> event) {
final String output = String.fromCharCodes(event);
if (output.isNotEmpty) {
_printImportantStatusMessage(output, isError: true);
// The final result is always printed on stderr, whether success or
// failure.
final bool isError = !output.contains('has 0 warnings');
_printImportantStatusMessage(output, isError: isError);
outputBuffer.write(output);
}
},

View File

@ -132,6 +132,26 @@ void main() {
expect(runner.run(<String>['publish-check']), throwsA(isA<ToolExit>()));
});
test('Success message on stderr is not printed as an error', () async {
createFakePlugin('d');
const String publishOutput = 'Package has 0 warnings.';
final MockProcess process = MockProcess();
process.stderrController.add(publishOutput.codeUnits);
process.stdoutController.close(); // ignore: unawaited_futures
process.stderrController.close(); // ignore: unawaited_futures
process.exitCodeCompleter.complete(0);
processRunner.processesToReturn.add(process);
final List<String> output = await runCapturingPrint(
runner, <String>['publish-check']);
expect(output, isNot(contains(contains('ERROR:'))));
});
test(
'--machine: Log JSON with status:no-publish and correct human message, if there are no packages need to be published. ',
() async {