Skip to content

Commit 394472d

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 a separate processes option 'concurrency' added to .coveragerc. Additionally patch introduces integration with Coveralls service using python-coveralls module [2] that allows to evaluate incremental code coverage changes like we do it for Tarantool [3]. Code coverage for test-run is available on a public page by URL [4]. Name Stmts Miss Branch BrPart Cover ----------------------------------------------------------------- dispatcher.py 281 50 94 12 78.1% lib/__init__.py 45 0 6 1 98.0% lib/admin_connection.py 71 9 22 7 82.8% lib/app_server.py 162 45 38 11 67.0% lib/box_connection.py 54 22 12 1 50.0% lib/colorer.py 111 28 42 6 68.6% lib/connpool.py 85 54 18 1 35.0% lib/inspector.py 81 13 26 4 80.4% lib/options.py 81 15 18 6 78.8% lib/preprocessor.py 329 162 162 40 44.6% lib/pytap13.py 128 48 58 18 55.9% lib/server.py 111 23 40 12 74.2% lib/server_mixins.py 126 83 28 0 27.9% lib/tarantool_connection.py 126 28 22 5 75.0% lib/tarantool_server.py 729 237 268 65 61.5% lib/test.py 249 111 86 17 48.1% lib/test_suite.py 191 35 68 19 77.6% lib/unittest_server.py 63 6 10 4 86.3% lib/utils.py 216 76 86 19 59.9% lib/worker.py 251 81 70 15 60.7% listeners.py 205 78 70 6 60.0% test-run.py 149 76 44 9 42.5% ----------------------------------------------------------------- TOTAL 3844 1280 1288 278 61.2% 1. https://coverage.readthedocs.io/en/latest/config.html 2. https://coveralls-python.readthedocs.io/en/latest/usage/configuration.html#github-actions-support 3. https://coveralls.io/github/tarantool/tarantool 4. https://coveralls.io/github/tarantool/test-run
1 parent d01b205 commit 394472d

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

.coveragerc

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

.github/workflows/test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,13 @@ jobs:
5858
- name: run regression tests
5959
run: |
6060
make test
61+
- name: code coverage
62+
if: ${{ matrix.python-version == '3.8' && matrix.tarantool-version == '2.7' }}
63+
run: |
64+
pip install coveralls==3.*
65+
make coverage
66+
- name: upload coverage data to coveralls.io
67+
if: ${{ matrix.python-version == '3.8' && matrix.tarantool-version == '2.7' }}
68+
run: coveralls --service=github
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 11 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,19 @@ 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="coverage run" make -f $(MAKEFILE_PATH) test
27+
coverage combine $(PROJECT_DIR) $(PROJECT_DIR)/test
28+
coverage report
29+
30+
clean:
31+
coverage erase
32+
2333
.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`

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
coverage==5.*
12
flake8==3.7.9
23
hypothesis==4.*

0 commit comments

Comments
 (0)