Skip to content

Commit 96d7d28

Browse files
committed
make: add target to make a code coverage report
Patch introduces integration with coverage.py module [1] that allows to gather code coverage and build a simple report about covered statements and branches. We have a test-run.py module itself and also we have Python helpers for Tarantool tests written in Python. These Python tests runs a separate processes using subprocess module. To make it possible to gather code coverage for these helpers there are special changes added to lib/tarantool_server.py file. Additionally patch introduces integration with Coveralls service that allows to evaluate incremental code coverage changes like we do it for Tarantool [2]. Code coverage for test-run is available on page by URL [3]. Name Stmts Miss Branch BrPart Cover ----------------------------------------------------------------- dispatcher.py 281 57 94 13 76.0% lib/__init__.py 45 3 6 2 90.2% lib/admin_connection.py 71 50 22 0 22.6% lib/app_server.py 162 104 38 2 33.0% lib/box_connection.py 54 33 12 0 31.8% lib/colorer.py 111 31 42 7 64.7% lib/connpool.py 85 65 18 0 19.4% lib/inspector.py 81 49 26 1 34.6% lib/options.py 81 15 18 6 78.8% lib/preprocessor.py 329 290 162 0 7.9% lib/pytap13.py 128 110 58 1 10.2% lib/server.py 111 62 40 2 35.1% lib/server_mixins.py 126 83 28 0 27.9% lib/tarantool_connection.py 126 89 22 0 25.0% lib/tarantool_server.py 735 553 270 9 20.6% lib/test.py 249 181 86 0 20.3% lib/test_suite.py 191 76 68 12 57.5% lib/unittest_server.py 63 25 10 2 57.5% lib/utils.py 216 132 86 9 33.4% lib/worker.py 251 179 70 3 25.2% listeners.py 205 78 70 6 60.0% test-run.py 149 76 44 9 42.5% ----------------------------------------------------------------- TOTAL 3850 2341 1290 84 34.2% 1. https://coverage.readthedocs.io/en/latest/config.html 2. https://coveralls.io/github/tarantool/tarantool 3. https://coveralls.io/github/tarantool/test-run
1 parent d01b205 commit 96d7d28

File tree

6 files changed

+41
-1
lines changed

6 files changed

+41
-1
lines changed

.coveragerc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
precision = 1
6+
include =
7+
./*
8+
omit =
9+
lib/tarantool-python/*
10+
lib/msgpack-python/*

.github/workflows/test.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,14 @@ jobs:
5858
- name: run regression tests
5959
run: |
6060
make test
61+
- name: code coverage
62+
run: |
63+
make coverage
64+
- name: upload coverage data to coveralls.io
65+
run: coveralls
66+
env:
67+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
68+
COVERALLS_PARALLEL: true
69+
include:
70+
- python-version: 3.8
71+
- tarantool-version: 2.7

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
2+
PROJECT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
13
TEST_RUN_EXTRA_PARAMS?=
24
PYTHON?=python
35

@@ -13,11 +15,18 @@ luacheck:
1315
luacheck --config .luacheckrc .
1416

1517
test_integration:
16-
$(PYTHON) test/test-run.py --force $(TEST_RUN_EXTRA_PARAMS)
18+
PYTHONPATH=$(PROJECT_DIR) $(PYTHON) test/test-run.py --force $(TEST_RUN_EXTRA_PARAMS)
1719

1820
test_unittest:
1921
$(PYTHON) -m unittest discover test/unittest/
2022

2123
test: test_unittest test_integration
2224

25+
coverage:
26+
PYTHON="$(PYTHON) -m coverage run" make -f $(MAKEFILE_PATH) test
27+
coverage report
28+
29+
clean:
30+
coverage erase
31+
2332
.PHONY: lint flake8 luacheck test test_integration test_unittest

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Tarantool Functional testing framework
22

3+
[![Coverage Status](https://coveralls.io/repos/github/tarantool/test-run/badge.svg)](https://coveralls.io/github/tarantool/test-run)
4+
35
### Test Suite
46

57
Bunch of tests, that lay down in the subfolder (recursively) with `suite.ini`

lib/tarantool_server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,12 @@ def start(self, silent=True, wait=True, wait_load=True, rais=True, args=[],
857857

858858
# redirect stdout from tarantoolctl and tarantool
859859
os.putenv("TEST_WORKDIR", self.vardir)
860+
if os.environ.get('PYTHON') == 'coverage run':
861+
import coverage
862+
coveragerc_path = os.path.join(os.path.abspath(self.sourcedir), ".coveragerc")
863+
assert(os.path.exists(coveragerc_path))
864+
os.environ['COVERAGE_PROCESS_START'] = os.path.join(coveragerc_path)
865+
coverage.process_startup()
860866
self.process = subprocess.Popen(args,
861867
cwd=self.vardir,
862868
stdout=self.log_des,

requirements-test.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
coverage==5.*
2+
coveralls==1.*
13
flake8==3.7.9
24
hypothesis==4.*

0 commit comments

Comments
 (0)