From c141039755df5bd7fb0504c4e7f20d1fe5a1786f Mon Sep 17 00:00:00 2001 From: Olivier Dion Date: Mon, 6 Feb 2023 14:21:07 -0500 Subject: [PATCH] Tests: Add meta shellcheck test MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Jérémie Galarneau --- configure.ac | 1 + tests/Makefile.am | 2 +- tests/meta/Makefile.am | 7 +++++++ tests/meta/shellcheck-tests | 29 +++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/meta/Makefile.am create mode 100755 tests/meta/shellcheck-tests diff --git a/configure.ac b/configure.ac index 11d931759..6605bf95a 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index 5e3ee4623..01babf7da 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..044fc83c9 --- /dev/null +++ b/tests/meta/Makefile.am @@ -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 index 000000000..49c8e73d1 --- /dev/null +++ b/tests/meta/shellcheck-tests @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (c) 2023 Olivier Dion + +# 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 -- 2.34.1