]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Improve cargo test output
authorDavid Mulder <dmulder@samba.org>
Tue, 13 Aug 2024 21:06:42 +0000 (15:06 -0600)
committerDavid Mulder <dmulder@samba.org>
Wed, 23 Oct 2024 14:21:34 +0000 (14:21 +0000)
Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
python/samba/tests/rust.py

index e5624bbbeac2ff4c6e3794b14215966026c43c7e..d453b3330275f59a82c38b49a8f4a67a6689179a 100644 (file)
 
 """Cargo tests for Rust sources"""
 
-from samba.tests import BlackboxTestCase
+from samba.tests import TestCase, BlackboxProcessError
 import os
+from subprocess import Popen, PIPE
 
 
-class RustCargoTests(BlackboxTestCase):
+class RustCargoTests(TestCase):
     def setUp(self):
         super().setUp()
 
@@ -52,7 +53,16 @@ class RustCargoTests(BlackboxTestCase):
     def check_cargo_test(self, crate_toml):
         # Execute the cargo test command
         cmd = 'cargo test --target-dir=%s --manifest-path=%s' % (self.target_dir, crate_toml)
-        return self.check_run(cmd, 'cargo test failed')
+        p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
+        stdoutdata, stderrdata = p.communicate()
+        retcode = p.returncode
+        if retcode != 0:
+            msg = "cargo test failed; return code %s" % retcode
+            raise BlackboxProcessError(retcode,
+                                       cmd,
+                                       stdoutdata.decode('utf-8'),
+                                       stderrdata.decode('utf-8'),
+                                       msg)
 
     def test_rust(self):
         crates = []