[elbe-devel] [PATCH] test_xml: make sure the full traceback ends up in the test result

Christian Teklenborg chris at linutronix.de
Fri Jan 22 16:44:44 CET 2021


Before, only a CommandError with the executed command and an exit code was
captured and written to the test result if an error occured. Extend the test
result with the full traceback.

Signed-off-by: Christian Teklenborg <chris at linutronix.de>
---
 elbepack/tests/test_xml.py | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
index 30d57dc7..760ab570 100644
--- a/elbepack/tests/test_xml.py
+++ b/elbepack/tests/test_xml.py
@@ -9,7 +9,7 @@ import tempfile
 
 from elbepack.directories import elbe_dir, elbe_exe
 from elbepack.commands.test import ElbeTestCase, ElbeTestLevel
-from elbepack.shellhelper import system
+from elbepack.shellhelper import system, command_out
 
 @unittest.skipIf(ElbeTestCase.level < ElbeTestLevel.INITVM,
                  "Test level not set to INITVM")
@@ -28,20 +28,27 @@ class TestSimpleXML(ElbeTestCase):
             uuid = None
 
             try:
-                system('%s initvm submit "%s" --output "%s" --keep-files '
-                       '--build-sdk --writeproject "%s"' %
-                       (elbe_exe, self.param, build_dir, prj))
+                ret, out = command_out('%s initvm submit "%s" --output "%s" --keep-files '
+                                       '--build-sdk --writeproject "%s"' %
+                                       (elbe_exe, self.param, build_dir, prj))
+                if ret != 0:
+                    raise Exception(out)
 
                 # Ensure project build is done
                 with open(prj, "r") as f:
                     uuid = f.read()
-                    system("%s control list_projects | "
-                           "grep %s | grep build_done || false" %
-                           (elbe_exe, uuid))
+                    ret, out = command_out("%s control list_projects | "
+                                           "grep %s | grep build_done || false" %
+                                           (elbe_exe, uuid))
+                    if ret != 0:
+                        raise Exception(out)
 
                 for cmd in ("cdrom", "img", "sdk", "rebuild"):
                     with self.subTest(cmd=cmd):
-                        system('%s check-build %s "%s"' % (elbe_exe, cmd, build_dir))
+                        ret, out = command_out('%s check-build %s "%s"' %
+                                               (elbe_exe, cmd, build_dir))
+                        if ret != 0:
+                            raise Exception(out)
 
             # pylint: disable=try-except-raise
             except:
@@ -68,14 +75,18 @@ class TestPbuilder(ElbeTestCase):
             uuid = None
 
             try:
-                system('%s pbuilder create --xmlfile "%s" --writeproject "%s"' %
-                       (elbe_exe, self.param, prj))
+                ret, out = command_out('%s pbuilder create --xmlfile "%s" --writeproject "%s"' %
+                                       (elbe_exe, self.param, prj))
+                if ret != 0:
+                    raise Exception(out)
 
                 with open(prj, "r") as f:
                     uuid = f.read()
-                    system('cd "%s"; %s pbuilder build --project %s' % (build_dir,
-                                                                        elbe_exe,
-                                                                        uuid))
+                    ret, out = command_out('cd "%s"; %s pbuilder build --project %s' %
+                                           (build_dir, elbe_exe, uuid))
+                    if ret != 0:
+                        raise Exception(out)
+
             # pylint: disable=try-except-raise
             except:
                 raise
-- 
2.20.1



More information about the elbe-devel mailing list