diff mbox series

[meta-lts-mixins,kirkstone/rust,01/13] ptest-cargo: fix tests output format for testimage

Message ID efd603776a911911f8ee3c82beceba1741365feb.1753296167.git.scott.murray@konsulko.com
State New
Headers show
Series Update to Rust 1.87.0 | expand

Commit Message

Scott Murray July 23, 2025, 7:05 p.m. UTC
From: Ines KCHELFI <ines.kchelfi@smile.fr>

In testimage, the ptest-runner output parser expects test results to follow
a specific format,with lines beginning with PASS:, FAIL:, or SKIP:. ptest-cargo,
currently, does not emit any of those lines and the parser treats the test
section as having no results, causing a test failure with :

AssertionError:
ptests which had no test results:
['<package>']

This patch ensures that the recipes using ptest-cargo class explicitly emits
PASS: or FAIL: lines, making the results compatible with the test parser and
preventing test failures.

Signed-off-by: Ines KCHELFI <ines.kchelfi@smile.fr>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(adapted from oe-core commit 6a9356346f13556a06d4a99bd7924992c7e29d66)
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
 classes/ptest-cargo.bbclass | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/classes/ptest-cargo.bbclass b/classes/ptest-cargo.bbclass
index 7b18d43..ece25ff 100644
--- a/classes/ptest-cargo.bbclass
+++ b/classes/ptest-cargo.bbclass
@@ -77,6 +77,7 @@  python do_compile_ptest_cargo() {
 
 python do_install_ptest_cargo() {
     import shutil
+    import textwrap
 
     dest_dir = d.getVar("D")
     pn = d.getVar("PN")
@@ -107,7 +108,16 @@  python do_install_ptest_cargo() {
             f.write(f"\necho \"\"\n")
             f.write(f"echo \"## starting to run rust tests ##\"\n")               
         for test_path in test_paths:
-            f.write(f"if ! {test_path} {rust_test_args}; then rc=1; fi\n")
+            script = textwrap.dedent(f"""\
+                if ! {test_path} {rust_test_args}
+                then
+                    rc=1
+                    echo "FAIL: {test_path}"
+                else
+                    echo "PASS: {test_path}"
+                fi
+            """)
+            f.write(script)
         
         f.write("exit $rc\n")