-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_manpage.sh
executable file
·98 lines (74 loc) · 1.58 KB
/
test_manpage.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
# Tests man pages.
#
# Version: 20240413
EXIT_SUCCESS=0;
EXIT_FAILURE=1;
EXIT_IGNORE=77;
run_test()
{
local INPUT_FILE=$1;
local RESULT=0
TEST_NAME=`basename ${INPUT_FILE}`;
echo -n "Testing man with input: ${TEST_NAME}";
LC_ALL=en_US.UTF-8 MANROFFSEQ='' MANWIDTH=80 man --warnings -E UTF-8 -l -Tutf8 -Z ${INPUT_FILE} > /dev/null 2> ${TMPDIR}/${TEST_NAME}.warnings;
RESULT=$?;
# For now line break warnings are ignored.
if test -f ${TMPDIR}/${TEST_NAME}.warnings;
then
sed "/can't break line/ d" -i ${TMPDIR}/${TEST_NAME}.warnings;
fi
if test -s ${TMPDIR}/${TEST_NAME}.warnings;
then
RESULT=${EXIT_FAILURE};
fi
if test ${RESULT} -ne ${EXIT_SUCCESS};
then
echo " (FAIL)";
else
echo " (PASS)";
fi
if test -s ${TMPDIR}/${TEST_NAME}.warnings;
then
cat ${TMPDIR}/${TEST_NAME}.warnings;
fi
return ${RESULT};
}
if test "${OSTYPE}" = "msys";
then
exit ${EXIT_IGNORE};
fi
TEST_DIRECTORY=`dirname $0`;
TEST_RUNNER="${TEST_DIRECTORY}/test_runner.sh";
if ! test -f "${TEST_RUNNER}";
then
echo "Missing test runner: ${TEST_RUNNER}";
exit ${EXIT_FAILURE};
fi
source ${TEST_RUNNER};
assert_availability_binary man;
RESULT=${EXIT_IGNORE};
TMPDIR="tmp$$";
rm -rf ${TMPDIR};
mkdir ${TMPDIR};
MANUALS_PATH="../manuals";
if ! test -d ${MANUALS_PATH};
then
MANUALS_PATH="manuals";
fi
if ! test -d ${MANUALS_PATH};
then
echo "Manuals directory not found.";
exit ${EXIT_IGNORE};
fi
for INPUT_FILE in ${MANUALS_PATH}/*.[13];
do
run_test "${INPUT_FILE}";
RESULT=$?;
if test ${RESULT} -ne ${EXIT_SUCCESS};
then
break;
fi
done
rm -rf ${TMPDIR};
exit ${RESULT};