Add unit test coverage test script #14
This commit is contained in:
parent
acba9e7a5d
commit
dd6e12e9c2
36
scripts/check_test_coverage.sh
Executable file
36
scripts/check_test_coverage.sh
Executable file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -d spec ]
|
||||||
|
then
|
||||||
|
echo "Error: spec folder not found"
|
||||||
|
echo " run this script from the root of repo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
function missing_unit_tests() {
|
||||||
|
local ruby_file
|
||||||
|
local got_err=0
|
||||||
|
while read -r ruby_file
|
||||||
|
do
|
||||||
|
ruby_file="${ruby_file::-3}"
|
||||||
|
if ! grep -rq "$ruby_file" spec/
|
||||||
|
then
|
||||||
|
echo "[-] Error: missing unit tests for $ruby_file.rb"
|
||||||
|
got_err=1
|
||||||
|
fi
|
||||||
|
done < <(find lib/ -name "*.rb")
|
||||||
|
if [ "$got_err" == "0" ]
|
||||||
|
then
|
||||||
|
echo "[+] OK: every file has a unit test."
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo "[-] Error: missing unit tests."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if missing_unit_tests
|
||||||
|
then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue