From 5dc88359d27c2c36f53e52a3f54fe77af7a99415 Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Tue, 17 Feb 2026 10:41:22 -0500 Subject: [PATCH] Add explicit logging for Rust extension usage in tests Enhanced the logging in run_tests.py to clearly show: - Whether PYMONGO_USE_RUST and PYMONGO_BUILD_RUST are set - Which BSON implementation is actually in use (rust/c/python) - Clear indication of which extension is ACTIVE This makes it easier to verify that the Rust extension is being used when expected, especially for the 'perf rust' tests. --- .evergreen/scripts/run_tests.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.evergreen/scripts/run_tests.py b/.evergreen/scripts/run_tests.py index 93d08b9d0..d98d18198 100644 --- a/.evergreen/scripts/run_tests.py +++ b/.evergreen/scripts/run_tests.py @@ -154,12 +154,26 @@ def run() -> None: handle_pymongocrypt() # Check if Rust extension is being used + LOGGER.info(f"PYMONGO_USE_RUST={os.environ.get('PYMONGO_USE_RUST', 'not set')}") + LOGGER.info(f"PYMONGO_BUILD_RUST={os.environ.get('PYMONGO_BUILD_RUST', 'not set')}") + if os.environ.get("PYMONGO_USE_RUST") or os.environ.get("PYMONGO_BUILD_RUST"): try: import bson - LOGGER.info(f"BSON implementation: {bson.get_bson_implementation()}") - LOGGER.info(f"Has Rust: {bson.has_rust()}, Has C: {bson.has_c()}") + impl = bson.get_bson_implementation() + has_rust = bson.has_rust() + has_c = bson.has_c() + + LOGGER.info(f"BSON implementation in use: {impl}") + LOGGER.info(f"Has Rust: {has_rust}, Has C: {has_c}") + + if impl == "rust": + LOGGER.info("✓ Rust extension is ACTIVE") + elif impl == "c": + LOGGER.info("✓ C extension is ACTIVE") + else: + LOGGER.info("✓ Pure Python implementation is ACTIVE") except Exception as e: LOGGER.warning(f"Could not check BSON implementation: {e}")