Add Python version banner to Catch progress reporter

Print the CPython version once at the start of the Catch-based
interpreter tests using Py_GetVersion(). This makes it trivial to
confirm which free-threaded build a failing run is using when
inspecting CI or local logs.
This commit is contained in:
Ralf W. Grosse-Kunstleve
2025-12-13 23:25:33 -08:00
parent ad3e1c34ce
commit 48725893c6

View File

@@ -21,6 +21,8 @@ namespace py = pybind11;
// Simple progress reporter that prints a line per test case.
namespace {
bool g_printed_python_version = false;
class ProgressReporter : public Catch::CumulativeReporterBase<ProgressReporter> {
public:
using CumulativeReporterBase::CumulativeReporterBase;
@@ -28,6 +30,12 @@ public:
static std::string getDescription() { return "Simple progress reporter (one line per test)"; }
void testCaseStarting(Catch::TestCaseInfo const &testInfo) override {
if (!g_printed_python_version) {
g_printed_python_version = true;
const char *version = Py_GetVersion();
stream << "[ PYTHON ] " << version << '\n';
stream.flush();
}
stream << "[ RUN ] " << testInfo.name << '\n';
stream.flush();
CumulativeReporterBase::testCaseStarting(testInfo);