Skip to content

Commit

Permalink
Remove test related to old python2 warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jvolkman committed Jul 1, 2022
1 parent cf7fafe commit c3d43ec
Showing 1 changed file with 0 additions and 114 deletions.
114 changes: 0 additions & 114 deletions src/test/shell/bazel/python_version_test.sh
Expand Up @@ -601,120 +601,6 @@ function test_default_output_root_is_bazel_bin() {
expect_not_log "bazel-out/.*-py3.*/bin"
}

# Tests that we get a warning when host tools fail due to being built for the
# wrong Python version. See #7899 and #8549 for context, as well as
# {@link PyCommon#shouldWarnAboutHostVersionUponFailure}.
# TODO(#6443): Delete this once we no longer have the host configuration.
function test_host_version_mismatch_warning() {
mkdir -p test

cat > test/BUILD << 'EOF'
py_binary(
name = "passing_tool_using_py2_explicitly",
srcs = ["success.py"],
main = "success.py",
python_version = "PY2",
)
py_binary(
name = "failing_tool_using_py2_explicitly",
srcs = ["fail.py"],
main = "fail.py",
python_version = "PY2",
)
py_binary(
name = "failing_tool_using_py3_explicitly",
srcs = ["fail.py"],
main = "fail.py",
python_version = "PY3",
)
py_binary(
name = "failing_tool_using_py3_implicitly",
srcs = ["fail.py"],
main = "fail.py",
)
# For each tool, a genrule target that uses it.
genrule(
name = "invoke_passing_tool_using_py2_explicitly",
cmd = "$(location :passing_tool_using_py2_explicitly) > $@",
tools = [":passing_tool_using_py2_explicitly"],
outs = ["passing_tool_using_py2_explicitly.txt"],
)
genrule(
name = "invoke_failing_tool_using_py2_explicitly",
cmd = "$(location :failing_tool_using_py2_explicitly) > $@",
tools = [":failing_tool_using_py2_explicitly"],
outs = ["failing_tool_using_py2_explicitly.txt"],
)
genrule(
name = "invoke_failing_tool_using_py3_explicitly",
cmd = "$(location :failing_tool_using_py3_explicitly) > $@",
tools = [":failing_tool_using_py3_explicitly"],
outs = ["failing_tool_using_py3_explicitly.txt"],
)
genrule(
name = "invoke_failing_tool_using_py3_implicitly",
cmd = "$(location :failing_tool_using_py3_implicitly) > $@",
tools = [":failing_tool_using_py3_implicitly"],
outs = ["failing_tool_using_py3_implicitly.txt"],
)
EOF
cat > test/success.py << EOF
print("Successfully did nothing.")
EOF
cat > test/fail.py << EOF
import sys
sys.exit(1)
EOF

# Relies on --incompatible_py3_is_default being true (flipped in Bazel 0.25).

# The warning should be present if the tool
# 1) was built with toolchains enabled,
# 2) in the host config,
# 3) with a mismatched version, or a version set implicitly,
# 4) and it failed during execution.

# Warning should be present due to explicit version mismatch with host config.
bazel build //test:invoke_failing_tool_using_py2_explicitly \
--incompatible_use_python_toolchains=true --host_force_python=PY3 \
&> $TEST_log && fail "bazel build succeeded (expected failure)"
expect_log "it is a Python 2 program that was built in the host \
configuration, which uses Python 3"

# Warning should be present due to implicitly set version, even though it
# matches host config.
bazel build //test:invoke_failing_tool_using_py3_implicitly \
--incompatible_use_python_toolchains=true --host_force_python=PY3 \
&> $TEST_log && fail "bazel build succeeded (expected failure)"
expect_log "it is running under Python 3 instead of Python 2"

# No warning if version was set explicitly and matches host config.
bazel build //test:invoke_failing_tool_using_py2_explicitly \
--incompatible_use_python_toolchains=true --host_force_python=PY2 \
&> $TEST_log && fail "bazel build succeeded (expected failure)"
expect_not_log "Note: The above Python target's failure"

# No warning if toolchains are disabled.
bazel build //test:invoke_failing_tool_using_py2_explicitly \
--incompatible_use_python_toolchains=false --host_force_python=PY3 \
&> $TEST_log && fail "bazel build succeeded (expected failure)"
expect_not_log "Note: The above Python target's failure"

# No warning if it succeeded during execution.
bazel build //test:invoke_passing_tool_using_py2_explicitly \
--incompatible_use_python_toolchains=true --host_force_python=PY3 \
&> $TEST_log || fail "bazel build failed (expected success)"
expect_not_log "Note: The above Python target's failure"
}

# Regression test for (bazelbuild/continuous-integration#578): Ensure that a
# py_binary built with the autodetecting toolchain works when used as a tool
# from Starlark rule. In particular, the wrapper script that launches the real
Expand Down

0 comments on commit c3d43ec

Please sign in to comment.