forked from tstack/lnav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_expected_output.sh
executable file
·99 lines (88 loc) · 2.66 KB
/
update_expected_output.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
98
99
#!/usr/bin/env bash
srcdir="$1"
builddir="$2"
expected_dir="$1/expected"
expected_am="${expected_dir}/expected.am"
mkdir -p "${expected_dir}"
for fname in $(ls -t ${builddir}/*.cmd); do
echo
echo "Checking test ${fname}:"
echo -n " "
cat "${fname}"
stem=$(echo $fname | sed -e 's/.cmd$//')
exp_stem="${srcdir}/expected/$(basename $stem)"
echo " \$(srcdir)/%reldir%/$(basename "$stem").out \\" >> "${expected_am}.tmp"
echo " \$(srcdir)/%reldir%/$(basename "$stem").err \\" >> "${expected_am}.tmp"
if ! test -f "${exp_stem}.out"; then
printf '\033[0;32mBEGIN\033[0m %s.out\n' "${stem}"
cat "${stem}.out"
printf '\033[0;32mEND\033[0m %s.out\n' "${stem}"
if test x"${AUTO_APPROVE}" = x""; then
echo "Expected stdout is missing, update with the above?"
select yn in "Yes" "No"; do
case $yn in
Yes ) cp "${stem}.out" "${exp_stem}.out"; break;;
No ) exit;;
esac
done
else
cp "${stem}.out" "${exp_stem}.out"
fi
else
if ! cmp "${exp_stem}.out" "${stem}.out"; then
diff --color=always -u "${exp_stem}.out" "${stem}.out"
if test x"${AUTO_APPROVE}" = x""; then
echo "Expected stdout is different, update with the above?"
select yn in "Yes" "No"; do
case $yn in
Yes ) cp "${stem}.out" "${exp_stem}.out"; break;;
No ) exit;;
esac
done
else
cp "${stem}.out" "${exp_stem}.out"
fi
fi
fi
if ! test -f "${exp_stem}.err"; then
printf '\033[0;31mBEGIN\033[0m %s.err\n' "${stem}"
cat "${stem}.err"
printf '\033[0;31mEND\033[0m %s.err\n' "${stem}"
if test x"${AUTO_APPROVE}" = x""; then
echo "Expected stderr is missing, update with the above?"
select yn in "Yes" "No"; do
case $yn in
Yes ) cp "${stem}.err" "${exp_stem}.err"; break;;
No ) exit;;
esac
done
else
cp "${stem}.err" "${exp_stem}.err"
fi
else
if ! cmp "${exp_stem}.err" "${stem}.err"; then
diff --color=always -u "${exp_stem}.err" "${stem}.err"
if test x"${AUTO_APPROVE}" = x""; then
echo "Expected stderr is different, update with the above?"
select yn in "Yes" "No"; do
case $yn in
Yes ) cp "${stem}.err" "${exp_stem}.err"; break;;
No ) exit;;
esac
done
else
cp "${stem}.err" "${exp_stem}.err"
fi
fi
fi
done
cat > "${expected_am}.new" <<EOF
EXPECTED_FILES = \\
$(sort "${expected_am}.tmp")
\$()
EOF
if ! cmp "${expected_am}" "${expected_am}.new"; then
cp "${expected_am}.new" "${expected_am}"
fi
rm "${expected_am}.new"
rm "${expected_am}.tmp"