Skip to content

Commit 9350a3e

Browse files
Only set linetrace=True when compiling for coverage
1 parent c34616f commit 9350a3e

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.github/workflows/coverage.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ jobs:
1717
steps:
1818
- name: Acquire sources
1919
uses: actions/checkout@v4
20-
20+
- name: Arm coverage-only compiler directives
21+
# Unfortunately, it doesn't seem to be possible to pass directives
22+
# to Cython through environment variables: https://github.com/cython/cython/issues/3930
23+
# Doing it here is still better than introducing a non-declarative setup.py into the
24+
# build again.
25+
run: sed -i 's/#coverage#cython/#cython/g' pkcs11/*.pyx
2126
- name: Setup Python
2227
uses: actions/setup-python@v5
2328
with:

pkcs11/_pkcs11.pxd

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,10 +625,11 @@ cdef inline CK_ULONG_buffer(length):
625625
return array(shape=(length,), itemsize=sizeof(CK_ULONG), format='L')
626626

627627

628-
cdef inline object map_rv_to_error(
629-
CK_RV rv
630-
):
628+
# Note: this `cdef inline` declaration doesn't seem to be consistently labelled
629+
# as executed by Cython's line tracing, so we flag it as nocover
630+
# to avoid noise in the metrics.
631631

632+
cdef inline object map_rv_to_error(CK_RV rv): # pragma: nocover
632633
if rv == CKR_ATTRIBUTE_TYPE_INVALID:
633634
exc = AttributeTypeInvalid()
634635
elif rv == CKR_ATTRIBUTE_VALUE_INVALID:

pkcs11/_pkcs11.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#!python
21
#cython: language_level=3
3-
#cython: linetrace=True
2+
#coverage#cython: linetrace=True
43
"""
54
High-level Python PKCS#11 Wrapper.
65

0 commit comments

Comments
 (0)