Skip to content

Commit

Permalink
Update tests to be compatible with --incompatible_allow_python_versio…
Browse files Browse the repository at this point in the history
…n_transitions

Work toward #7307.

RELNOTES: None
PiperOrigin-RevId: 236718484
  • Loading branch information
brandjon authored and copybara-github committed Mar 4, 2019
1 parent 2537cb7 commit bc1b9de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,16 @@ public void canBuildWithDifferentVersionAttrs_UnderOldSemantics_FlagSetToDefault
ruleDeclWithDefaultPyVersionAttr("foo_v2", "PY2"),
ruleDeclWithDefaultPyVersionAttr("foo_v3", "PY3"));

assertPythonVersionIs_UnderNewConfig("//pkg:foo_v2", PythonVersion.PY2, "--force_python=PY2");
assertPythonVersionIs_UnderNewConfig("//pkg:foo_v3", PythonVersion.PY2, "--force_python=PY2");
assertPythonVersionIs_UnderNewConfig(
"//pkg:foo_v2",
PythonVersion.PY2,
"--incompatible_allow_python_version_transitions=false",
"--force_python=PY2");
assertPythonVersionIs_UnderNewConfig(
"//pkg:foo_v3",
PythonVersion.PY2,
"--incompatible_allow_python_version_transitions=false",
"--force_python=PY2");
}

@Test
Expand All @@ -421,8 +429,16 @@ public void canBuildWithDifferentVersionAttrs_UnderOldSemantics_FlagSetToNonDefa
ruleDeclWithDefaultPyVersionAttr("foo_v2", "PY2"),
ruleDeclWithDefaultPyVersionAttr("foo_v3", "PY3"));

assertPythonVersionIs_UnderNewConfig("//pkg:foo_v2", PythonVersion.PY3, "--force_python=PY3");
assertPythonVersionIs_UnderNewConfig("//pkg:foo_v3", PythonVersion.PY3, "--force_python=PY3");
assertPythonVersionIs_UnderNewConfig(
"//pkg:foo_v2",
PythonVersion.PY3,
"--incompatible_allow_python_version_transitions=false",
"--force_python=PY3");
assertPythonVersionIs_UnderNewConfig(
"//pkg:foo_v3",
PythonVersion.PY3,
"--incompatible_allow_python_version_transitions=false",
"--force_python=PY3");
}

@Test
Expand Down
11 changes: 7 additions & 4 deletions src/test/shell/integration/python_stub_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,22 @@ EOF
&> $TEST_log || fail "bazel run failed"
expect_log "I am Python 3"

# These assertions try to override the version, which is legacy semantics.
FLAG=--incompatible_allow_python_version_transitions=false

# Force to Python 2.
bazel run //test:main2 --force_python=PY2 \
bazel run //test:main2 $FLAG --force_python=PY2 \
&> $TEST_log || fail "bazel run failed"
expect_log "I am Python 2"
bazel run //test:main3 --force_python=PY2 \
bazel run //test:main3 $FLAG --force_python=PY2 \
&> $TEST_log || fail "bazel run failed"
expect_log "I am Python 2"

# Force to Python 3.
bazel run //test:main2 --force_python=PY3 \
bazel run //test:main2 $FLAG --force_python=PY3 \
&> $TEST_log || fail "bazel run failed"
expect_log "I am Python 3"
bazel run //test:main3 --force_python=PY3 \
bazel run //test:main3 $FLAG --force_python=PY3 \
&> $TEST_log || fail "bazel run failed"
expect_log "I am Python 3"
}
Expand Down

0 comments on commit bc1b9de

Please sign in to comment.