summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/ptest-cargo.bbclass
diff options
context:
space:
mode:
authorFrederic Martinsons <frederic.martinsons@gmail.com>2023-07-29 07:09:21 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-07-30 07:54:44 +0100
commit80cec38c0cde4eae80c1fdfe4dfaac28bcfc5d91 (patch)
tree32e260b493b1b3981a6c2d3256573629e07bfe5a /meta/classes-recipe/ptest-cargo.bbclass
parentc2d0ac3f0d8de681b28e0aca6dc41e93f4ca0540 (diff)
downloadpoky-80cec38c0cde4eae80c1fdfe4dfaac28bcfc5d91.tar.gz
ptest-cargo.bbclass: Support of cargo workspaces
For complex project, it is very common to have multiple sub artifacts and so use workspaces, sometimes it has even no root artifacts (but several bin or lib) and virtual manifest is used for that. Long story short, support this case in ptest-cargo class to look for all test binaries in the current project and no more those generated by the root Cargo.toml (From OE-Core rev: 67644c3fa7d012ad03d0a876a281d5abd5edf7fe) Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/ptest-cargo.bbclass')
-rw-r--r--meta/classes-recipe/ptest-cargo.bbclass12
1 files changed, 8 insertions, 4 deletions
diff --git a/meta/classes-recipe/ptest-cargo.bbclass b/meta/classes-recipe/ptest-cargo.bbclass
index 5d53abe969..ff57be8525 100644
--- a/meta/classes-recipe/ptest-cargo.bbclass
+++ b/meta/classes-recipe/ptest-cargo.bbclass
@@ -16,6 +16,8 @@ python do_compile_ptest_cargo() {
16 cargo_build_flags = d.getVar("CARGO_BUILD_FLAGS", True) 16 cargo_build_flags = d.getVar("CARGO_BUILD_FLAGS", True)
17 rust_flags = d.getVar("RUSTFLAGS", True) 17 rust_flags = d.getVar("RUSTFLAGS", True)
18 manifest_path = d.getVar("MANIFEST_PATH", True) 18 manifest_path = d.getVar("MANIFEST_PATH", True)
19 project_manifest_path = os.path.normpath(manifest_path)
20 manifest_dir = os.path.dirname(manifest_path)
19 21
20 env = os.environ.copy() 22 env = os.environ.copy()
21 env['RUSTFLAGS'] = rust_flags 23 env['RUSTFLAGS'] = rust_flags
@@ -46,13 +48,15 @@ python do_compile_ptest_cargo() {
46 pass 48 pass
47 else: 49 else:
48 try: 50 try:
49 # Filter the test packages coming from the current manifest 51 # Filter the test packages coming from the current project:
52 # - test binaries from the root manifest
53 # - test binaries from sub manifest of the current project if any
50 current_manifest_path = os.path.normpath(data['manifest_path']) 54 current_manifest_path = os.path.normpath(data['manifest_path'])
51 project_manifest_path = os.path.normpath(manifest_path) 55 common_path = os.path.commonpath([current_manifest_path, project_manifest_path])
52 if current_manifest_path == project_manifest_path: 56 if common_path in [manifest_dir, current_manifest_path]:
53 if (data['target']['test'] or data['target']['doctest']) and data['executable']: 57 if (data['target']['test'] or data['target']['doctest']) and data['executable']:
54 test_bins.append(data['executable']) 58 test_bins.append(data['executable'])
55 except KeyError as e: 59 except (KeyError, ValueError) as e:
56 # skip lines that do not meet the requirements 60 # skip lines that do not meet the requirements
57 pass 61 pass
58 62