celerity / celerity-runtime

High-level C++ for Accelerator Clusters
https://celerity.github.io
MIT License
139 stars 18 forks source link

Capture and inspect all logs in Catch2 tests, fix race #234

Closed fknorr closed 8 months ago

fknorr commented 9 months ago

This PR completely redefines how logging is handled inside unit tests.

It works by unconditionally capturing logs in the global thread-safe test_utils::log_test_capture. This allows the test code to query captured messages, and will echo the captured logs through a global Catch2 hook if the test fails. By default, this mechanism will fail any test that logs a warning or error, but it provides functions to relax that behavior either explicitly through test_utils::allow_max_log_level or implicitly through runtime_fixture / device_queue_fixture which permit system-dependent warnings to appear.

The new mechanism is fully independent of the CELERITY_LOG_LEVEL environment, both in which messages it captures and also which ones it dumps in case of a test failure.

Some refactorings and fixes happened alogn the way:

github-actions[bot] commented 9 months ago

Check-perf-impact results: (4c65f1399a47e0eb1340f63004745b17)

:question: No new benchmark data submitted. :question:
Please re-run the microbenchmarks and include the results if your commit could potentially affect performance.

fknorr commented 8 months ago

I agree, finer control over which warnings to allow would be great in a follow-up PR!

I have created an issue about this.