[pseudo][PATCH 1/5] run_tests.sh: Allow the user to specify specific tests to run

Mark Hatle <[email protected]>
Newsgroups org.yoctoproject.lists.yocto-patches
Message-ID <[email protected]>
From: Mark Hatle <[email protected]>

AI-Generated: Implemented with the assistance of github CoPilot (Claude Opus 4.6)

Signed-off-by: Mark Hatle <[email protected]>
---
 run_tests.sh | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/run_tests.sh b/run_tests.sh
index 1b6cfb9..306a561 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -4,11 +4,15 @@
 #
 
 opt_verbose=
+test_args=()
 
 usage()
 {
     echo >&2 "usage:"
-    echo >&2 "  run_tests [-v|--verbose]"
+    echo >&2 "  run_tests [-v|--verbose] [test ...]"
+    echo >&2 ""
+    echo >&2 "If no tests are specified, all tests are run."
+    echo >&2 "Tests can be specified as filenames (test-fstat.sh) or basenames (test-fstat)."
     exit 1
 }
 
@@ -19,9 +23,15 @@ do
         -v | --verbose)
                 opt_verbose=-v
                 ;;
-        *)
+        -h | --help)
+                usage
+                ;;
+        -*)
                 usage
                 ;;
+        *)
+                test_args+=("$arg")
+                ;;
         esac
 done
 
@@ -36,7 +46,23 @@ num_failed_tests=0
 
 tmplog="$(mktemp pseudo.log.XXXXXXXX)"
 
-for file in test/test*.sh
+if [ ${#test_args[@]} -gt 0 ]; then
+    test_files=()
+    for t in "${test_args[@]}"; do
+        # Strip directory prefix and ensure .sh suffix
+        t="${t##*/}"
+        t="${t%.sh}.sh"
+        if [ -f "test/$t" ]; then
+            test_files+=("test/$t")
+        else
+            echo >&2 "Warning: test/$t not found, skipping."
+        fi
+    done
+else
+    test_files=(test/test*.sh)
+fi
+
+for file in "${test_files[@]}"
 do
     filename=${file#test/}
     let num_tests++
-- 
1.8.3.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.