From: Frederic Martinsons <frederic.martins...@gmail.com>

It can be useful for user of this class for giving common rust test
arguments (like --shuffle, --format or --test-threads)

To add arguments to test binary , simply define RUST_TEST_ARGS
in your recipe that inherit ptest-cargo, for example:

RUST_TEST_ARGS = "--shuffle"

Signed-off-by: Frederic Martinsons <frederic.martins...@gmail.com>
---
 meta/classes-recipe/ptest-cargo.bbclass | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/meta/classes-recipe/ptest-cargo.bbclass 
b/meta/classes-recipe/ptest-cargo.bbclass
index f28bc7a826..4ed528445a 100644
--- a/meta/classes-recipe/ptest-cargo.bbclass
+++ b/meta/classes-recipe/ptest-cargo.bbclass
@@ -1,5 +1,8 @@
 inherit cargo ptest
 
+RUST_TEST_ARGS ??= ""
+RUST_TEST_ARGS[doc] = "Arguments to give to the test binaries (e.g. --shuffle)"
+
 # I didn't find a cleaner way to share data between compile and install tasks
 CARGO_TEST_BINARIES_FILES ?= "${B}/test_binaries_list"
 
@@ -74,6 +77,7 @@ python do_install_ptest_cargo() {
     pn = d.getVar("PN", True)
     ptest_path = d.getVar("PTEST_PATH", True)
     cargo_test_binaries_file = d.getVar('CARGO_TEST_BINARIES_FILES', True)
+    rust_test_args = d.getVar('RUST_TEST_ARGS') or ""
 
     ptest_dir = os.path.join(dest_dir, ptest_path.lstrip('/'))
     os.makedirs(ptest_dir, exist_ok=True)
@@ -94,12 +98,12 @@ 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"{test_path}\n")
+                f.write(f"{test_path} {rust_test_args}\n")
     else:
         with open(ptest_script, "a") as f:
             f.write("#!/bin/sh\n")
             for test_path in test_paths:
-                f.write(f"{test_path}\n")
+                f.write(f"{test_path} {rust_test_args}\n")
         os.chmod(ptest_script, 0o755)
 
     # this is chown -R root:root ${D}${PTEST_PATH}
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#181000): 
https://lists.openembedded.org/g/openembedded-core/message/181000
Mute This Topic: https://lists.openembedded.org/mt/98736909/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to