utils: run: fix crash with failing tools & combined stderr
If we try to run a program that doesn't exist, don't crash while
trying to show the errors to the user.
Bug: 185946409
Test: pre-upload unittests pass
Change-Id: I70e00412bd000e907536011d245eaa82d36634f6
diff --git a/rh/utils_unittest.py b/rh/utils_unittest.py
index e6ecc97..ea2ddaa 100755
--- a/rh/utils_unittest.py
+++ b/rh/utils_unittest.py
@@ -206,6 +206,15 @@
self.assertNotEqual(0, ret.returncode)
self.assertIn('a/b/c/d', str(ret))
+ def test_check_false_missing_prog_combined_output(self):
+ """Verify handling of combined output capturing w/missing progs."""
+ with self.assertRaises(rh.utils.CalledProcessError) as e:
+ rh.utils.run(['./!~a/b/c/d/'], check=True,
+ combine_stdout_stderr=True)
+ err = e.exception
+ self.assertNotEqual(0, err.returncode)
+ self.assertIn('a/b/c/d', str(err))
+
if __name__ == '__main__':
unittest.main()