File: test-cover-html-plugin.sh

package info (click to toggle)
pyglossary 5.0.9-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,896 kB
  • sloc: python: 46,165; sh: 308; javascript: 100; xml: 42; makefile: 28
file content (49 lines) | stat: -rwxr-xr-x 1,312 bytes parent folder | download
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