From: Ines KCHELFI Date: Thu, 24 Apr 2025 12:32:16 +0000 (+0200) Subject: ptest-cargo: refactor run-ptest generation to remove redundancy X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=287614a847651f8bd528597b7d6ccb8ad8262367;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git ptest-cargo: refactor run-ptest generation to remove redundancy This refactoring simplifies the generation of the run-ptest script by removing redundant logic and improving readability. Signed-off-by: Ines KCHELFI Reviewed-by: Yoann Congal Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/classes-recipe/ptest-cargo.bbclass b/meta/classes-recipe/ptest-cargo.bbclass index 198110a81a3..d19617aa50e 100644 --- a/meta/classes-recipe/ptest-cargo.bbclass +++ b/meta/classes-recipe/ptest-cargo.bbclass @@ -98,17 +98,19 @@ python do_install_ptest_cargo() { test_paths.append(os.path.join(ptest_path, os.path.basename(test_bin))) ptest_script = os.path.join(ptest_dir, "run-ptest") - if os.path.exists(ptest_script): - with open(ptest_script, "a") as f: + script_exists = os.path.exists(ptest_script) + with open(ptest_script, "a") as f: + if not script_exists: + f.write("#!/bin/sh\n") + + else: 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} {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} {rust_test_args}\n") + + for test_path in test_paths: + f.write(f"{test_path} {rust_test_args}\n") + + if not script_exists: os.chmod(ptest_script, 0o755) # this is chown -R root:root ${D}${PTEST_PATH}