Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .bzl files explicitly to toolchain tests to detect .bzl file changes #815

Merged
merged 4 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ filegroup(
],
visibility = [
"//examples:__pkg__",
"//python/tests/toolchains:__pkg__",
"//tests:__pkg__",
],
)
Expand Down
10 changes: 5 additions & 5 deletions python/tests/toolchains/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def _acceptance_test_impl(ctx):
)

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,
Expand Down Expand Up @@ -92,7 +88,7 @@ def _acceptance_test_impl(ctx):
python_version_test,
run_acceptance_test_py,
workspace,
]
] + ctx.files._distribution
return [DefaultInfo(
executable = executable,
files = depset(
Expand Down Expand Up @@ -126,6 +122,10 @@ _acceptance_test = rule(
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,
Expand Down
7 changes: 1 addition & 6 deletions python/tests/toolchains/run_acceptance_test.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ class TestPythonVersion(unittest.TestCase):
@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"]
Expand Down