@@ -43,8 +43,10 @@ python do_compile_ptest_cargo() {
# - test binaries from sub manifest of the current project if any
current_manifest_path = os.path.normpath(data['manifest_path'])
common_path = os.path.commonpath([current_manifest_path, project_manifest_path])
+ # - artifacts actually built as tests: target.test is also true
+ # for plain bin targets, which cargo builds for integration tests
if common_path in [manifest_dir, current_manifest_path]:
- if (data['target']['test'] or data['target']['doctest']) and data['executable']:
+ if data['profile']['test'] and data['executable']:
test_bins.append(data['executable'])
except (KeyError, ValueError) as e:
# skip lines that do not meet the requirements
do_compile_ptest_cargo finds test binaries by parsing JSON from 'cargo build --tests' and keeps every executable artifact with a "test" or "doctest" target. Since 'cargo build --tests' also builds bin targets, the normal program binary can be mistakenly installed and run as a test only to fail because no arguments are provided. Instead, filter on profile.test, which is only set for artifacts compiled with the test harness. Additionally, drop the 'doctest' check, since 'cargo build --tests' doesn't produce doctest executables. See also: https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-test-field As an example, here is what happens with the 'hyperfine' tool when trying to run its ptests. Most of the test suite works, but it fails at the end when trying to invoke the 'normal' binary: |test result: ok. 56 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s | |PASS: /usr/lib/hyperfine/ptest/hyperfine-e8776e44d98845b7 |error: the following required arguments were not provided: | <command>... | |Usage: hyperfine <command>... | |For more information, try '--help'. |FAIL: /usr/lib/hyperfine/ptest/hyperfine | |ERROR: Exit status is 1 |DURATION: 1 |END: /usr/lib/hyperfine/ptest |2026-11-24T19:14 |STOP: ptest-runner |TOTAL: 1 FAIL: 1 |root@qemux86-64:~# With this fix, we instead see: |test result: ok. 56 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s | |PASS: /usr/lib/hyperfine/ptest/hyperfine-e8776e44d98845b7 |DURATION: 1 |END: /usr/lib/hyperfine/ptest |2026-11-24T19:21 |STOP: ptest-runner |TOTAL: 1 FAIL: 0 |root@qemux86-64:~# librsvg test run to ensure no breakage: |test result: ok. 101 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.16s | |PASS: /usr/lib/librsvg/ptest/rsvg_convert-87afefb074698767 | |running 0 tests | |test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s | |PASS: /usr/lib/librsvg/ptest/rsvg_convert-a76274799d15584d |DURATION: 4 |END: /usr/lib/librsvg/ptest |2026-11-24T19:29 |STOP: ptest-runner |TOTAL: 1 FAIL: 0 and rpm-sequoia: |test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.43s | |PASS: /usr/lib/rpm-sequoia/ptest/rpm_sequoia-51940508e5906e81 |DURATION: 1 |END: /usr/lib/rpm-sequoia/ptest |2026-11-24T19:35 |STOP: ptest-runner |TOTAL: 1 FAIL: 0 Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> --- meta/classes-recipe/ptest-cargo.bbclass | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)