Splux Linux

source-based Linux using SPS

SPS · log · files · refs · tags · releases · people · languages · GitHub · file

tests/run


Shell

871 bytes at 2909919 · GitHub

#!/bin/sh
set -eu

case $0 in
	*/*) test_dir=${0%/*} ;;
	*) test_dir=. ;;
esac
test_dir=$(CDPATH= cd -- "$test_dir" 2>/dev/null && pwd)

# A developer shell that has run src/sget exports SPS_* into the environment.
# Drop those so `make check` does not read the host config by accident.
unset SPS_ROOT SPS_CONFIG SPS_REPOS_CONFIG SPS_DB SPS_CACHE SPS_BUILD \
	SPS_LIBDIR SPS_REPO_ROOT SPS_COMPRESSION SPS_ARCH SPS_PRESERVE \
	SPS_MAKEJOBS 2>/dev/null || :

status=0
count=0
for test_file in "$test_dir"/test_*.sh; do
	[ -f "$test_file" ] || continue
	count=$((count + 1))
	printf '%s\n' "==> ${test_file##*/}"
	if "${TEST_SHELL:-/bin/sh}" "$test_file"; then
		printf '%s\n' "ok - ${test_file##*/}"
	else
		printf '%s\n' "not ok - ${test_file##*/}" >&2
		status=1
	fi
done

[ "$count" -gt 0 ] || {
	printf '%s\n' 'tests/run: no tests found' >&2
	exit 1
}

exit "$status"