Skip to content

Commit 567f570

Browse files
feature/coverage (#141)
* add coverage.sh * fix permission on coverage.sh * improve coverage sh script * add coverage.xml to .igtignore * improve doc on coverage.sh * add doc for ./coverage.sh in contributing guide
1 parent b7bb17c commit 567f570

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ examples/.ipynb_checkpoints/
1212
runs/
1313
.coverage
1414
htmlcov
15+
coverage.xml
1516
.darts
1617
docs_env
1718
.DS_Store

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ Before working on a contribution (a new feature or a fix) make sure you can't fi
113113
3. Clone the forked repository locally.
114114
4. Create a clean python env and install requirements with pip: `pip install -r requirements/main.txt -r requirements/dev.txt -r requirements/release.txt`
115115
5. Create a new branch with your fix / feature from the **develop** branch.
116-
6. Create a pull request from your new branch to the **develop** branch.
116+
6. Check that your code pass the tests / design new unit tests: `python -m unittest`.
117+
7. Verify your tests coverage with `./coverage.sh` (additionaly you can generate xml report and use VSCode Coverage gutter to identify untested lines with `./coverage.sh xml`).
118+
8. Create a pull request from your new branch to the **develop** branch.
117119

118120
## Contact Us
119121

coverage.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# run and display coverage report properly filtered in terminal, xml or html
3+
# usage: ./coverage.sh [ xml | html ]
4+
usage()
5+
{
6+
echo "usage: ./coverage.sh [ xml | html ]"
7+
}
8+
9+
#### Main
10+
coverage run --source=. -m unittest
11+
if [ -z "$1" ]; then
12+
coverage report -m --fail-under=80 --omit='darts/tests*,*__init__.py'
13+
else
14+
case $1 in
15+
xml ) coverage xml --fail-under=80 --omit='darts/tests*,*__init__.py' ;;
16+
html ) coverage html --fail-under=80 --omit='darts/tests*,*__init__.py' ;;
17+
* ) usage; exit 1;;
18+
esac
19+
fi

0 commit comments

Comments
 (0)