Skip to content

Commit 9eaba87

Browse files
committed
add Makefile to measure coverage
1 parent a8d324b commit 9eaba87

File tree

3 files changed

+152
-0
lines changed

3 files changed

+152
-0
lines changed

.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[run]
2+
branch = True
3+
source = cwltool

Makefile

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# This file is part of cwltool,
2+
# https://github.com/common-workflow-language/cwltool/, and is
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
18+
# make pep8 to check for basic Python code compliance
19+
# make autopep8 to fix most pep8 errors
20+
# make pylint to check Python code for enhanced compliance including naming
21+
# and documentation
22+
# make coverage-report to check coverage of the python scripts by the tests
23+
24+
MODULE=cwltool
25+
26+
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
27+
# `[[` conditional expressions.
28+
PYSOURCES=$(wildcard ${MODULE}/**.py tests/*.py) setup.py
29+
DEVPKGS=pep8 diff_cover autopep8 pylint coverage pep257
30+
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pep257 sloccount
31+
VERSION=1.0.$(shell date +%Y%m%d%H%M%S --date=`git log --first-parent \
32+
--max-count=1 --format=format:%cI`)
33+
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
34+
35+
## all : default task
36+
all:
37+
./setup.py develop
38+
39+
## help : print this help message and exit
40+
help: Makefile
41+
@sed -n 's/^##//p' $<
42+
43+
## install-dep : install most of the development dependencies via pip
44+
install-dep:
45+
pip install --upgrade $(DEVPKGS)
46+
47+
## install-deb-dep: install most of the dev dependencies via apt-get
48+
install-deb-dep:
49+
sudo apt-get install $(DEBDEVPKGS)
50+
51+
## install : install the ${MODULE} module and schema-salad-tool
52+
install: FORCE
53+
./setup.py build install
54+
55+
## dist : create a module package for distribution
56+
dist: dist/${MODULE}-$(VERSION).tar.gz
57+
58+
dist/${MODULE}-$(VERSION).tar.gz: $(SOURCES)
59+
./setup.py sdist
60+
61+
## clean : clean up all temporary / machine-generated files
62+
clean: FORCE
63+
rm -f ${MODILE}/*.pyc tests/*.pyc
64+
./setup.py clean --all || true
65+
rm -Rf .coverage
66+
rm -f diff-cover.html
67+
68+
## pep8 : check Python code style
69+
pep8: $(PYSOURCES)
70+
pep8 --exclude=_version.py --show-source --show-pep8 $^ || true
71+
72+
pep8_report.txt: $(PYSOURCES)
73+
pep8 --exclude=_version.py $^ > pep8_report.txt || true
74+
75+
diff_pep8_report: pep8_report.txt
76+
diff-quality --violations=pep8 pep8_report.txt
77+
78+
## pep257 : check Python code style
79+
pep257: $(PYSOURCES)
80+
pep257 --ignore=D100,D101,D102,D103 $^ || true
81+
82+
pep257_report.txt: $(PYSOURCES)
83+
pep257 setup.py $^ > pep257_report.txt 2>&1 || true
84+
85+
diff_pep257_report: pep257_report.txt
86+
diff-quality --violations=pep8 pep257_report.txt
87+
88+
## autopep8 : fix most Python code indentation and formatting
89+
autopep8: $(PYSOURCES)
90+
autopep8 --recursive --in-place --ignore E309 $^
91+
92+
# A command to automatically run astyle and autopep8 on appropriate files
93+
## format : check/fix all code indentation and formatting (runs autopep8)
94+
format: autopep8
95+
# Do nothing
96+
97+
## pylint : run static code analysis on Python code
98+
pylint: $(PYSOURCES)
99+
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
100+
$^ || true
101+
102+
pylint_report.txt: ${PYSOURCES}
103+
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
104+
$^ > pylint_report.txt || true
105+
106+
diff_pylint_report: pylint_report.txt
107+
diff-quality --violations=pylint pylint_report.txt
108+
109+
.coverage: $(PYSOURCES) all
110+
export COVERAGE_PROCESS_START=${mkfile_dir}.coveragerc; \
111+
cd ${CWL}; ./run_test.sh RUNNER=cwltool
112+
coverage run setup.py test
113+
coverage combine ${CWL} ${CWL}/draft-3/ ./
114+
115+
coverage.xml: .coverage
116+
python-coverage xml
117+
118+
coverage.html: htmlcov/index.html
119+
120+
htmlcov/index.html: .coverage
121+
python-coverage html
122+
@echo Test coverage of the Python code is now in htmlcov/index.html
123+
124+
coverage-report: .coverage
125+
python-coverage report
126+
127+
diff-cover: coverage-gcovr.xml coverage.xml
128+
diff-cover coverage-gcovr.xml coverage.xml
129+
130+
diff-cover.html: coverage-gcovr.xml coverage.xml
131+
diff-cover coverage-gcovr.xml coverage.xml \
132+
--html-report diff-cover.html
133+
134+
## test : run the ${MODULE} test suite
135+
test: FORCE
136+
python tests/test_examples.py
137+
138+
sloccount.sc: ${PYSOURCES} Makefile
139+
sloccount --duplicates --wide --details $^ > sloccount.sc
140+
141+
## sloccount : count lines of code
142+
sloccount: ${PYSOURCES} Makefile
143+
sloccount $^
144+
145+
list-author-emails:
146+
@echo 'name, E-Mail Address'
147+
@git log --format='%aN,%aE' | sort -u | grep -v 'root'
148+
149+
FORCE:

setup.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)