Skip to content

Commit

Permalink
Remove deprecated "test from recipe" function (#5478)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard committed Sep 5, 2024
1 parent 23c5797 commit 12fc37c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 86 deletions.
40 changes: 1 addition & 39 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from . import environ, noarch_python, source, tarcheck, utils
from .config import Config
from .create_test import create_all_test_files
from .deprecations import deprecated
from .exceptions import (
BuildScriptException,
CondaBuildException,
Expand Down Expand Up @@ -2869,32 +2868,6 @@ def warn_on_use_of_SRC_DIR(metadata):
)


@deprecated(
"3.16.0",
"24.9.0",
addendum=(
"Test built packages instead, not recipes "
"(e.g., `conda build --test package` instead of `conda build --test recipe/`)."
),
deprecation_type=FutureWarning, # we need to warn users, not developers
)
def _construct_metadata_for_test_from_recipe(recipe_dir, config):
config.need_cleanup = False
config.recipe_dir = None
hash_input = {}
metadata = expand_outputs(
render_recipe(recipe_dir, config=config, reset_build_id=False)
)[0][1]

utils.rm_rf(metadata.config.test_dir)

if metadata.meta.get("test", {}).get("source_files"):
if not metadata.source_provided:
try_download(metadata, no_download_source=False)

return metadata, hash_input


def _construct_metadata_for_test_from_package(package, config):
recipe_dir, need_cleanup = utils.get_recipe_abspath(package)
config.need_cleanup = need_cleanup
Expand Down Expand Up @@ -3034,18 +3007,7 @@ def _extract_test_files_from_package(metadata):


def construct_metadata_for_test(recipedir_or_package, config):
if (
os.path.isdir(recipedir_or_package)
or os.path.basename(recipedir_or_package) == "meta.yaml"
):
m, hash_input = _construct_metadata_for_test_from_recipe(
recipedir_or_package, config
)
else:
m, hash_input = _construct_metadata_for_test_from_package(
recipedir_or_package, config
)
return m, hash_input
return _construct_metadata_for_test_from_package(recipedir_or_package, config)


def _set_env_variables_for_build(m, env):
Expand Down
19 changes: 19 additions & 0 deletions news/5478-24.9-removals
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* <news item>

### Deprecations

* Remove `conda_build.build._construct_metadata_for_test_from_recipe`. Test built packages instead, not recipes (e.g., `conda build --test package` instead of `conda build --test recipe/`). (#5478)

### Docs

* <news item>

### Other

* <news item>
29 changes: 0 additions & 29 deletions tests/cli/test_main_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,35 +443,6 @@ def test_relative_path_test_artifact(
main_build.execute(args)


def test_relative_path_test_recipe(conda_build_test_recipe_envvar: str):
# this test builds a package into (cwd)/relative/path and then calls:
# conda-build --test --croot ./relative/path/ /abs/path/to/recipe

empty_sections = Path(metadata_dir, "empty_with_build_script")
croot_rel = Path(".", "relative", "path")
croot_abs = croot_rel.resolve()

# build the package
args = [
"--no-anaconda-upload",
"--no-test",
f"--croot={croot_abs}",
str(empty_sections),
]
main_build.execute(args)

assert len(list(croot_abs.glob("**/*.tar.bz2"))) == 1

# run the test stage with relative croot
args = [
"--no-anaconda-upload",
"--test",
f"--croot={croot_rel}",
str(empty_sections),
]
main_build.execute(args)


def test_test_extra_dep(testing_metadata):
testing_metadata.meta["test"]["imports"] = ["imagesize"]
api.output_yaml(testing_metadata, "meta.yaml")
Expand Down
9 changes: 0 additions & 9 deletions tests/test_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@
from .utils import metadata_dir


@pytest.mark.sanity
def test_recipe_test(testing_config):
"""Test calling conda build -t <recipe dir>"""
recipe = os.path.join(metadata_dir, "has_prefix_files")
metadata = api.render(recipe, config=testing_config)[0][0]
api.build(metadata, notest=True, anaconda_upload=False)
api.test(recipe, config=metadata.config)


@pytest.mark.sanity
def test_package_test(testing_config):
"""Test calling conda build -t <package file> - rather than <recipe dir>"""
Expand Down
10 changes: 1 addition & 9 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from conda_build import api, build
from conda_build.exceptions import CondaBuildUserError

from .utils import get_noarch_python_meta, metadata_dir, metadata_path
from .utils import get_noarch_python_meta, metadata_dir

if TYPE_CHECKING:
from conda_build.config import Config
Expand Down Expand Up @@ -349,14 +349,6 @@ def test_copy_readme(testing_metadata: MetaData, readme: str):
assert Path(testing_metadata.config.info_dir, readme).exists()


def test_construct_metadata_for_test_from_recipe(testing_config: Config) -> None:
with pytest.warns(FutureWarning):
build._construct_metadata_for_test_from_recipe(
str(metadata_path / "test_source_files"),
testing_config,
)


@pytest.mark.skipif(not on_win, reason="WSL is only on Windows")
def test_wsl_unsupported(
testing_metadata: MetaData,
Expand Down

0 comments on commit 12fc37c

Please sign in to comment.