forked from LevBernstein/BeardlessBot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathunitTests.sh
More file actions
executable file
·30 lines (27 loc) · 1.32 KB
/
unitTests.sh
File metadata and controls
executable file
·30 lines (27 loc) · 1.32 KB
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
#!/usr/bin/env bash
#Run `bash unitTests.sh` to run bb's unit tests,
#output results to stdout and testResults.md
echo "# Beardless Bot Unit Test Results" > testResults.md;
python3 -m coverage run --branch --include=$(echo $PWD)/* --omit=./*env/* \
-m pytest -W ignore::DeprecationWarning --ignore=./*env/* --tb=line \
--junitxml=junit.xml;
python3 -m coverage report -m --precision=2 |& tee -a testResults.md;
python3 -m coverage xml -q;
rm resources/images/coverage.svg 2> /dev/null;
genbadge coverage -s -i coverage.xml -o resources/images/coverage.svg;
rm .coverage coverage.xml 2> /dev/null;
python3 -m flake8 --exclude="*env/*" --ignore=W191,W503 --statistics \
--exit-zero --output-file flake8stats.txt --min-python-version 3.12.0;
genbadge flake8 -s -i flake8stats.txt -o resources/images/flake8-badge.svg;
rm flake8stats.txt 2> /dev/null;
genbadge tests -s -i junit.xml -o resources/images/tests.svg;
rm junit.xml 2> /dev/null;
docstr-coverage ./ -e ".*bb_test.py/*|.*env/*" -v 0 --badge \
resources/images/docstr-coverage.svg 2> /dev/null;
#Truncate decimals in coverage badge. Very hacky; I wish
#there was an arg for significant figures.
python3 -c '
import re, pathlib
p = pathlib.Path("resources/images/coverage.svg")
with p.open("r") as f: svg = f.read()
with p.open("w") as g: g.write(re.sub(r"((\.\d{2})%+)", ".00%", svg))'