From 8e3b47bf898d950e5d625e4ecec0cfaf24b36050 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Tue, 1 Aug 2023 21:42:59 +0100 Subject: [PATCH] Added test to check that "make install" installs the expected set of files. --- doc/NEWS.md | 1 + tests/Bug_-_Install_all_files.sh | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/Bug_-_Install_all_files.sh diff --git a/doc/NEWS.md b/doc/NEWS.md index ad8a6e5..7782cd2 100644 --- a/doc/NEWS.md +++ b/doc/NEWS.md @@ -1,6 +1,7 @@ 0.0.20230801-UNRELEASED * cleanup: added a test for terminal width detection to "`make test`" + * cleanup: added a test to "`make test`" to ensure that "`make install`" installs everything expected 1.7.24 - 30 July 2023 diff --git a/tests/Bug_-_Install_all_files.sh b/tests/Bug_-_Install_all_files.sh new file mode 100644 index 0000000..a0ebc1e --- /dev/null +++ b/tests/Bug_-_Install_all_files.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Test that "make install" installs the expected minimum set of files. + +# Dummy assignments for "shellcheck". +testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}" + +makeDir="${testSubject%/*}" +if ! test -d "${makeDir}"; then + echo "could not find the directory to run \`make' in" + exit 2 +fi + +makeCommand=$(command -v gmake 2>/dev/null) +test -z "${makeCommand}" && makeCommand="make" + +testInstallDir=$(mktemp -d) +if ! test -n "${testInstallDir}"; then + echo "failed to create temporary installation directory" + exit 2 +fi + +export DESTDIR="${testInstallDir}" +if ! ${makeCommand} -C "${makeDir}" install DESTDIR="${testInstallDir}" >"${workFile1}" 2>&1; then + echo "\`make install' exited $?" + rm -rf "${testInstallDir}" + exit 1 +fi + +exitStatus=0 +if ! find "${testInstallDir}" -type f -name "pv.1*" | grep -Fq "pv.1"; then + echo "installation of man page failed" + exitStatus=1 +fi +if ! find "${testInstallDir}" -type f -name "pv*" | grep -Fv "pv.1" | grep -Fq "pv"; then + echo "installation of binary failed" + exitStatus=1 +fi + +# Only check for message catalogue files if any were defined in the Makefile. +if grep "^CATALOGS" "${makeDir}/Makefile" 2>/dev/null | cut -d = -f 2 | grep -Fq .mo; then + if ! find "${testInstallDir}" -type f -name "*.mo" | grep -Fq ".mo"; then + echo "installation of localisation files failed" + exitStatus=1 + fi +else + # There should always be some message catalogue files defined. + echo "no localisation files defined in the Makefile (\$CATALOGS is empty)" + exitStatus=1 +fi + +rm -rf "${testInstallDir}" +exit "${exitStatus}" + +# EOF