From e6226251e5603810d2e8211cd46f16ec43e3339f Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 29 Oct 2021 19:43:53 +0200 Subject: test: Add shellcheck --- Makefile | 1 + README.md | 1 + configure | 21 +++++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0ff8b3d..9504203 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,7 @@ uri_test: uri.o uri_test.o .PHONY: test test: $(EXE_test) $(MANDOC) -Tlint -Wunsupp,error,warning ./badwolf.1 + $(SHELLCHECK) ./configure .PHONY: install install: all diff --git a/README.md b/README.md index e5205e1..d8b088b 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Dependencies are: - A pkg-config implementation (pkgconf is recommended) - (optional) gettext implementation (such as GNU Gettext) - (optional, test) [mandoc](https://mdocml.bsd.lv/) (the command) for linting the manpage +- (optional, test) [shellcheck](https://www.shellcheck.net/) for linting the `./configure` script Compilation is done with `./configure && make`, install with `make install` (`DESTDIR` and `PREFIX` environment variables are supported, amongs other common ones). An example AppArmor profile is provided at `usr.bin.badwolf`, please do some long runtime checks before shipping it or a modified version, help can be provided but with no support. diff --git a/configure b/configure index b0a705e..aa2647c 100755 --- a/configure +++ b/configure @@ -26,6 +26,7 @@ Variables: CFLAGS=OPTIONS EXTRA_CFLAGS=OPTIONS MANDOC=BIN + SHELLCHECK=BIN WITH_WEBKITGTK=(4.0|4.1) WITH_URI_PARSER=(guri|libsoup2) @@ -37,7 +38,8 @@ Dependencies: - libxml-2.0 - webkit2gtk-4.1 version >=${min_webkitgtk} or webkit2gtk-4.0 version >=${min_webkitgtk} - libsoup-2.4 or glib-2.0 version >=${min_glib_guri} -- mandoc: for linting the manual page (optionnal, test dep) +- mandoc: for linting the manual page (optional, test dep) +- shellcheck: for linting ./configure (optional, test dep) END } @@ -73,6 +75,7 @@ INKSCAPE="${INKSCAPE:-inkscape}" CC="${CC:-cc}" CFLAGS="${CFLAGS:--g -O2 -pie -fPIE}" MANDOC="${MANDOC:-mandoc}" +SHELLCHECK="${SHELLCHECK:-shellcheck}" # Also allow variables through arguments @@ -111,6 +114,7 @@ APPSDIR="${APPSDIR:-${PREFIX}/share/applications}" CFLAGS="${CFLAGS} -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla ${EXTRA_CFLAGS}" ## System checks +# commands printf 'Checking %s command existance ...' "${PKGCONFIG}" command -v "${PKGCONFIG}" >/dev/null ; required @@ -122,10 +126,22 @@ if command -v "${MANDOC}" >/dev/null ; is_ok then : else + printf 'Warning: Tests depending on mandoc disabled' MANDOC="true" fi +printf 'Checking %s command existance ...' "${SHELLCHECK}" +if command -v "${SHELLCHECK}" >/dev/null ; is_ok +then + : +else + printf 'Warning: Tests depending on shellcheck disabled' + SHELLCHECK="true" +fi + +echo +# pkg-config for dep in ${DEPS} do pkg_config_check --exists "$dep" || exit 1 @@ -209,7 +225,7 @@ required ## Configuration write -printf 'Writing to config.mk ...' +printf '\nWriting to config.mk ...' cat >config.mk <