]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
ptest-cargo: refactor run-ptest generation to remove redundancy
authorInes KCHELFI <ines.kchelfi@smile.fr>
Thu, 24 Apr 2025 12:32:16 +0000 (14:32 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 29 Apr 2025 08:54:15 +0000 (09:54 +0100)
This refactoring simplifies the generation of the run-ptest script by
removing redundant logic and improving readability.

Signed-off-by: Ines KCHELFI <ines.kchelfi@smile.fr>
Reviewed-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/ptest-cargo.bbclass

index 198110a81a3f23f4090dfa0dd84e17c8e893b438..d19617aa50eec4121aa35b72acd1cc4d3cf6460c 100644 (file)
@@ -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}