Reduce bloat in test runners

This commit is contained in:
0x1eef 2024-10-12 13:55:37 -03:00
parent a04dbc90ab
commit 4ca4a06896
2 changed files with 33 additions and 56 deletions

View file

@ -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

View file

@ -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