diff options
| author | Egor Tensin <egor@tensin.name> | 2026-10-14 22:50:19 +0500 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-10-14 22:50:19 +0500 |
| commit | 1113be584b46e7e037a2bc4ece9b3b938969ec75 (patch) | |
| tree | 937e7a6cf516db8c27c5373aae5ccfcbf9c8cd55 /lib | |
| parent | main.sh: add proper command line parameters & usage info (diff) | |
| download | test-harness-1113be584b46e7e037a2bc4ece9b3b938969ec75.tar.gz test-harness-1113be584b46e7e037a2bc4ece9b3b938969ec75.zip | |
shuffle files around, add the top-level symlinkv0.3.0
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/log.sh | 139 | ||||
| -rw-r--r-- | lib/test.sh | 23 |
2 files changed, 0 insertions, 162 deletions
diff --git a/lib/log.sh b/lib/log.sh deleted file mode 100644 index db2c498..0000000 --- a/lib/log.sh +++ /dev/null @@ -1,139 +0,0 @@ -# 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. - -log() { - local msg - for msg; do - echo -e "$test_file | $msg" >&2 - done -} - -log_run() { - if [ "$#" -lt 1 ]; then - log "usage: ${FUNCNAME[0]} ARGV0 [ARG...]" - return 1 - fi - - local msg='Running:' - msg="$msg$( printf -- ' %q' "$@" )" - log "$msg" -} - -fail() { - local msg - for msg; do - log "FAIL: $msg" - done -} - -fail_details() { - local msg - for msg; do - fail " $msg" - done -} - -_log_numof_tests_ok=0 -_log_numof_tests_failed=0 -declare -a _log_tests_failed=() -declare -A _log_tests_should_fail=() - -_log_test_start() { - if [ "$#" -ne 1 ]; then - echo "usage: ${FUNCNAME[0]} TEST_FILE" >&2 - return 1 - fi - - local test_file="$1" - - if [ -n "${test_should_fail:-}" ]; then - _log_tests_should_fail["$test_file"]=1 - fi - - cat <<EOF >&2 - -====================================================================== -TEST: $test_file -====================================================================== -EOF - - log "Should fail: ${test_should_fail:-No}" -} - -_log_test_ok() { - if [ "$#" -ne 1 ]; then - echo "usage: ${FUNCNAME[0]} TEST_FILE" >&2 - return 1 - fi - - _log_numof_tests_ok=$((_log_numof_tests_ok + 1)) - - cat <<EOF >&2 ----------------------------------------------------------------------- -OK: $1 ----------------------------------------------------------------------- -EOF -} - -_log_test_fail() { - if [ "$#" -ne 1 ]; then - echo "usage: ${FUNCNAME[0]} TEST_FILE" >&2 - return 1 - fi - - _log_numof_tests_failed=$((_log_numof_tests_failed + 1)) - _log_tests_failed+=("$1") - - cat <<EOF >&2 ----------------------------------------------------------------------- -FAIL: $1 ----------------------------------------------------------------------- -EOF -} - -_log_test_finish() { - if [ "$#" -ne 2 ]; then - echo "usage: ${FUNCNAME[0]} TEST_FILE EXIT_CODE" >&2 - return 1 - fi - - local test_file="$1" - local ret="$2" - local test_should_fail - test_should_fail="${_log_tests_should_fail["$test_file"]:+x}" - - if [ "$ret" -eq 0 ] || [ -n "$test_should_fail" ]; then - _log_test_ok "$test_file" - else - _log_test_fail "$test_file" - fi -} - -_log_tests_summary() { - cat <<EOF >&2 - -====================================================================== -SUMMARY -====================================================================== -OK: $_log_numof_tests_ok -FAIL: $_log_numof_tests_failed -EOF - - local test_file - for test_file in ${_log_tests_failed[@]+"${_log_tests_failed[@]}"}; do - cat <<EOF >&2 -FAIL: $test_file -EOF - done - - cat <<EOF >&2 ----------------------------------------------------------------------- -EOF - - local ret=0 - [ "$_log_numof_tests_failed" -gt 0 ] && ret=1 - - return "$ret" -} diff --git a/lib/test.sh b/lib/test.sh deleted file mode 100644 index 7c5844b..0000000 --- a/lib/test.sh +++ /dev/null @@ -1,23 +0,0 @@ -# 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 -} |
