Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
6
Merge Requests
6
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.buildout
Commits
2563a46e
Commit
2563a46e
authored
May 08, 2020
by
Godefroid Chapelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
run coverage should be explicit
register combine and report with atexit
parent
0a6d23e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
12 deletions
+44
-12
buildout.cfg
buildout.cfg
+4
-3
src/zc/buildout/testing.py
src/zc/buildout/testing.py
+40
-9
No files found.
buildout.cfg
View file @
2563a46e
...
@@ -24,9 +24,10 @@ eggs =
...
@@ -24,9 +24,10 @@ eggs =
zc.recipe.egg
zc.recipe.egg
coverage
coverage
initialization =
initialization =
import os
import os.path
if 'COVERAGE_PROCESS_START' not in os.environ: os.environ['COVERAGE_PROCESS_START'] = os.path.abspath('../../.coveragerc')
from zc.buildout.testing import setup_coverage
if os.getenv('COVERAGE_PROCESS_START'): import coverage; coverage.process_startup()
path_to_coveragerc = os.path.join('${buildout:directory}', '.coveragerc')
setup_coverage(path_to_coveragerc)
# Tests that can be run wo a network
# Tests that can be run wo a network
[oltest]
[oltest]
...
...
src/zc/buildout/testing.py
View file @
2563a46e
...
@@ -297,15 +297,8 @@ def buildoutSetUp(test):
...
@@ -297,15 +297,8 @@ def buildoutSetUp(test):
# way due to the trick above:
# way due to the trick above:
os
.
mkdir
(
'develop-eggs'
)
os
.
mkdir
(
'develop-eggs'
)
if
os
.
getenv
(
"COVERAGE_PROCESS_START"
):
path_to_coveragerc
=
os
.
getenv
(
"COVERAGE_PROCESS_START"
,
None
)
# The user has requested subprocess code coverage. Since we will be changing
if
path_to_coveragerc
is
not
None
:
# directories, we need to make sure this path is absolute, which means
# we need to temporarily return to our starting directory.
os
.
chdir
(
here
)
path_to_coveragerc
=
os
.
path
.
abspath
(
os
.
environ
[
'COVERAGE_PROCESS_START'
])
os
.
chdir
(
sample
)
assert
os
.
path
.
isfile
(
path_to_coveragerc
),
path_to_coveragerc
os
.
environ
[
'COVERAGE_PROCESS_START'
]
=
path_to_coveragerc
# Before we return to the current directory and destroy the
# Before we return to the current directory and destroy the
# temporary working directory, we need to copy all the coverage files
# temporary working directory, we need to copy all the coverage files
...
@@ -641,3 +634,41 @@ def run_buildout_in_process(command='buildout'):
...
@@ -641,3 +634,41 @@ def run_buildout_in_process(command='buildout'):
)
)
command = ' '.join(command)
command = ' '.join(command)
run_in_process(run_buildout, command)
run_in_process(run_buildout, command)
def setup_coverage(path_to_coveragerc):
if 'RUN_COVERAGE' not in os.environ:
return
if not os.path.exists(path_to_coveragerc):
raise ValueError('coveragerc file %s does not exist.' % path_to_coveragerc)
os.environ['COVERAGE_PROCESS_START'] = path_to_coveragerc
rootdir = os.path.dirname(path_to_coveragerc)
def combine_report():
subprocess.call(
[
sys.executable, '-m', 'coverage', 'combine',
],
cwd=rootdir,
)
subprocess.call(
[
sys.executable, '-m', 'coverage', 'report',
],
cwd=rootdir,
)
if path_to_coveragerc:
try:
import coverage
print("
Coverage
configured
with
%
s
" % path_to_coveragerc)
if 'COVERAGE_REPORT' in os.environ:
import atexit
atexit.register(combine_report)
coverage.process_startup()
except ImportError:
print(
"
You
try
to
run
coverage
"
"
but
coverage
is
not
installed
in
your
environment
.
"
)
sys.exit(1)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment