Files
scwrypts/zsh/unittest/execute-test-file.module.zsh
T
wrynegade e7484103b9 v5.1.0
=====================================================================

A follow-up to V5 focused on hardening the environment system and
expanding the ZSH logging/caching toolkit. No migration required from
v5.0.x, though note the log-level reorganization below may quiet some
messages at lower verbosities.

--- New Features -------------------------

- persistent cross-runtime cache for ZSH-type scwrypts; extends the
  v5.0 runtime speedup cache to survive between runs with automatic
  hash-based invalidation (toggle via SCWRYPTS__ZSH_CACHE_ENABLED)

- new 'trace' log level (5) and echo.trace, plus '-v VARNAME' state
  injection for echo.debug / echo.trace to surface variable values
  inline

- additional scwrypts output formats: 'raw' and 'logfmt'
  (alongside pretty and json)

- normalize.boolean utility for consistent truthy/falsey handling
  across ZSH-type scwrypts

- utils.fzf.file-select for directory-scoped file selection prompts

- automatic dependency wrappers providing default arguments, GNU
  coreutil resolution, and scwrypts trace on wrapped commands

--- Changes ------------------------------

- log levels reorganized; success / status / reminder messages now
  emit at level 3, so lower verbosities will show fewer of these

- environment library restructured around get-user-json as the single
  source of truth (replaces the previous user module and cache-output)

- utility renames for consistency: user.Yn / user.yN (from utils.*)

- utils.fail and utils.abort deprecated in favor of echo.error and
  echo.error.user-abort

--- Bug Fixes ----------------------------

- CI runs now resolve config lookup-paths (.dotted.path) to their
  environment variable before reading, fixing false "not set" reports
  and invalid-export errors for lookup-path checks in CI

- hardened environment type detection so array-valued configs reprint
  correctly after their first check

- corrected exit-code capture in the cache layer (now reflects the
  cached command, not the downstream output filter)

- scwrypt exit code now survives the logging pipeline

- assorted script fixes (efs unmount file listing, postgres run-sql
  file discovery)
2026-08-14 12:28:08 -06:00

52 lines
1.6 KiB
Bash

#####################################################################
use unittest/operations
#####################################################################
${scwryptsmodule}() {
local ERRORS=0 TEST_ERRORS=0
[[ "$SCWRYPTS_LOG_LEVEL" ]] || local SCWRYPTS_LOG_LEVEL=4
local UNITTESTS=($(echo "${(k)functions}" | sed 's/ /\n/g' | grep '^test\.' | sort))
[[ ${#UNITTESTS[@]} -gt 0 ]] \
|| echo.error "must define at least one unittest" \
|| return 1
echo.status "${SCWRYPTS_TEST_MODULE_STRING}starting test suite"
local UNITTEST_RESULTS_DIR="${SCWRYPTS_TEMP_PATH}/test"
mkdir -p "${UNITTEST_RESULTS_DIR}"
local TEST_COUNT=0
command -v beforeall &>/dev/null && beforeall
local UNITTEST
for UNITTEST in ${UNITTESTS[@]}
do
((TEST_COUNT+=1))
ERRORS=0
command -v beforeeach &>/dev/null && beforeeach
${UNITTEST} &> "${UNITTEST_RESULTS_DIR}/${UNITTEST}.txt" \
&& echo.success "${SCWRYPTS_TEST_MODULE_STRING}${UNITTEST}" \
|| { echo.error "${SCWRYPTS_TEST_MODULE_STRING}${UNITTEST}"; ((TEST_ERRORS+=1)); echo "--- begin test output ---">&2; cat "${UNITTEST_RESULTS_DIR}/${UNITTEST}.txt"; echo "--- end test output ---\n">&2; }
command -v aftereach &>/dev/null && aftereach
unittest.operations restore
unittest.mock.env.restore
done
command -v afterall &>/dev/null && afterall
local EXIT_CODE=$TEST_ERRORS
[[ $TEST_ERRORS -eq 0 ]] \
&& echo.success "${SCWRYPTS_TEST_MODULE_STRING}passed ${TEST_COUNT} / ${TEST_COUNT} test(s)" \
|| echo.error "${SCWRYPTS_TEST_MODULE_STRING}failed ${EXIT_CODE} / ${TEST_COUNT} test(s)" \
;
return $EXIT_CODE
}