182ec13fae46fb781bfa9fced4503e56e980f786
[librseq.git] / tests / utils / utils.sh
1 #!/bin/bash
2 #
3 # SPDX-License-Identifier: MIT
4 #
5 # SPDX-FileCopyrightText: 2020 Michael Jeanson <mjeanson@efficios.com>
6 #
7
8 # This file is meant to be sourced at the start of shell script-based tests.
9
10
11 # Error out when encountering an undefined variable
12 set -u
13
14 # If "readlink -f" is available, get a resolved absolute path to the
15 # tests source dir, otherwise make do with a relative path.
16 scriptdir="$(dirname "${BASH_SOURCE[0]}")"
17 if readlink -f "." >/dev/null 2>&1; then
18 testsdir=$(readlink -f "$scriptdir/..")
19 else
20 testsdir="$scriptdir/.."
21 fi
22
23 # Allow overriding the source and build directories
24 if [ "x${RSEQ_TESTS_SRCDIR:-}" = "x" ]; then
25 RSEQ_TESTS_SRCDIR="$testsdir"
26 fi
27 export RSEQ_TESTS_SRCDIR
28
29 if [ "x${RSEQ_TESTS_BUILDDIR:-}" = "x" ]; then
30 RSEQ_TESTS_BUILDDIR="$testsdir"
31 fi
32 export RSEQ_TESTS_BUILDDIR
33
34 # By default, it will not source tap.sh. If you to tap output directly from
35 # the test script, define the 'SH_TAP' variable to '1' before sourcing this
36 # script.
37 if [ "x${SH_TAP:-}" = x1 ]; then
38 # shellcheck source=./tap.sh
39 . "${RSEQ_TESTS_SRCDIR}/utils/tap.sh"
40 fi
This page took 0.031459 seconds and 5 git commands to generate.