diff options
| author | Frederic Martinsons <frederic.martinsons@gmail.com> | 2023-05-07 07:44:35 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-05-10 17:18:57 +0100 |
| commit | 6588655baafff4019d9399fb391a6c6c73b89b6f (patch) | |
| tree | d82b3948199eca9d77333355099cf8b72c409ce6 /meta/classes-recipe | |
| parent | 15da7b5e24696492bbb0c4155df0a73186ff1bac (diff) | |
| download | poky-6588655baafff4019d9399fb391a6c6c73b89b6f.tar.gz | |
ptest-cargo.bbclass: add the possibility to define test arguments
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"
(From OE-Core rev: ea1feece62b0347aa2ebf02509ff2da151d96b61)
Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe')
| -rw-r--r-- | meta/classes-recipe/ptest-cargo.bbclass | 8 |
1 files 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 @@ | |||
| 1 | inherit cargo ptest | 1 | inherit cargo ptest |
| 2 | 2 | ||
| 3 | RUST_TEST_ARGS ??= "" | ||
| 4 | RUST_TEST_ARGS[doc] = "Arguments to give to the test binaries (e.g. --shuffle)" | ||
| 5 | |||
| 3 | # I didn't find a cleaner way to share data between compile and install tasks | 6 | # I didn't find a cleaner way to share data between compile and install tasks |
| 4 | CARGO_TEST_BINARIES_FILES ?= "${B}/test_binaries_list" | 7 | CARGO_TEST_BINARIES_FILES ?= "${B}/test_binaries_list" |
| 5 | 8 | ||
| @@ -74,6 +77,7 @@ python do_install_ptest_cargo() { | |||
| 74 | pn = d.getVar("PN", True) | 77 | pn = d.getVar("PN", True) |
| 75 | ptest_path = d.getVar("PTEST_PATH", True) | 78 | ptest_path = d.getVar("PTEST_PATH", True) |
| 76 | cargo_test_binaries_file = d.getVar('CARGO_TEST_BINARIES_FILES', True) | 79 | cargo_test_binaries_file = d.getVar('CARGO_TEST_BINARIES_FILES', True) |
| 80 | rust_test_args = d.getVar('RUST_TEST_ARGS') or "" | ||
| 77 | 81 | ||
| 78 | ptest_dir = os.path.join(dest_dir, ptest_path.lstrip('/')) | 82 | ptest_dir = os.path.join(dest_dir, ptest_path.lstrip('/')) |
| 79 | os.makedirs(ptest_dir, exist_ok=True) | 83 | os.makedirs(ptest_dir, exist_ok=True) |
| @@ -94,12 +98,12 @@ python do_install_ptest_cargo() { | |||
| 94 | f.write(f"\necho \"\"\n") | 98 | f.write(f"\necho \"\"\n") |
| 95 | f.write(f"echo \"## starting to run rust tests ##\"\n") | 99 | f.write(f"echo \"## starting to run rust tests ##\"\n") |
| 96 | for test_path in test_paths: | 100 | for test_path in test_paths: |
| 97 | f.write(f"{test_path}\n") | 101 | f.write(f"{test_path} {rust_test_args}\n") |
| 98 | else: | 102 | else: |
| 99 | with open(ptest_script, "a") as f: | 103 | with open(ptest_script, "a") as f: |
| 100 | f.write("#!/bin/sh\n") | 104 | f.write("#!/bin/sh\n") |
| 101 | for test_path in test_paths: | 105 | for test_path in test_paths: |
| 102 | f.write(f"{test_path}\n") | 106 | f.write(f"{test_path} {rust_test_args}\n") |
| 103 | os.chmod(ptest_script, 0o755) | 107 | os.chmod(ptest_script, 0o755) |
| 104 | 108 | ||
| 105 | # this is chown -R root:root ${D}${PTEST_PATH} | 109 | # this is chown -R root:root ${D}${PTEST_PATH} |
