Skip to content

Commit 93869ee

Browse files
ppisarkontura
authored andcommitted
Handle Fedora ELN as RHEL
We compile the tested software according to %rhel RPM macro. To skip or condition tests correctly, we need to handle Fedora ELN as RHEL when evaluating behave tags. Old dection had these problems: distro.id() parses /etc/os-release. That file declares ELN in VARIANT constant, but distro.id() does not recognizes that (correctly because ELN is still a Fedora project). Also /etc/os-release does not contain the RHEL version. This patch overrides the distr.id() detection with querying RPM library for %rhel macro. The same what we use when building the software.
1 parent ff5417c commit 93869ee

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# -*- coding: utf-8 -*-
22

33
import distro
4+
import rpm
45

56

67
def detect_os_version():
78
os_id = distro.id()
9+
major_version = distro.major_version()
810

911
# treat centos as RHEL in context of scenario tag matching
1012
if os_id == "centos":
1113
os_id = "rhel"
1214

13-
return os_id + "__" + distro.major_version()
15+
# Treat anything that defines non-empty "rhel" RPM macro as RHEL.
16+
# That's especially needed to handle Fedora ELN as RHEL.
17+
rhel_macro_version = int(rpm.expandMacro("0%{?rhel}"))
18+
if rhel_macro_version > 0:
19+
os_id = "rhel"
20+
major_version = str(rhel_macro_version)
21+
22+
return os_id + "__" + major_version

0 commit comments

Comments
 (0)