blob: f85252a32a68b9b86fd1499c3552a51f438ae0bf [file] [log] [blame]
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +01001#!/bin/sh -e
2#
3# The following steps are to be taken by this script:
4# 1) Remove all files from the "dumps" directory.
5# 2) Generate screendumps for each syntax test and each self-test.
6# 3) Unconditionally move each batch of screendumps to "dumps"; if generated
7# files differ on repeated runs, always remove these files from "dumps".
8# 4) Repeat steps 2) and 3) once or as many times as requested with the "$1"
9# argument.
10# 5) Summarise any differences.
11#
12# Provided that "git difftool" is set up (see src/testdir/commondumps.vim),
13# run "git difftool HEAD -- '**/*.dump'" to collate tracked and generated
14# screendumps.
15
16case "$1" in
17-h | --help)
18 printf >&2 "Usage: [time VIM_SYNTAX_TEST_LOG=/tmp/log] $0 [1 | 2 | ...]\n"
19 exit 0
20 ;;
21esac
22
23tries="${1:-1}"
24shift $#
25
26case "$tries" in
270* | *[!0-9]*)
28 exit 80
29 ;;
30esac
31
32test -x "$(command -v make)" || exit 81
33test -x "$(command -v git)" || exit 82
34
35case "$(git status --porcelain=v1)" in
36'') ;;
37*) printf >&2 'Resolve ALL changes before proceeding.\n'
38 exit 83
39 ;;
40esac
41
42templet=$(printf "\t\t\t\t$(tput rev)%%s$(tput sgr0)") || exit 84
43cd "$(dirname "$0")/../../../syntax" || exit 85
44set +f
45rm testdir/dumps/*.dump || exit 86
46spuriosities=''
47
48# Because the clean target of Make will be executed before each syntax test,
49# this environment variable needs to be pointed to an existing file that is
50# created in a directory not affectable by the target.
51if test -w "$VIM_SYNTAX_TEST_LOG"
52then
53 log=-e VIM_SYNTAX_TEST_LOG="$VIM_SYNTAX_TEST_LOG"
54else
55 log=
56fi
57
58for f in testdir/input/*.*
59do
60 test ! -d "$f" || continue
61 b=$(basename "$f")
62 i=0
63 printf "$templet\n\n" "$b"
64
65 while test "$i" -le "$tries"
66 do
67 make $log clean "$b" test || :
68
69 case "$i" in
70 0) mv testdir/failed/*.dump testdir/dumps/
71 ;;
72 *) case "$(printf '%s' testdir/failed/*.dump)" in
73 testdir/failed/\*.dump)
74 # (Repeatable) success.
75 ;;
76 *) spuriosities="${spuriosities}${b} "
77 p=${b%.*}
78 rm -f testdir/dumps/"$p"_[0-9][0-9].dump \
79 testdir/dumps/"$p"_[0-9][0-9][0-9].dump \
80 testdir/dumps/"$p"_[0-9][0-9][0-9][0-9].dump
81 ;;
82 esac
83 ;;
84 esac
85
86 i=$(($i + 1))
87 sleep 1
88 done
89done
90
91# For a 20-file set, initially fail for a series of: 1-6, 7-12, 13-18, 19-20.
92tries=$(($tries + 3))
93i=0
94
95while test "$i" -le "$tries"
96do
97 make $log clean self-testing test || :
98
99 case "$i" in
100 [0-3]) mv testdir/failed/dots_*.dump testdir/dumps/
101 ;;
102 *) case "$(printf '%s' testdir/failed/*.dump)" in
103 testdir/failed/\*.dump)
104 # (Repeatable) success.
105 ;;
106 *) spuriosities="${spuriosities}dots_xy "
107 rm -f testdir/dumps/dots_*.dump
108 ;;
109 esac
110 ;;
111 esac
112
113 sleep 1
114 i=$(($i + 1))
115done
116
117make clean
118git diff --compact-summary
119
120if test -n "$spuriosities"
121then
122 printf '\n%s\n' "$spuriosities"
123 exit 87
124fi
125
126# vim:sw=8:ts=8:noet:nosta: