From 88203f8ad74e789435e5ae73d30b2c3f57bddfe1 Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Wed, 2 Feb 2022 18:00:46 +0000 Subject: [PATCH] Bug 1752381 - only parse stdout in substitute-local-geckoview. r=nalexander Root cause: in the current tree, mach commands in mozilla-central output a warning to stderr. The substitute-local-geckoview script was calling a mach command and combining the stdout and stderr streams of the process, parsing it as JSON. This warning is not JSON so the script crashed. The crashing code was copied from settings.gradle: https://searchfox.org/mozilla-central/rev/b70bc09685763c44a8e56e4e04cb741fa020701a/settings.gradle#26 The code in settings.gradle does an intuitive thing - capture stderr separately but only print it on subprocess non-zero exit value - so we also copy that solution. I'm not sure what an appropriate place to store code shared between these two files would be so I didn't try to deduplicate it. Differential Revision: https://phabricator.services.mozilla.com/D137591 --- substitute-local-geckoview.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/substitute-local-geckoview.gradle b/substitute-local-geckoview.gradle index a7828ded7e67..a32dc5ae8a05 100644 --- a/substitute-local-geckoview.gradle +++ b/substitute-local-geckoview.gradle @@ -54,12 +54,15 @@ def loadMozconfig() { machEnv(topsrcdir), new File(ext.has('topobjdir') ? ext.get('topobjdir') : topsrcdir)) def standardOutput = new ByteArrayOutputStream() - proc.consumeProcessOutput(standardOutput, standardOutput) + def standardError = new ByteArrayOutputStream() + proc.consumeProcessOutput(standardOutput, standardError) proc.waitFor() // Only show the output if something went wrong. if (proc.exitValue() != 0) { - throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n${standardOutput.toString()}") + throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n" + + "stdout:\n${standardOutput.toString()}\n\n" + + "stderr:\n${standardError.toString()}") } def slurper = new JsonSlurper()