Tests: Add meta shellcheck test
authorOlivier Dion <odion@efficios.com>
Mon, 6 Feb 2023 19:21:07 +0000 (14:21 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 15 Feb 2023 22:14:49 +0000 (17:14 -0500)
Pass shellcheck on a list of known correct shell scripts. The idea is to
add scripts to the list incrementally and avoid regressions.

Change-Id: If9b15879cfd4d3c3bdbc6b5fc3efb5638593ca74
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
tests/Makefile.am
tests/meta/Makefile.am [new file with mode: 0644]
tests/meta/shellcheck-tests [new file with mode: 0755]

index 11d931759506db928a0fdcb82bb627844947af58..6605bf95ad6d8c8e261c23980e4df39b6875628c 100644 (file)
@@ -1203,6 +1203,7 @@ AC_CONFIG_FILES([
        src/vendor/msgpack/Makefile
        tests/Makefile
        tests/destructive/Makefile
+       tests/meta/Makefile
        tests/regression/Makefile
        tests/regression/kernel/Makefile
        tests/regression/tools/Makefile
index 5e3ee4623b760ee6cac6f216aeb77d9f7545f80e..01babf7da37b00702baff59ecac0d65a2d95c194 100644 (file)
@@ -3,7 +3,7 @@
 SUBDIRS =
 
 if BUILD_TESTS
-SUBDIRS += . utils unit regression stress destructive perf
+SUBDIRS += . utils meta unit regression stress destructive perf
 if HAVE_PGREP
 check-am:
        $(top_srcdir)/tests/utils/warn_processes.sh $(PGREP)
diff --git a/tests/meta/Makefile.am b/tests/meta/Makefile.am
new file mode 100644 (file)
index 0000000..044fc83
--- /dev/null
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+LOG_DRIVER_FLAGS = --merge
+LOG_DRIVER = env PGREP='$(PGREP)' AM_TAP_AWK='$(AWK)' $(SHELL) \
+               $(top_srcdir)/tests/utils/tap-driver.sh
+
+TESTS = shellcheck-tests
diff --git a/tests/meta/shellcheck-tests b/tests/meta/shellcheck-tests
new file mode 100755 (executable)
index 0000000..49c8e73
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (c) 2023 Olivier Dion <odion@efficios.com>
+
+# Augment this list incrementally when a shell script passes shellcheck.
+#
+# All file must be relative to the test directory.
+files=(
+    meta/shellcheck-tests
+    run.sh
+)
+
+TESTDIR=$(dirname "$0")/..
+
+# shellcheck source=../utils/tap/tap.sh
+source "$TESTDIR/utils/tap/tap.sh"
+
+function shellcheck_ok() {
+    shellcheck --external-sources "$1"
+    ok $? "Checking $1"
+}
+
+plan_tests "${#files[@]}"
+
+for f in "${files[@]}";
+do
+    shellcheck_ok "$TESTDIR/$f"
+done
This page took 0.026712 seconds and 4 git commands to generate.