Add verbose flag to test shell script

This commit is contained in:
Brian Picciano 2023-08-30 20:08:40 +02:00
parent 2876b56afb
commit aa0d489e88
3 changed files with 21 additions and 3 deletions

View File

@ -167,6 +167,6 @@ in rec {
tests = pkgs.writeShellScript "isle-tests" ''
export PATH=$PATH:${appImage}/bin
test_dir=${./tests}
exec $SHELL $test_dir/entrypoint.sh
exec $SHELL $test_dir/entrypoint.sh "$@"
'';
}

View File

@ -1,2 +1,4 @@
version="$(isle version)"
test "$(echo "$version" | wc -l)" -gt 0
echo "$version" | grep -q 'Release:'
echo "$version" | grep -q 'Platform:'
echo "$version" | grep -q 'Build Platform:'

View File

@ -1,5 +1,18 @@
set -e
while [[ $# -gt 0 ]]; do
case $1 in
-v|--verbose)
VERBOSE=1
shift;
;;
*)
echo "USAGE: [-v|--verbose]"
exit 1
;;
esac
done
# cd into script's directory
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null
@ -13,7 +26,10 @@ echo -e '\nrunning all tests...\n'
for file in $(find . -type f -name '*.sh' | grep -v entrypoint.sh | sort -n); do
echo "running test $file"
if ! $SHELL -e -x "$file" >"$tmp/$file.log" 2>&1; then
[ -z "$VERBOSE" ] && output="$tmp/$file.log" || output=/dev/stdout
if ! $SHELL -e -x "$file" >"$output" 2>&1; then
echo "TEST FAILED"
echo "output of test is as follows"
echo "------------------------------"