Skip to content

Commit 473af5d

Browse files
committed
INTERNAL: distro detection for the frontend can just use /etc/os-release (we missed a spot in code coverage calculation)
1 parent f08f8f5 commit 473af5d

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

test-framework/provisioning/roles/system-coverage/files/sitecustomize.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
import atexit
2-
import os.path
2+
from pathlib import Path
33

44
import coverage
55

66

7-
if os.path.exists("/etc/SuSE-release"):
8-
config_file = "/export/test-suites/_common/sles.coveragerc"
9-
else:
10-
config_file = "/export/test-suites/_common/redhat.coveragerc"
7+
def get_distro():
8+
''' get the distro on any newer systemd based distro (sles12+, centos/rhel 7+) '''
9+
os_release = Path('/etc/os-release')
10+
if not os_release.exists():
11+
raise NotImplementedError
12+
13+
for line in os_release.read_text().splitlines():
14+
if line.startswith('ID='):
15+
distro_id = line.split('=')[-1].strip('"')
16+
break
17+
else: # nobreak
18+
raise NotImplementedError
19+
20+
if distro_id in ['rhel', 'centos']:
21+
return 'redhat'
22+
23+
return distro_id
24+
25+
26+
config_file = f"/export/test-suites/_common/{get_distro()}.coveragerc"
1127

1228
cov = coverage.Coverage(
1329
data_file="/root/.coverage",
@@ -17,7 +33,6 @@
1733
)
1834
cov.start()
1935

20-
2136
@atexit.register
2237
def stop_coverage():
2338
cov.stop()

0 commit comments

Comments
 (0)