Skip to content

Commit

Permalink
Feature/implement coverage (bmw-software-engineering#78)
Browse files Browse the repository at this point in the history
* implement coverage for lobster

* Include coverage report and test outputs to lobster

* Add ci-tests to workflow
  • Loading branch information
DiFerMa authored Sep 23, 2024
1 parent fb705f9 commit 77e74a1
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ jobs:
- name: Executing system tests
run: |
make system-tests
- name: Coverage analysis
run: |
make coverage
- name: Check output files
if: always()
run: |
util/check_local_modifications.sh
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ integration-tests: packages
(cd integration-tests/projects/filter; make)

system-tests:
mkdir -p docs
make -B -C test-system/lobster-json
make -B -C test-system/lobster-python

unit-tests:
python3 -m unittest discover -s test-unit -v
coverage run -p \
--branch --rcfile=coverage.cfg \
--data-file .coverage \
-m unittest discover -s test-unit -v

test: integration-tests system-tests unit-tests

Expand All @@ -74,3 +78,11 @@ full-release:
make github-release
make bump
git push

coverage:
coverage combine -q
coverage html --rcfile=coverage.cfg
coverage report --rcfile=coverage.cfg --fail-under=57

test-ci: system-tests unit-tests coverage
util/check_local_modifications.sh
16 changes: 16 additions & 0 deletions coverage.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[report]
exclude_lines =
pragma: no cover
ice_loc
@abstractmethod
if DEBUG_
assert False
def __repr__(self)
def sanity_test()
if __name__ == "__main__"

[run]
omit =
/usr/*
*/site-packages/*
test-unit/*
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-r requirements.txt
pycodestyle==2.12.0
pylint==3.2.4
coverage>=7.2
4 changes: 3 additions & 1 deletion test-system/lobster-json/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ all: $(TARGETS)
%.output: %.input
@tail +2 $< > $*.json
@touch $*.lobster
-$(TOOL) $(shell head -1 $< | tail --bytes=+3) --out=$*.lobster --single > $@ 2>&1
-@coverage run -p --rcfile=../../coverage.cfg --branch \
--data-file ../../.coverage \
$(TOOL) $(shell head -1 $< | tail --bytes=+3) --out=$*.lobster --single > $@ 2>&1
@echo "==========" >> $@
@cat $*.lobster >> $@
@rm $*.json $*.lobster
4 changes: 3 additions & 1 deletion test-system/lobster-python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ all: $(TARGETS)

%.output: %.py
@touch $*.lobster
-$(TOOL) $(shell head -1 $< | tail --bytes=+2) $< --out=$*.lobster --single > $@ 2>&1
-@coverage run -p --rcfile=../../coverage.cfg --branch \
--data-file ../../.coverage \
$(TOOL) $(shell head -1 $< | tail --bytes=+2) $< --out=$*.lobster --single > $@ 2>&1
@echo "==========" >> $@
@cat $*.lobster >> $@
@rm $*.lobster
8 changes: 4 additions & 4 deletions test-system/lobster-python/basic.output
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ Written output for 3 items to basic.lobster
"kind": "Function"
},
{
"tag": "python basic.Example.helper_function",
"tag": "python basic.Example",
"location": {
"kind": "file",
"file": "basic.py",
"line": 13,
"column": null
},
"name": "basic.Example.helper_function",
"name": "basic.Example",
"messages": [],
"just_up": [],
"just_down": [],
Expand All @@ -40,14 +40,14 @@ Written output for 3 items to basic.lobster
"kind": "Method"
},
{
"tag": "python basic.Example.nor",
"tag": "python basic.Example-1",
"location": {
"kind": "file",
"file": "basic.py",
"line": 17,
"column": null
},
"name": "basic.Example.nor",
"name": "basic.Example",
"messages": [],
"just_up": [],
"just_down": [],
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#

flag = False
requirements_global = None

Expand Down
8 changes: 4 additions & 4 deletions test-system/lobster-python/pytest_mark.output
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Written output for 2 items to pytest_mark.lobster
{
"data": [
{
"tag": "pyunit pytest_mark.TestFrameServerProcessesStart.test_1",
"tag": "pyunit pytest_mark.TestFrameServerProcessesStart.test_1:21",
"location": {
"kind": "file",
"file": "pytest_mark.py",
"line": 21,
"column": null
},
"name": "pytest_mark.TestFrameServerProcessesStart.test_1",
"name": "pytest_mark.TestFrameServerProcessesStart.test_1:21",
"messages": [],
"just_up": [],
"just_down": [],
Expand All @@ -23,14 +23,14 @@ Written output for 2 items to pytest_mark.lobster
"status": null
},
{
"tag": "pyunit pytest_mark.TestFrameServerProcessesStart.test_2",
"tag": "pyunit pytest_mark.TestFrameServerProcessesStart.test_2:24",
"location": {
"kind": "file",
"file": "pytest_mark.py",
"line": 24,
"column": null
},
"name": "pytest_mark.TestFrameServerProcessesStart.test_2",
"name": "pytest_mark.TestFrameServerProcessesStart.test_2:24",
"messages": [],
"just_up": [],
"just_down": [],
Expand Down
11 changes: 11 additions & 0 deletions util/check_local_modifications.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

if [[ $(git status -s) ]]; then
echo "Local modifications found:"
git -P diff
echo "Summary:"
git status -s
exit 1
else
exit 0
fi

0 comments on commit 77e74a1

Please sign in to comment.