1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#!/usr/bin/env bash
set -e
pluginLookup="$1"
if [ -z "$pluginLookup" ]; then
echo 'Must give plugins l_name as argument, for example "stardict" or "octopus_mdict"'
exit 1
fi
rootDir=$(dirname $(realpath $(dirname "$0")))
echo $rootDir
cd $rootDir/pyglossary/plugins/
pluginLname=$(ls -1d $pluginLookup* | grep -v 'cover' | sort | head -n1 | sed 's/\.py$//')
if [ -z "$pluginLname" ]; then
echo "Did not find a plugin matching '$pluginLookup'"
exit 1
fi
if [ -f "$rootDir/pyglossary/plugins/${pluginLname}.py" ]; then
filePaths="$rootDir/pyglossary/plugins/${pluginLname}.py"
elif [ -d "$rootDir/pyglossary/plugins/${pluginLname}" ]; then
filePaths="$rootDir/pyglossary/plugins/${pluginLname}/*.py"
else
echo "Did not find a plugin matching '$pluginLookup'"
exit 1
fi
echo "Using plugin name '$pluginLname'"
dataFile="$rootDir/pyglossary/plugins/${pluginLname}.cover"
outDir="$rootDir/pyglossary/plugins/${pluginLname}.coverhtml"
mkdir -p $outDir
# echo "file://$outDir/index.html"
cd "$rootDir/tests"
set -x
coverage run --data-file="$dataFile" -m unittest "g_${pluginLname}_test.py"
coverage html --data-file="$dataFile" \
--include="$filePaths" \
--directory=$outDir ||
echo "'coverage html' failed with $?"
set +x
if [ -f "$outDir/index.html" ]; then
echo "file://$outDir/index.html"
fi
|