Skip to content

Commit

Permalink
fix: Make python test failure with compile-time log threshold more in…
Browse files Browse the repository at this point in the history
…formative (#1315)

If `ACTS_LOG_FAILURE_THRESHOLD` is set, a compile time threshold is
enabled and `setFailureThreshold` throws an exception. The python tests
assume this call to `setFailureThreshold` always works. This PR prints an informative error message about what to do about this, but reraises the exception.
  • Loading branch information
paulgessinger committed Jul 18, 2022
1 parent 1fdf72c commit e7edccb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion Examples/Python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@
import acts
import acts.examples

acts.logging.setFailureThreshold(acts.logging.WARNING)
try:
acts.logging.setFailureThreshold(acts.logging.WARNING)
except RuntimeError:
# Repackage with different error string
raise RuntimeError(
"Runtime log failure threshold could not be set. "
"Compile-time value is probably set via CMake, i.e. "
f"`ACTS_LOG_FAILURE_THRESHOLD={acts.logging.getFailureThreshold().name}` is set. The "
"pytest test-suite will not work in this configuration."
)


u = acts.UnitConstants

Expand Down
12 changes: 11 additions & 1 deletion Examples/Python/tests/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,17 @@ def execute(self, ctx):
def failure_threshold(level: acts.logging.Level, enabled: bool = True):
if enabled:
prev = acts.logging.getFailureThreshold()
acts.logging.setFailureThreshold(level)
try:
acts.logging.setFailureThreshold(level)
except RuntimeError:
# Repackage with different error string
raise RuntimeError(
"Runtime log failure threshold could not be set. "
"Compile-time value is probably set via CMake, i.e. "
f"`ACTS_LOG_FAILURE_THRESHOLD={acts.logging.getFailureThreshold().name}` is set. The "
"pytest test-suite will not work in this configuration."
)

yield
acts.logging.setFailureThreshold(prev)
else:
Expand Down

0 comments on commit e7edccb

Please sign in to comment.