From 24b4a13905aedd7d7229971c9229e044068925ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Wed, 26 May 2021 19:17:29 +0200
Subject: [PATCH] fix coverage

---
 .coveragerc |  6 +-----
 .travis.yml |  5 +++--
 Dockerfile  | 14 ++++----------
 setup.py    | 11 ++++++++---
 4 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/.coveragerc b/.coveragerc
index e029911..d5b54ce 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -1,7 +1,3 @@
 [run]
-branch=1
-omit=
-  tests/*
-  .eggs/*
-  setup.py
+omit=setup.py
 plugins = Cython.Coverage
diff --git a/.travis.yml b/.travis.yml
index 2fa1e77..12addb7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,8 +5,8 @@ before_script:
   - chmod +x ./cc-test-reporter
   - ./cc-test-reporter before-build
   - pip install -r requirements.txt
-  - pip install pytest mock coverage cython[coverage] pytest-cov
-  - DEBUG=1 python setup.py build_ext --inplace --force --define CYTHON_TRACE
+  - pip install pytest coverage pytest-cov
+  - DEBUG=1 python setup.py install
   - rm -rf minijson
 jobs:
   include:
@@ -15,6 +15,7 @@ jobs:
       script:
         - pytest --cov=./ --cov-report=xml
       after_script:
+        - coverage xml
         - ./cc-test-reporter after-build -t coverage.py --exit-code ${TRAVIS_TEST_RESULT}
 
 
diff --git a/Dockerfile b/Dockerfile
index 56d6625..7a93d2b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,19 +1,13 @@
 FROM smokserwis/build:python3
 
-RUN pip install snakehouse Cython satella pytest
+RUN pip install snakehouse Cython satella pytest coverage pytest-cov
 
 ENV DEBUG=1
 
 WORKDIR /tmp/compile
-ADD minijson /tmp/compile/minijson
-ADD setup.py /tmp/compile/setup.py
-ADD README.md /tmp/compile/README.md
-ADD setup.cfg /tmp/compile/setup.cfg
+ADD . /tmp/compile/
 
 RUN python setup.py install
+RUN rm -rf minijson
 
-WORKDIR /tmp
-
-ADD tests /tmp/tests
-
-CMD ["pytest"]
+CMD ["pytest", "--cov=./", "--cov-report=xml"]
diff --git a/setup.py b/setup.py
index 754a228..51baa21 100644
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,14 @@
 import os
 from setuptools import find_packages
 from distutils.core import setup
-from snakehouse import Multibuild, build, find_pyx
+from snakehouse import Multibuild, build, monkey_patch_parallel_compilation, find_pyx
+
+monkey_patch_parallel_compilation()
 
 build_kwargs = {}
 directives = {'language_level': '3'}
 dont_snakehouse = False
-
+multi_kwargs = {}
 if 'DEBUG' in os.environ:
     print('Enabling debug mode')
     dont_snakehouse = True
@@ -15,6 +17,8 @@ if 'DEBUG' in os.environ:
                       profile=True,
                       linetrace=True,
                       binding=True)
+    multi_kwargs['define_macros'] = [('CYTHON_TRACE', '1'),
+                                     ('CYTHON_TRACE_NOGIL', '1')]
 
     import Cython.Compiler.Options
     Cython.Compiler.Options.annotate = True
@@ -23,7 +27,8 @@ if 'DEBUG' in os.environ:
 setup(version='1.7',
       packages=find_packages(include=['minijson', 'minijson.*']),
       ext_modules=build([Multibuild('minijson', find_pyx('minijson'),
-                                    dont_snakehouse=dont_snakehouse), ],
+                                    dont_snakehouse=dont_snakehouse,
+                                    **multi_kwargs), ],
                         compiler_directives=directives, **build_kwargs),
       python_requires='!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*',
       )
-- 
GitLab