Skip to content

Conversation

@redsun82
Copy link
Contributor

This mode (enabled with --codeql=build-as-test or setting PYTEST_CODEQL=build-as-test in the environment) is an experimental mode that makes the pytest dist installation run as a test. This allows to avoid running the installation in case nothing changed in the dist, leveraging bazel's test caching mechanism, and accelrating the dev loop when working on integration test code. This mode might become the default for devs in the future.

Up until now, this mode was only working on POSIX systems. This commit fixes it on Windows. The issue was native_test being unable to wrap a py_binary target because of an .exe suffix mismatch. Turning the native_test into a full-fledged py_test solves the issue.

@redsun82 redsun82 requested a review from a team as a code owner October 14, 2025 13:36
Copilot AI review requested due to automatic review settings October 14, 2025 13:36
Copy link
Contributor

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

This PR fixes the experimental build-as-test mode for pytest on Windows systems by addressing an issue where native_test couldn't properly wrap a py_binary target due to .exe suffix mismatches on Windows.

Key changes:

  • Replaces native_test with py_test for the test wrapper
  • Refactors common installer arguments into a shared dictionary to avoid duplication

This mode (enabled with `--codeql=build-as-test` or setting
`PYTEST_CODEQL=build-as-test` in the environment) is an experimental
mode that makes the pytest dist installation run as a test. This
allows to avoid running the installation in case nothing changed in the
dist, leveraging bazel's test caching mechanism, and accelrating the
dev loop when working on integration test code. This mode might become
the default for devs in the future.

Up until now, this mode was only working on POSIX systems. This commit
fixes it on Windows. The issue was `native_test` being unable to wrap
a `py_binary` target because of an `.exe` suffix mismatch. Turning the
`native_test` into a full-fledged `py_test` solves the issue.
@redsun82 redsun82 force-pushed the redsun82/fix-pytest-build-as-test-windows branch from 5a697ae to b6aee67 Compare October 14, 2025 13:44
Copy link
Contributor

@esbena esbena left a comment

Choose a reason for hiding this comment

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

sounds right, but without the PR body I would never have guessed that this was a windows fix.

@redsun82 redsun82 merged commit 630ea7b into main Oct 27, 2025
23 checks passed
@redsun82 redsun82 deleted the redsun82/fix-pytest-build-as-test-windows branch October 27, 2025 14:47
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.

3 participants