git-wad

Manage files via git but not their content
git clone git://git.meso-star.fr/git-wad.git
Log | Files | Refs | README | LICENSE

commit a6b2748bacef95af6b10c056130b4dd7b196b86f
parent 958b6e995ab87f2c3f528c667562367e08646e0a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 31 Jan 2025 15:11:43 +0100

Clean up the way output status is returned in the test

Don't call the die function directly. Instead, let the exit signal
invoke it automatically to clean up temporary files and return the
output status.

Diffstat:
Mtest_tiny_bin.sh | 29+++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/test_tiny_bin.sh b/test_tiny_bin.sh @@ -20,18 +20,22 @@ set -e die() { rm -rf "${tmpdir}" # cleanup temporary files - exit "${1:-1}" # return status code (default is 1) + return "${1:-1}" # return status code (default is 1) } +# Configure signal processing +trap 'die $?' EXIT +trap 'die 1' TERM INT + git_wad="$(pwd)/git-wad" # Working directory -tmpdir="$(mktemp -d "${TMPDIR:-/tmp}"/git_wad_test_XXXXXX)" || die "$?" +tmpdir="$(mktemp -d "${TMPDIR:-/tmp}"/git_wad_test_XXXXXX)" repo="${tmpdir}/tiny_bin" -# Configure signal processing -trap "die 1" TERM INT - +######################################################################## +# Test setup +######################################################################## # Create the bare repository mkdir -p "${repo}.git" git init --bare "${repo}.git" @@ -64,6 +68,9 @@ git remote add origin "file://${repo}.git" git push origin master "${git_wad}" push +######################################################################## +# The test +######################################################################## # Clone a fresh git working directory from the remote cd "${tmpdir}" git clone "file://${repo}.git" @@ -71,11 +78,11 @@ git clone "file://${repo}.git" # Check that files managed by git-wad have not yet been restored, # whereas normal files are the same as the originals, i.e. they are not # actually managed by git and not git-wad. -! diff "${repo}/file0.bin" "${repo}_ref/file0.bin" || die $? -! diff "${repo}/file1.bin" "${repo}_ref/file1.bin" || die $? -! diff "${repo}/file2.bin" "${repo}_ref/file2.bin" || die $? -! diff "${repo}/file3.bin" "${repo}_ref/file3.bin" || die $? -! diff "${repo}/file4.bin" "${repo}_ref/file4.bin" || die $? +! diff "${repo}/file0.bin" "${repo}_ref/file0.bin" || exit "$?" +! diff "${repo}/file1.bin" "${repo}_ref/file1.bin" || exit "$?" +! diff "${repo}/file2.bin" "${repo}_ref/file2.bin" || exit "$?" +! diff "${repo}/file3.bin" "${repo}_ref/file3.bin" || exit "$?" +! diff "${repo}/file4.bin" "${repo}_ref/file4.bin" || exit "$?" diff "${repo}/README" "${repo}_ref/README" diff "${repo}/.gitattributes" "${repo}_ref/.gitattributes" @@ -94,5 +101,3 @@ diff "${repo}/file3.bin" "${repo}_ref/file3.bin" diff "${repo}/file4.bin" "${repo}_ref/file4.bin" diff "${repo}/README" "${repo}_ref/README" diff "${repo}/.gitattributes" "${repo}_ref/.gitattributes" - -die 0