Skip to content

Commit 194a388

Browse files
authored
chore: Add tests covering the version transition (#661)
Fixes #541 by failure to reproduce. ### Changes are visible to end-users: no ### Test plan This is the test plan.
1 parent 20abf8c commit 194a388

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
folders: |
3030
[
3131
"e2e/cross-repo-610",
32+
"e2e/interpreter-version-541",
3233
"e2e/repository-rule-deps",
3334
"e2e/smoke",
3435
"e2e/system-interpreter",
@@ -41,6 +42,7 @@ jobs:
4142
[
4243
{"os": "windows-latest"},
4344
{"folder": "e2e/cross-repo-610", "bzlmodEnabled": false},
45+
{"folder": "e2e/interpreter-version-541", "bzlmodEnabled": false},
4446
{"folder": "e2e/repository-rule-deps", "bzlmodEnabled": false},
4547
{"folder": "e2e/system-interpreter", "bzlmodEnabled": false},
4648
{"folder": "examples/uv_pip_compile", "bzlmodEnabled": false},
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
2+
load("@aspect_rules_py//py:defs.bzl", "py_test")
3+
load("@aspect_rules_py//py/unstable:defs.bzl", "py_venv_test")
4+
5+
[
6+
[
7+
expand_template(
8+
name = "expanded_test_{}.py".format(ver.replace(".", "_")),
9+
out = "test_{}.py".format(ver.replace(".", "_")),
10+
substitutions = {
11+
"<VERSION>": ver,
12+
},
13+
template = "test.py",
14+
),
15+
py_venv_test(
16+
name = "test_{}_venv".format(ver.replace(".", "_")),
17+
srcs = [
18+
"expanded_test_{}.py".format(ver.replace(".", "_")),
19+
],
20+
imports = [
21+
".",
22+
],
23+
main = "expanded_test_{}.py".format(ver.replace(".", "_")),
24+
python_version = ver,
25+
),
26+
py_test(
27+
name = "test_{}_classic".format(ver.replace(".", "_")),
28+
srcs = [
29+
"expanded_test_{}.py".format(ver.replace(".", "_")),
30+
],
31+
imports = [
32+
".",
33+
],
34+
main = "expanded_test_{}.py".format(ver.replace(".", "_")),
35+
python_version = ver,
36+
),
37+
]
38+
for ver in [
39+
"3.11",
40+
"3.12",
41+
"3.13",
42+
]
43+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"Bazel dependencies"
2+
3+
bazel_dep(name = "aspect_rules_py", version = "0.0.0", dev_dependency = True)
4+
local_path_override(
5+
module_name = "aspect_rules_py",
6+
path = "../..",
7+
)
8+
9+
bazel_dep(name = "aspect_bazel_lib", version = "2.16.0")
10+
11+
bazel_dep(name = "rules_python", version = "1.6.3", dev_dependency = True)
12+
13+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
14+
python.toolchain(
15+
python_version = "3.11",
16+
)
17+
python.toolchain(
18+
python_version = "3.12",
19+
)
20+
python.toolchain(
21+
python_version = "3.13",
22+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
import site
5+
6+
print("---")
7+
print("__file__:", __file__)
8+
print("sys.prefix:", sys.prefix)
9+
print("sys.executable:", sys.executable)
10+
print("site.PREFIXES:")
11+
for p in site.PREFIXES:
12+
print(" -", p)
13+
14+
# The virtualenv module should have already been loaded at interpreter startup
15+
assert "_virtualenv" in sys.modules
16+
17+
# Assert that we booted against the expected interpreter version
18+
EXPECTED_VERSION = "<VERSION>"
19+
print(repr(EXPECTED_VERSION))
20+
print(repr(sys.version))
21+
assert sys.version.startswith(EXPECTED_VERSION)

0 commit comments

Comments
 (0)