Improve test output

This commit is contained in:
0x1eef 2024-05-12 21:16:56 -03:00
parent 6d0bccc3ed
commit fafc20c06b
2 changed files with 54 additions and 6 deletions

View file

@ -1,12 +1,36 @@
#!/bin/sh #!/bin/sh
set -e 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 rake clean clobber compile
rm -rf tmp/ rm -rf tmp/
for file in test/superuser/*_test.rb; do for file in test/superuser/*_test.rb; do
ruby -Ilib ${file} --no-use-color logfile=".runner.log_$(basename ${file})"
done if run_test "${file}" "${logfile}"; then
echo -n .
rm "${logfile}"
else else
echo "You must be the root user to run these tests." cat "${logfile}"
rm "${logfile}"
exit 1
fi
done
echo
else
echo "This script must be run by root"
exit 1 exit 1
fi fi

View file

@ -1,11 +1,35 @@
#!/bin/sh #!/bin/sh
set -e 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 rake clean clobber compile
for file in test/readme_examples_test.rb test/unprivileged/*_test.rb; do for file in test/readme_examples_test.rb test/unprivileged/*_test.rb; do
ruby -Ilib ${file} --no-use-color logfile=".runner.log_$(basename ${file})"
done if run_test "${file}" "${logfile}"; then
echo -n .
rm "${logfile}"
else else
echo "You must be an unprivileged user to run these tests." cat "${logfile}"
rm "${logfile}"
exit 1
fi
done
echo
else
echo "This script must be run by a user other than root"
exit 1 exit 1
fi fi