Skip to content

Commit

Permalink
update scripts/test-cover-html-plugin.sh and .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Dec 19, 2024
1 parent 4ee177f commit 1f3153d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import-analyzer/
/.mypy_cache/
/plugins
/ui
*.coverage
*.cover*
*,cover
htmlcov
*.htmlcov
Expand Down
28 changes: 23 additions & 5 deletions scripts/test-cover-html-plugin.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
#!/usr/bin/env bash
set -e

pluginLname="$1"
if [ -z "$pluginLname" ]; then
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

dataFile="$rootDir/pyglossary/plugins/${pluginLname}.coverage"
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}.htmlcov"
outDir="$rootDir/pyglossary/plugins/${pluginLname}.coverhtml"
mkdir -p $outDir
# echo "file://$outDir/index.html"

Expand All @@ -21,7 +39,7 @@ cd "$rootDir/tests"
set -x
coverage run --data-file="$dataFile" -m unittest "g_${pluginLname}_test.py"
coverage html --data-file="$dataFile" \
--include="$rootDir/pyglossary/plugins/${pluginLname}*" \
--include="$filePaths" \
--directory=$outDir ||
echo "'coverage html' failed with $?"
set +x
Expand Down

0 comments on commit 1f3153d

Please sign in to comment.