Add .bzl files explicitly to toolchain tests to detect .bzl file changes (#815)
Co-authored-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
diff --git a/BUILD b/BUILD
index ebdf74e..7ea2aa4 100644
--- a/BUILD
+++ b/BUILD
@@ -39,6 +39,7 @@
],
visibility = [
"//examples:__pkg__",
+ "//python/tests/toolchains:__pkg__",
"//tests:__pkg__",
],
)
diff --git a/python/tests/toolchains/defs.bzl b/python/tests/toolchains/defs.bzl
index 8c07d23..2abc1ed 100644
--- a/python/tests/toolchains/defs.bzl
+++ b/python/tests/toolchains/defs.bzl
@@ -39,10 +39,6 @@
)
python_version_test = ctx.actions.declare_file("/".join([ctx.attr.python_version, "python_version_test.py"]))
-
- # With the current approach in the run_acceptance_test.sh, we use this
- # symlink to find the absolute path to the rules_python to be passed to the
- # --override_repository rules_python=<rules_python_path>.
ctx.actions.symlink(
target_file = ctx.file._python_version_test,
output = python_version_test,
@@ -92,7 +88,7 @@
python_version_test,
run_acceptance_test_py,
workspace,
- ]
+ ] + ctx.files._distribution
return [DefaultInfo(
executable = executable,
files = depset(
@@ -126,6 +122,10 @@
allow_single_file = True,
default = Label("//python/tests/toolchains/workspace_template:BUILD.bazel.tmpl"),
),
+ "_distribution": attr.label(
+ doc = "The rules_python source distribution.",
+ default = Label("//:distribution"),
+ ),
"_python_version_test": attr.label(
doc = "The python_version_test.py used to test the Python version.",
allow_single_file = True,
diff --git a/python/tests/toolchains/run_acceptance_test.py.tmpl b/python/tests/toolchains/run_acceptance_test.py.tmpl
index 51eba3d..b3071a7 100644
--- a/python/tests/toolchains/run_acceptance_test.py.tmpl
+++ b/python/tests/toolchains/run_acceptance_test.py.tmpl
@@ -21,12 +21,7 @@
@classmethod
def setUpClass(cls):
os.chdir("%test_location%")
- python_version_test_dirname = os.path.dirname(
- os.path.realpath("python_version_test.py")
- )
- rules_python_path = os.path.normpath(
- os.path.join(python_version_test_dirname, "..", "..", "..", "..")
- )
+ rules_python_path = os.path.join(os.environ["TEST_SRCDIR"], "rules_python")
if %is_windows%:
test_tmpdir = os.environ["TEST_TMPDIR"]