Tests for configure and for the test script itself pasted by mario-goulart on Wed Jul 10 20:33:32 2024

diff --git a/configure b/configure
index 86574dc8..f5f4d234 100755
--- a/configure
+++ b/configure
@@ -230,6 +230,12 @@ tmpc="$(mktemp).c"
 cat > "$tmpc" <<EOF
 int main() {return 0;}
 EOF
+
+# Since we are dealing with commands and options that might be given
+# as multiple words, and preventing shellcheck errors in those cases
+# is tricky, we disable the check.
+#
+# shellcheck disable=SC2086
 if command -v $cccmd >/dev/null; then
     if $cccmd "$tmpc" $CFLAGS -o "${tmpc}.out"; then
         rm -f "$tmpc"


diff --git a/tests/config.make.ok b/tests/config.make.ok
new file mode 100644
index 00000000..38c27e26
--- /dev/null
+++ b/tests/config.make.ok
@@ -0,0 +1,3 @@
+# GENERATED BY configure
+PLATFORM ?= linux
+PREFIX ?= /foo/bar


diff --git a/tests/test-configure.sh b/tests/test-configure.sh
new file mode 100755
index 00000000..7a05b166
--- /dev/null
+++ b/tests/test-configure.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+
+set -e
+
+configure=../configure
+
+# Prevent clobbering/removing config.make files which are not in the
+# tests directory
+[ -e runtests.sh ] || {
+    echo "This script is to be executed from the tests directory." >&2
+    exit 1
+}
+
+trap "[ -e runtests.sh ] && rm -f config.make" EXIT
+
+check_shell() {
+    if command -v "$@" >/dev/null; then
+        echo "Checking $*"
+        "$@" "$configure" --prefix /foo/bar >/dev/null
+        diff config.make config.make.ok
+    else
+        echo "Skipping $* (not found)"
+    fi
+}
+
+check_shell bash
+check_shell busybox sh
+check_shell dash
+check_shell sh
+
+command -v shellcheck >/dev/null && {
+    echo "Checking $configure with shellcheck"
+    shellcheck "$configure"
+
+    echo "Checking $0 with shellcheck"
+    shellcheck "$0"
+}

Output of test-configure.sh added by mario-goulart on Wed Jul 10 20:34:58 2024

$ ./test-configure.sh 
Checking bash
Checking busybox sh
Checking dash
Checking sh
Checking ../configure with shellcheck
Checking ./test-configure.sh with shellcheck