From fafc20c06bdafaf82810eeb07ff359f315105a02 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sun, 12 May 2024 21:16:56 -0300 Subject: [PATCH] Improve test output --- bin/run-superuser-tests | 30 +++++++++++++++++++++++++++--- bin/run-unprivileged-tests | 30 +++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/bin/run-superuser-tests b/bin/run-superuser-tests index a6e6484..9c65c41 100755 --- a/bin/run-superuser-tests +++ b/bin/run-superuser-tests @@ -1,12 +1,36 @@ #!/bin/sh set -e -if [ $(id -u) = 0 ]; then + +## +# functions +run_test() +{ + testfile="${1}" + logfile="${2}" + ruby -Ilib \ + "${testfile}" \ + --no-use-color \ + > "${logfile}" 2>&1 +} + +## +# main +if [ "$(id -u)" = "0" ]; then rake clean clobber compile rm -rf tmp/ for file in test/superuser/*_test.rb; do - ruby -Ilib ${file} --no-use-color + logfile=".runner.log_$(basename ${file})" + if run_test "${file}" "${logfile}"; then + echo -n . + rm "${logfile}" + else + cat "${logfile}" + rm "${logfile}" + exit 1 + fi done + echo else - echo "You must be the root user to run these tests." + echo "This script must be run by root" exit 1 fi diff --git a/bin/run-unprivileged-tests b/bin/run-unprivileged-tests index c4adff2..719b7c6 100755 --- a/bin/run-unprivileged-tests +++ b/bin/run-unprivileged-tests @@ -1,11 +1,35 @@ #!/bin/sh set -e -if [ $(id -u) -ne 0 ]; then + +## +# functions +run_test() +{ + testfile="${1}" + logfile="${2}" + ruby -Ilib \ + "${testfile}" \ + --no-use-color \ + > "${logfile}" 2>&1 +} + +## +# main +if [ "$(id -u)" != "0" ]; then rake clean clobber compile for file in test/readme_examples_test.rb test/unprivileged/*_test.rb; do - ruby -Ilib ${file} --no-use-color + logfile=".runner.log_$(basename ${file})" + if run_test "${file}" "${logfile}"; then + echo -n . + rm "${logfile}" + else + cat "${logfile}" + rm "${logfile}" + exit 1 + fi done + echo else - echo "You must be an unprivileged user to run these tests." + echo "This script must be run by a user other than root" exit 1 fi