diff --git a/src/python/pants/backend/docker/goals/package_image.py b/src/python/pants/backend/docker/goals/package_image.py index d5451e3d22b..46ca9994c29 100644 --- a/src/python/pants/backend/docker/goals/package_image.py +++ b/src/python/pants/backend/docker/goals/package_image.py @@ -8,7 +8,7 @@ from dataclasses import dataclass from functools import partial from itertools import chain -from typing import Iterator +from typing import Iterator, cast # Re-exporting BuiltDockerImage here, as it has its natural home here, but has moved out to resolve # a dependency cycle from docker_build_context. @@ -170,7 +170,9 @@ def get_context_root(self, default_context_root: str) -> str: if self.context_root.value is not None: context_root = self.context_root.value else: - context_root = default_context_root + context_root = cast( + str, self.context_root.compute_value(default_context_root, self.address) + ) if context_root.startswith("./"): context_root = os.path.join(self.address.spec_path, context_root) return os.path.normpath(context_root) diff --git a/src/python/pants/backend/docker/goals/package_image_test.py b/src/python/pants/backend/docker/goals/package_image_test.py index 9f817f2e036..a7e406f7616 100644 --- a/src/python/pants/backend/docker/goals/package_image_test.py +++ b/src/python/pants/backend/docker/goals/package_image_test.py @@ -52,13 +52,7 @@ from pants.option.global_options import GlobalOptions, ProcessCleanupOption from pants.testutil.option_util import create_subsystem from pants.testutil.pytest_util import assert_logged, no_exception -from pants.testutil.rule_runner import ( - MockGet, - QueryRule, - RuleRunner, - engine_error, - run_rule_with_mocks, -) +from pants.testutil.rule_runner import MockGet, QueryRule, RuleRunner, run_rule_with_mocks from pants.util.frozendict import FrozenDict @@ -896,20 +890,20 @@ def test_invalid_build_target_stage(rule_runner: RuleRunner) -> None: ( "/", None, - engine_error( + pytest.raises( InvalidFieldException, - contains=("Use '' for a path relative to the build root, or './' for"), + match=r"Use '' for a path relative to the build root, or '\./' for", ), ), ( "/src", None, - engine_error( + pytest.raises( InvalidFieldException, - contains=( - "The `context_root` field in target src/docker:image must be a relative path, but was " - "'/src'. Use 'src' for a path relative to the build root, or './src' for a path " - "relative to the BUILD file (i.e. 'src/docker/src')." + match=( + r"The `context_root` field in target src/docker:image must be a relative path, " + r"but was '/src'\. Use 'src' for a path relative to the build root, or '\./src' " + r"for a path relative to the BUILD file \(i\.e\. 'src/docker/src'\)\." ), ), ), @@ -931,7 +925,6 @@ def test_get_context_root( raises = cast("ContextManager", no_exception()) else: raises = expected_context_root - expected_context_root = "" with raises: docker_options = create_subsystem( @@ -942,8 +935,7 @@ def test_get_context_root( tgt = DockerImageTarget({"context_root": context_root}, address) fs = DockerFieldSet.create(tgt) actual_context_root = fs.get_context_root(docker_options.default_context_root) - if expected_context_root: - assert actual_context_root == expected_context_root + assert actual_context_root == expected_context_root @pytest.mark.parametrize( diff --git a/src/python/pants/backend/go/util_rules/third_party_pkg_test.py b/src/python/pants/backend/go/util_rules/third_party_pkg_test.py index 2f8459a65f7..fa124bfe342 100644 --- a/src/python/pants/backend/go/util_rules/third_party_pkg_test.py +++ b/src/python/pants/backend/go/util_rules/third_party_pkg_test.py @@ -264,6 +264,8 @@ def test_invalid_go_sum(rule_runner: RuleRunner) -> None: rule_runner.request(AllThirdPartyPackages, [AllThirdPartyPackagesRequest(digest, "go.mod")]) +@pytest.mark.skip(reason="TODO(#15824)") +@pytest.mark.no_error_if_skipped def test_missing_go_sum(rule_runner: RuleRunner) -> None: digest = set_up_go_mod( rule_runner, @@ -286,6 +288,8 @@ def test_missing_go_sum(rule_runner: RuleRunner) -> None: rule_runner.request(AllThirdPartyPackages, [AllThirdPartyPackagesRequest(digest, "go.mod")]) +@pytest.mark.skip(reason="TODO(#15824)") +@pytest.mark.no_error_if_skipped def test_stale_go_mod(rule_runner: RuleRunner) -> None: digest = set_up_go_mod( rule_runner, diff --git a/src/python/pants/backend/python/util_rules/pex_from_targets_test.py b/src/python/pants/backend/python/util_rules/pex_from_targets_test.py index 5ea595f0f87..0b78bb50f22 100644 --- a/src/python/pants/backend/python/util_rules/pex_from_targets_test.py +++ b/src/python/pants/backend/python/util_rules/pex_from_targets_test.py @@ -69,6 +69,8 @@ def rule_runner() -> RuleRunner: ) +@pytest.mark.skip(reason="TODO(#15824)") +@pytest.mark.no_error_if_skipped def test_choose_compatible_resolve(rule_runner: RuleRunner) -> None: def create_target_files( directory: str, *, req_resolve: str, source_resolve: str, test_resolve: str diff --git a/src/python/pants/jvm/resolve/coursier_fetch_integration_test.py b/src/python/pants/jvm/resolve/coursier_fetch_integration_test.py index 1fe8f26207f..32f57e1df94 100644 --- a/src/python/pants/jvm/resolve/coursier_fetch_integration_test.py +++ b/src/python/pants/jvm/resolve/coursier_fetch_integration_test.py @@ -155,6 +155,8 @@ def test_resolve_with_inexact_coord(rule_runner: RuleRunner) -> None: ) +@pytest.mark.skip(reason="TODO(#15824)") +@pytest.mark.no_error_if_skipped @maybe_skip_jdk_test def test_resolve_conflicting(rule_runner: RuleRunner) -> None: with engine_error( diff --git a/src/python/pants/testutil/rule_runner.py b/src/python/pants/testutil/rule_runner.py index 7cac57bf542..fdec63c2a09 100644 --- a/src/python/pants/testutil/rule_runner.py +++ b/src/python/pants/testutil/rule_runner.py @@ -135,6 +135,11 @@ def engine_error( f"expected: {contains}\n\n" f"exception: {underlying}" ) + else: + raise AssertionError( + "DID NOT RAISE ExecutionError with underlying exception type " + f"{expected_underlying_exception}." + ) # -----------------------------------------------------------------------------------------------