|
1 | 1 | load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
| 2 | +load("@bazel_skylib//rules:diff_test.bzl", "diff_test") |
| 3 | +load("@bazel_skylib//rules:write_file.bzl", "write_file") |
2 | 4 | load("@python//3.10:defs.bzl", py_binary_3_10 = "py_binary", py_test_3_10 = "py_test")
|
3 | 5 | load("@python//3.11:defs.bzl", py_binary_3_11 = "py_binary", py_test_3_11 = "py_test")
|
4 | 6 | load("@python//3.8:defs.bzl", py_binary_3_8 = "py_binary", py_test_3_8 = "py_test")
|
5 | 7 | load("@python//3.9:defs.bzl", py_binary_3_9 = "py_binary", py_test_3_9 = "py_test")
|
| 8 | +load("@pythons_hub//:versions.bzl", "MINOR_MAPPING", "PYTHON_VERSIONS") |
6 | 9 | load("@rules_python//python:defs.bzl", "py_binary", "py_test")
|
| 10 | +load("@rules_python//python:versions.bzl", DEFAULT_MINOR_MAPPING = "MINOR_MAPPING", DEFAULT_TOOL_VERSIONS = "TOOL_VERSIONS") |
| 11 | +load("@rules_python//python/private:text_util.bzl", "render") # buildifier: disable=bzl-visibility |
7 | 12 | load("@rules_shell//shell:sh_test.bzl", "sh_test")
|
8 | 13 |
|
9 | 14 | copy_file(
|
@@ -183,3 +188,37 @@ sh_test(
|
183 | 188 | "VERSION_PY_BINARY": "$(rootpath :version_3_10)",
|
184 | 189 | },
|
185 | 190 | )
|
| 191 | + |
| 192 | +# The following test ensures that default toolchain versions are the same as in |
| 193 | +# the TOOL_VERSIONS array. |
| 194 | + |
| 195 | +# NOTE @aignas 2024-10-26: This test here is to do a sanity check and not |
| 196 | +# include extra dependencies - if rules_testing is included here, we can |
| 197 | +# potentially uses `rules_testing` for a more lightweight test. |
| 198 | +write_file( |
| 199 | + name = "default_python_versions", |
| 200 | + out = "default_python_versions.txt", |
| 201 | + content = [ |
| 202 | + "MINOR_MAPPING:", |
| 203 | + render.dict(dict(sorted(DEFAULT_MINOR_MAPPING.items()))), |
| 204 | + "PYTHON_VERSIONS:", |
| 205 | + render.list(sorted(DEFAULT_TOOL_VERSIONS)), |
| 206 | + ], |
| 207 | +) |
| 208 | + |
| 209 | +write_file( |
| 210 | + name = "pythons_hub_versions", |
| 211 | + out = "pythons_hub_versions.txt", |
| 212 | + content = [ |
| 213 | + "MINOR_MAPPING:", |
| 214 | + render.dict(dict(sorted(MINOR_MAPPING.items()))), |
| 215 | + "PYTHON_VERSIONS:", |
| 216 | + render.list(sorted(PYTHON_VERSIONS)), |
| 217 | + ], |
| 218 | +) |
| 219 | + |
| 220 | +diff_test( |
| 221 | + name = "test_versions", |
| 222 | + file1 = "default_python_versions", |
| 223 | + file2 = "pythons_hub_versions", |
| 224 | +) |
0 commit comments