selfcheck.sh (1018B)
- #!/bin/sh
- # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- set -o pipefail
- WD="$(realpath "$(dirname "$0")")"
- tmpdir=
- err=0
- run_test() {
- env MALLOC_CHECK_=3 POSIX_ME_HARDER=1 POSIXLY_CORRECT=1 LC_ALL=C.UTF-8 "$1" 2>&1
- return $?
- }
- cd "$WD"
- rm "${WD}/selfcheck.out"
- for runner in test-cmd/*.sh
- do
- [ "$runner" = "test-cmd/tap.sh" ] && continue
- [ "$runner" = "test-cmd/init_env.sh" ] && continue
- echo "${PS4}${runner}"
- if command -v mktemp 2>/dev/null >/dev/null
- then
- cd "$WD"
- tmpdir="$(mktemp -d selfcheck.XXXXXX)"
- cd "$tmpdir"
- fi
- run_test "${WD}/${runner}" | tee -a "$WD/selfcheck.out" | grep -v '^ok'
- ret="$?"
- if [ "$ret" != 0 ]
- then
- printf '## %s exited with code %s\n' "$runner" "$ret"
- err=1
- fi
- if [ -n "$tmpdir" ]
- then
- cd "$WD"
- if ! rm -d "$tmpdir"
- then
- printf '## Error: %s left files:\n%s\n' "$runner" "$(ls -R "$tmpdir")"
- err=1
- fi
- fi
- done
- [ $err = 0 ] && rm "${WD}/selfcheck.out"
- exit $err