Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Merge requests
!550
WIP:
L2SS-938
: add coverage trace wrapper
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Closed
WIP:
L2SS-938
: add coverage trace wrapper
L2SS-938-fix-device-code-coverage
into
master
Overview
3
Commits
10
Pipelines
0
Changes
36
Closed
Stefano Di Frischia
requested to merge
L2SS-938-fix-device-code-coverage
into
master
2 years ago
Overview
3
Commits
10
Pipelines
0
Changes
36
Expand
Closes
L2SS-938
0
0
Merge request reports
Compare
master
version 8
42b12cb8
2 years ago
version 7
b58c962a
2 years ago
version 6
d2bbb840
2 years ago
version 5
d154bd25
2 years ago
version 4
77ec8dc4
2 years ago
version 3
2f9c8b30
2 years ago
version 2
3db4faf6
2 years ago
version 1
557e0d2b
2 years ago
master (base)
and
latest version
latest version
d14c75d0
10 commits,
2 years ago
version 8
42b12cb8
9 commits,
2 years ago
version 7
b58c962a
8 commits,
2 years ago
version 6
d2bbb840
6 commits,
2 years ago
version 5
d154bd25
5 commits,
2 years ago
version 4
77ec8dc4
4 commits,
2 years ago
version 3
2f9c8b30
3 commits,
2 years ago
version 2
3db4faf6
2 commits,
2 years ago
version 1
557e0d2b
1 commit,
2 years ago
36 files
+
327
−
32
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
36
Search (e.g. *.vue) (Ctrl+P)
tangostationcontrol/tangostationcontrol/common/coverage.py
0 → 100644
+
28
−
0
Options
# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0
# Code coverage tools 'coverage' and 'pytest-cov' don't seem to correctly trace
# code which is inside methods called from within QThreads, see
# https://github.com/nedbat/coveragepy/issues/686
# To mitigate this problem, I use a custom decorator '@coverage_resolve_trace'
# to be hung onto those method definitions. This will prepend the decorated
# method code with 'sys.settrace(threading._trace_hook)' when a code
# coverage test is detected. When no coverage test is detected, it will just
# pass the original method untouched.
import
sys
import
threading
from
functools
import
wraps
__all__
=
[
"
coverage_resolve_trace
"
]
def
coverage_resolve_trace
(
fn
):
"""
Wrapper to trace code coverage in Tango devices
"""
@wraps
(
fn
)
def
wrapped
(
*
args
,
**
kwargs
):
if
"
coverage
"
in
sys
.
modules
:
sys
.
settrace
(
threading
.
_trace_hook
)
return
fn
(
*
args
,
**
kwargs
)
return
wrapped
Loading