Skip to content

tests: detect stale Cython .so files at test startup#756

Merged
Lorak-mmk merged 2 commits intoscylladb:masterfrom
mykaul:fix/detect-stale-cython-extensions
Apr 8, 2026
Merged

tests: detect stale Cython .so files at test startup#756
Lorak-mmk merged 2 commits intoscylladb:masterfrom
mykaul:fix/detect-stale-cython-extensions

Conversation

@mykaul
Copy link
Copy Markdown

@mykaul mykaul commented Mar 19, 2026

Add a pytest_configure hook in tests/conftest.py that compares mtime of each compiled .so against its .py source and warns when the source is newer. This prevents silently testing stale compiled code after editing a Cython-compiled module without rebuilding.
(Bit me here - #749 )

Also document the rebuild requirement in CONTRIBUTING.rst.

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/.
  • I added appropriate Fixes: annotations to PR description.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds early test-session detection of stale in-place Cython extension builds (to avoid running tests against outdated compiled code) and documents the rebuild requirement for contributors.

Changes:

  • Add pytest_configure hook in tests/conftest.py to warn when a compiled extension is older than its corresponding cassandra/*.py source.
  • Document the required python setup.py build_ext --inplace rebuild step in CONTRIBUTING.rst and note that tests will warn when staleness is detected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/conftest.py New pytest startup hook that scans for stale compiled extensions vs .py sources and emits a warning.
CONTRIBUTING.rst Adds contributor guidance about rebuilding extensions to avoid testing stale compiled code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CONTRIBUTING.rst Outdated
Comment thread tests/conftest.py Outdated
Comment thread tests/conftest.py Outdated
@Lorak-mmk Lorak-mmk self-requested a review March 19, 2026 17:27
@mykaul mykaul force-pushed the fix/detect-stale-cython-extensions branch from 91aeef3 to 668275b Compare March 20, 2026 10:46
@mykaul mykaul requested a review from Copilot March 20, 2026 12:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a pytest startup check to help developers avoid accidentally running tests against stale Cython-compiled extensions when the corresponding cassandra/*.py sources have been edited without rebuilding, and documents the rebuild requirement for contributors.

Changes:

  • Introduces a pytest_configure hook that scans for Cython extension modules and warns when a compiled extension appears older than its .py source.
  • Documents the need to rebuild extensions after editing Cython-compiled cassandra/ modules, noting that the test suite will warn on staleness.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/conftest.py Adds a pytest session-start hook that attempts to detect stale Cython extension artifacts and emits a warning.
CONTRIBUTING.rst Adds contributor guidance about rebuilding extensions after modifying Cython-compiled driver modules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/conftest.py Outdated
Comment thread CONTRIBUTING.rst
Copy link
Copy Markdown

@Lorak-mmk Lorak-mmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general I think. First 3 commits should be squashed into one.

mykaul added 2 commits April 7, 2026 21:46
Add a pytest_configure hook in tests/conftest.py that compares mtime
of each compiled extension against its .py source and warns when the
source is newer. This prevents silently testing stale compiled code
after editing a Cython-compiled module without rebuilding.

The scan iterates over .py source files and checks for the first
matching compiled extension per importlib.machinery.EXTENSION_SUFFIXES
order, mirroring Python's import machinery and handling both .so (POSIX)
and .pyd (Windows) automatically.

Also document the rebuild requirement in CONTRIBUTING.rst, using uv
commands instead of deprecated setup.py invocations.
Replace all 'python setup.py install' instructions with 'pip install .'
or 'pip install scylla-driver' equivalents. Replace setup.py-specific
command-line flags (--no-cython, --no-extensions, etc.) with their
environment variable equivalents (CASS_DRIVER_NO_CYTHON,
CASS_DRIVER_NO_EXTENSIONS, CASS_DRIVER_NO_LIBEV). Remove deprecated
pip --install-option usage.
@mykaul mykaul force-pushed the fix/detect-stale-cython-extensions branch from 8f5e85c to 35d31e3 Compare April 7, 2026 18:47
@mykaul
Copy link
Copy Markdown
Author

mykaul commented Apr 7, 2026

Looks good in general I think. First 3 commits should be squashed into one.

Squashed.

@Lorak-mmk Lorak-mmk merged commit 442074c into scylladb:master Apr 8, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants