-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·61 lines (58 loc) · 2 KB
/
test.sh
File metadata and controls
executable file
·61 lines (58 loc) · 2 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
repo_root="$PWD"
errors_file="$repo_root/meta/test-errors.txt"
timeout_secs="${CODEX_VIM_TEST_TIMEOUT:-15}"
mkdir -p "$repo_root/meta"
declare -a tests
if [ "$#" -eq 0 ]; then
tests=("test/smoke_basic.vim" "test/helptags.vim" "test/cursor_context.vim" "test/preview_content.vim" "test/tool_gate.vim" "test/tool_noindent.vim" "test/shutdown_cleanup.vim")
else
for arg in "$@"; do
case "$arg" in
smoke|smoke_basic|test/smoke_basic.vim) tests+=("test/smoke_basic.vim") ;;
help|helptags|test/helptags.vim) tests+=("test/helptags.vim") ;;
cursor|cursor_context|test/cursor_context.vim) tests+=("test/cursor_context.vim") ;;
preview|preview_content|test/preview_content.vim) tests+=("test/preview_content.vim") ;;
tool|tool_gate|test/tool_gate.vim) tests+=("test/tool_gate.vim") ;;
noindent|tool_noindent|test/tool_noindent.vim) tests+=("test/tool_noindent.vim") ;;
shutdown|shutdown_cleanup|test/shutdown_cleanup.vim) tests+=("test/shutdown_cleanup.vim") ;;
live|live_apply|test/live_apply.vim) tests+=("test/live_apply.vim") ;;
*.vim) tests+=("$arg") ;;
*) tests+=("test/${arg}.vim") ;;
esac
done
fi
for test_file in "${tests[@]}"; do
if [ ! -f "$test_file" ]; then
echo "missing test: $test_file" >&2
exit 1
fi
rm -f "$errors_file"
CODEX_VIM_REPO="$repo_root" CODEX_VIM_TEST_ERRORS="$errors_file" vim -Nu NONE -i NONE -n -es -S "$test_file" &
pid=$!
(
sleep "$timeout_secs"
if kill -0 "$pid" 2>/dev/null; then
printf 'test timed out after %ss: %s\n' "$timeout_secs" "$test_file" > "$errors_file"
kill "$pid" 2>/dev/null || true
sleep 1
kill -9 "$pid" 2>/dev/null || true
fi
) &
watcher=$!
if wait "$pid"; then
status=0
else
status=$?
fi
kill "$watcher" 2>/dev/null || true
wait "$watcher" 2>/dev/null || true
if [ "$status" -ne 0 ]; then
if [ -f "$errors_file" ]; then
cat "$errors_file" >&2
fi
exit 1
fi
done