Page MenuHomec4science

run_tests.sh
No OneTemporary

File Metadata

Created
Tue, May 14, 02:33

run_tests.sh

#!/bin/bash
#########################################################################
function test_output {
name=$( basename $1 .verified )
echo "Testing $name output"
echo -n "------------ "
diff $name.out $name.verified >/dev/null 2>&1
return $?
}
#########################################################################
function test_return {
name=$( basename $1 .py )
echo "Testing $name.py"
echo -n "------------ "
PYTHONPATH=../python python $name.py >$name.out 2>$name.err
return $?
}
#########################################################################
function test_exec {
echo "Testing $1"
echo -n "------------ "
./$1 >/dev/null 2>&1
return $?
}
#########################################################################
tamaas_path=$(PYTHONPATH=../python python -c 'import tamaas; print(tamaas)' | cut -d "'" -f 4 )
tamaas_lib_path=$(ldd ../python/_tamaas.so | grep -e 'libTamaas.so' | cut -d " " -f 3)
echo "Tamaas test suite"
echo "================="
echo ""
echo "importing tamaas from $tamaas_path"
echo "importing library from $tamaas_lib_path"
echo ""
n_tests=0
passed_tests=0
for test_file in test_*; do
# Filtering files with an extension
if [[ ! $test_file =~ test_[^\.]+$ ]]; then
continue
fi
((n_tests++))
test_exec $test_file
result=$?
if [ $result -ne 0 ]; then
echo "failure"
else
echo "success"
((passed_tests++))
fi
done
for test_file in test_*.py; do
((n_tests++))
test_return $test_file
result=$?
if [ $result -ne 0 ]; then
echo "failure"
else
echo "success"
((passed_tests++))
fi
done
for test_file in test_*.verified; do
# In case no .verified files exist
if [ $test_file = "test_*.verified" ]; then
break
fi
((n_tests++))
test_output $test_file
result=$?
if [ $result -ne 0 ]; then
echo "failure"
else
echo "success"
((passed_tests++))
fi
done
failed_tests=$((n_tests - passed_tests))
echo ""
echo "Test results :"
echo " - passed $passed_tests/$n_tests"
echo " - failed $failed_tests/$n_tests"

Event Timeline