Add some tests for shell scripts

pull/15/head
Simon Let 6 years ago
parent 7eeb249722
commit 0bcf3fd3a9
  1. 7
      Makefile
  2. 20
      scripts/test.sh

@ -41,15 +41,18 @@ sanitize:
# #
# #
build: test submodules bin/resh-collect bin/resh-daemon bin/resh-evaluate bin/resh-sanitize build: test_go submodules bin/resh-collect bin/resh-daemon bin/resh-evaluate bin/resh-sanitize
test: test_go:
# Running tests # Running tests
@for dir in {cmd,pkg}/* ; do \ @for dir in {cmd,pkg}/* ; do \
echo $$dir ; \ echo $$dir ; \
go test $$dir/*.go ; \ go test $$dir/*.go ; \
done done
test:
scripts/test.sh
rebuild: rebuild:
make clean make clean
make build make build

@ -0,0 +1,20 @@
#!/usr/bin/env bash
[ "${BASH_SOURCE[0]}" != "scripts/test.sh" ] && echo 'Run this script using `make test`' && exit 1
for f in scripts/*.sh; do
echo "Running shellcheck on $f ..."
shellcheck $f --shell=bash --severity=error || exit 1
done
echo "Checking Zsh syntax of scripts/shellrc.sh ..."
! zsh -n scripts/shellrc.sh && echo "Zsh syntax check failed!" && exit 1
for sh in bash zsh; do
echo "Running functions in scripts/shellrc.sh using $sh ..."
! $sh -c ". scripts/shellrc.sh; __resh_preexec; __resh_precmd" && echo "Error while running functions!" && exit 1
done
# TODO: test installation
exit 0
Loading…
Cancel
Save