aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/test.sh
blob: 59e7ce6e9597243e455a76748e6035ee3423af40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (c) 2026 Egor Tensin <egor@tensin.name>
# This file is part of the "test-harness" project.
# For details, see https://github.com/egor-tensin/test-harness
# Distributed under the MIT License.

test_should_fail=
test_root_dir=

test_setup_global() {
    test_root_dir="$( mktemp -d )"
    # mktemp returns /var/..., which is actually in /private/var/... on macOS.
    test_root_dir="$( readlink -e -- "$test_root_dir" )"
}

test_cleanup_global() {
    if [ "$( type -t test_cleanup )" == function ]; then
        test_cleanup || true
    fi
    if [ -n "$test_root_dir" ]; then
        log "Removing test's root directory: $test_root_dir"
        rm -rf -- "$test_root_dir"
    fi
}