new_variant: return error code if build fails

If the build (launched by new_variant.py) fails, return an error
code after cleaning up as much as possible.

BUG=b:167305316
TEST=See testdata/README.md for full details.
Use `&&` to run a second command if the first one passes.
`cd testdata ; ./new_variant_fulltest.sh hatch && echo PASS`
`cd testdata ; ./new_variant_fulltest.sh waddledoo && echo PASS`
The case with hatch will show "PASS" but because waddledoo has an
issue right now, that line won't show the "PASS".

Change-Id: I6cceeff7127ba93e0bd99d186d3cb1dfca44fcf0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2401953
Tested-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Jacob Rasmussen <jacobraz@google.com>
Reviewed-by: Greg Edelston <gredelston@google.com>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
diff --git a/contrib/variant/testdata/new_variant_fulltest.sh b/contrib/variant/testdata/new_variant_fulltest.sh
index f902a62..ffe051b 100755
--- a/contrib/variant/testdata/new_variant_fulltest.sh
+++ b/contrib/variant/testdata/new_variant_fulltest.sh
@@ -196,14 +196,14 @@
 fi
 
 
-# Now create the new variant.
+# Now create the new variant. Output will be captured as a side-effect of
+# running in CQ, or it will be in the scrollback buffer on the user's terminal
+# when executed locally.
 ./new_variant.py --board="${REFERENCE}" --variant="${NEW}" --verbose
-# TODO(b/167305316) capture output of new_variant.py.
 
-# TODO(b/167305316) parse output and/or check [-e ~/.new_variant.yaml] to
-#   determine success/failure.
-
-# If new_variant didn't clean up after itself, then --abort.
+# If new_variant didn't clean up after itself, the build must have failed.
+# Clean up with --abort and exit this script with an error code.
 if [[ ! "${HOME}/.new_variant.yaml" ]] ; then
   ./new_variant.py --abort --verbose
+  exit 1
 fi