reframe-hpc / reframe

A powerful Python framework for writing and running portable regression tests and benchmarks for HPC systems.
https://reframe-hpc.readthedocs.org
BSD 3-Clause "New" or "Revised" License
213 stars 100 forks source link

[bugfix] Fix logging crash when the `check_#ALL` placeholder is used #3142

Closed vkarak closed 3 months ago

vkarak commented 3 months ago

I hit this subtle and nasty bug while working on the new tutorial. It is exposed more easily now that the variables and parameters are by default loggable. The problem is the following:

When a series of tests that define different variables is set, ReFrame's logging will crash with an error like this:

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.10/logging/__init__.py", line 1100, in emit
    msg = self.format(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 943, in format
    return fmt.format(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 681, in format
    s = self.formatMessage(record)
  File "/usr/local/share/reframe/reframe/core/logging.py", line 366, in formatMessage
    return self.__fmt % record_proxy
KeyError: 'check_nthr'
...

The problem was that the message's format was calculated once from the check_#ALL special placeholder, so when trying to format the message from another test with different variables, it would cause this crash. I have added a unit test that reproduces this error exactly.

This PR fixes this problem by keeping the expanded format strings for each test. Also, it fixes a similar problem that was causing ReFrame to generate wrong perflog headers for subsequent tests.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.63%. Comparing base (3932f25) to head (bd0e2aa).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3142 +/- ## ======================================= Coverage 86.63% 86.63% ======================================= Files 61 61 Lines 12042 12049 +7 ======================================= + Hits 10432 10439 +7 Misses 1610 1610 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.