From 4ca4a06896a8cf1827a004d9a0ce0eef33e523ed Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sat, 12 Oct 2024 13:55:37 -0300 Subject: [PATCH] Reduce bloat in test runners --- bin/run-superuser-tests | 44 ++++++++++++++----------------------- bin/run-unprivileged-tests | 45 ++++++++++++++------------------------ 2 files changed, 33 insertions(+), 56 deletions(-) diff --git a/bin/run-superuser-tests b/bin/run-superuser-tests index 9388581..6f093c8 100755 --- a/bin/run-superuser-tests +++ b/bin/run-superuser-tests @@ -1,36 +1,24 @@ #!/bin/sh set -e -## -# functions -run_test() -{ - testfile="${1}" - logfile="${2}" - ruby -Ilib \ - "${testfile}" \ - --no-use-color \ - > "${logfile}" 2>&1 -} - ## # main -if [ "$(id -u)" = "0" ]; then - bundle exec rake clean clobber compile - rm -rf tmp/ - for file in test/superuser/*_test.rb; do - 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 +if [ "$(id -u)" != "0" ]; then echo "This script must be run by root" exit 1 fi + +bundle exec rake clean clobber compile +rm -rf tmp/ +for test in test/superuser/*_test.rb; do + log=".$(basename "${test}")_log.txt" + if ruby -Ilib "${test}" --no-use-color > "${log}" 2>&1; then + printf "." + rm "${log}" + else + cat "${log}" + rm "${log}" + exit 1 + fi +done +echo diff --git a/bin/run-unprivileged-tests b/bin/run-unprivileged-tests index eca4ba3..70e44a8 100755 --- a/bin/run-unprivileged-tests +++ b/bin/run-unprivileged-tests @@ -1,35 +1,24 @@ #!/bin/sh set -e -## -# functions -run_test() -{ - testfile="${1}" - logfile="${2}" - ruby -Ilib \ - "${testfile}" \ - --no-use-color \ - > "${logfile}" 2>&1 -} - ## # main -if [ "$(id -u)" != "0" ]; then - bundle exec rake clean clobber compile - for file in test/unprivileged/*_test.rb; do - 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 "This script must be run by a user other than root" +if [ "$(id -u)" = "0" ]; then + echo "This script can't be run by root" exit 1 fi + +bundle exec rake clean clobber compile +rm -rf tmp/ +for test in test/unprivileged/*_test.rb; do + log=".$(basename "${test}")_log.txt" + if ruby -Ilib "${test}" --no-use-color > "${log}" 2>&1; then + printf "." + rm "${log}" + else + cat "${log}" + rm "${log}" + exit 1 + fi +done +echo