Skip to content

Commit

Permalink
test: Fix test_activated_prefixes_in_actual_path
Browse files Browse the repository at this point in the history
Needed to set .activate=True on the MetaData's own .config
  • Loading branch information
mbargull committed Dec 3, 2022
1 parent 7f047c7 commit 060f10f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2584,6 +2584,9 @@ def construct_metadata_for_test(recipedir_or_package, config):


def write_build_scripts(m, script, build_file):
# TODO: Prepending the prefixes here should probably be guarded by
# if not m.activate_build_script:
# Leaving it as is, for now, since we need a quick, non-disruptive patch release.
with utils.path_prepended(m.config.host_prefix):
with utils.path_prepended(m.config.build_prefix):
env = environ.get_dict(m=m)
Expand Down
8 changes: 6 additions & 2 deletions tests/test_api_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1657,12 +1657,13 @@ def assert_keyword(keyword):
@pytest.mark.slow
def test_activated_prefixes_in_actual_path(testing_config, testing_metadata):
file = "env-path-dump"
testing_metadata.config.activate = True
meta = testing_metadata.meta
meta["requirements"]["host"] = []
meta["build"]["script"] = [
f"echo %PATH%>%PREFIX%/{file}" if on_win else f"echo $PATH>$PREFIX/{file}"
]
outputs = api.build(testing_metadata, activate=True)
outputs = api.build(testing_metadata)
env = {"PATH": ""}
prepend_bin_path(env, testing_metadata.config.host_prefix)
prepend_bin_path(env, testing_metadata.config.build_prefix)
Expand All @@ -1672,4 +1673,7 @@ def test_activated_prefixes_in_actual_path(testing_config, testing_metadata):
for path in package_has_file(outputs[0], file).strip().split(os.pathsep)
if path in expected_paths
]
assert actual_paths == expected_paths
# We get the PATH entries twice:
# 1. from the environment activation hooks,
# 2. also beforehand from utils.path_prepended at the top of build.write_build_scripts
assert actual_paths == expected_paths * 2

0 comments on commit 060f10f

Please sign in to comment.