mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 22:39:09 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user