blob: 5bab3dc436aeb1c901762303cbd5d56befe68eac (
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
{
pkgs,
lib,
}:
pkgs.writeShellScriptBin "run_test_description" ''
set -eu
[ "$#" -ne 1 ] && {
echo "Usage: $0 <Test description file>";
exit 2
}
description="$(realpath "$1")"
base="$(mktemp -d)"
cd "$base"
__TEST_TMUX="${lib.getExe pkgs.tmux}"
__TEST_SHELL="${lib.getExe pkgs.dash}"
__TEST_TMUX_PANE="__TEST_TMUX_PANE"
__TEST_EVAL_USE_ALTERNATE_SCREEN="false"
__TEST_EVAL_AWK_CLEAN_FILE="${./clean.awk}"
__TEST_EVAL_LOG_FILE="__test_log"
__TEST_EVAL_GOLDEN_FILE="$(mktemp)"
printf "%s" "__test_golden" >"$__TEST_EVAL_GOLDEN_FILE"
. ${./driver.sh}
echo "Setting up a session.."
if "$__TEST_TMUX" has-session -t "$__TEST_TMUX_PANE"; then
echo "Killing old '$__TEST_TMUX_PANE' session."
"$__TEST_TMUX" kill-session -t "$__TEST_TMUX_PANE"
fi
"$__TEST_TMUX" new-session -d -s "$__TEST_TMUX_PANE"
echo "Initializing pipe.."
"$__TEST_TMUX" pipe-pane -t "$__TEST_TMUX_PANE" -o 'cat >>./test.golden'
echo "Evaluating description.."
__test_eval "$description"
"$__TEST_TMUX" pipe-pane -t "$__TEST_TMUX_PANE"
echo "Base dir: $base"
''
|