diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:44:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:44:55 +0000 |
commit | 5068d34c08f951a7ea6257d305a1627b09a95817 (patch) | |
tree | 08213e2be853396a3b07ce15dbe222644dcd9a89 /update_expected_output.sh | |
parent | Initial commit. (diff) | |
download | lnav-5068d34c08f951a7ea6257d305a1627b09a95817.tar.xz lnav-5068d34c08f951a7ea6257d305a1627b09a95817.zip |
Adding upstream version 0.11.1.upstream/0.11.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'update_expected_output.sh')
-rwxr-xr-x | update_expected_output.sh | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/update_expected_output.sh b/update_expected_output.sh new file mode 100755 index 0000000..ad416ee --- /dev/null +++ b/update_expected_output.sh @@ -0,0 +1,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 -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 -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" |