Skip to content

Commit

Permalink
Streamline approach for selecting shell files in test targets
Browse files Browse the repository at this point in the history
Use the `find`-command used for `shellcheck` also for `shfmt`. It is faster
than `shfmt`, does not need an explicit exclusion for `node_modules` and
does not stop on the first error (e.g. permission error).
  • Loading branch information
Martchus committed Feb 12, 2024
1 parent a80e571 commit 6227ed8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
container_env_file := "$(current_dir)/container.env"
unstables := $(shell cat tools/unstable_tests.txt | tr '\n' :)
shellfiles := $$(file --mime-type script/* t/* container/worker/*.sh tools/* | sed -n 's/^\(.*\):.*text\/x-shellscript.*$$/\1/p')

# tests need these environment variables to be unset
OPENQA_BASEDIR =
Expand Down Expand Up @@ -313,7 +314,7 @@ test-tidy-compile:
.PHONY: test-shellcheck
test-shellcheck:
@which shellcheck >/dev/null 2>&1 || (echo "Command 'shellcheck' not found, can not execute shell script checks" && false)
shellcheck -x $$(file --mime-type script/* t/* container/worker/*.sh tools/* | sed -n 's/^\(.*\):.*text\/x-shellscript.*$$/\1/p')
shellcheck -x $(shellfiles)

.PHONY: test-yaml
test-yaml:
Expand All @@ -324,7 +325,7 @@ test-yaml:
.PHONY: test-shfmt
test-shfmt:
@which shfmt >/dev/null 2>&1 || (echo "Command 'shfmt' not found, can not execute bash script syntax checks" && false)
shfmt -d -i 4 -bn -ci -sr $$(shfmt -f . | grep --invert-match node_modules)
shfmt -d -i 4 -bn -ci -sr $(shellfiles)

.PHONY: test-check-containers
test-check-containers:
Expand Down

0 comments on commit 6227ed8

Please sign in to comment.