From 12fc37c6522e98ea8d94c5491328557ea0fc1358 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 5 Sep 2024 10:08:45 -0500 Subject: [PATCH] Remove deprecated "test from recipe" function (#5478) --- conda_build/build.py | 40 +----------------------------------- news/5478-24.9-removals | 19 +++++++++++++++++ tests/cli/test_main_build.py | 29 -------------------------- tests/test_api_test.py | 9 -------- tests/test_build.py | 10 +-------- 5 files changed, 21 insertions(+), 86 deletions(-) create mode 100644 news/5478-24.9-removals diff --git a/conda_build/build.py b/conda_build/build.py index 5d062f7720..3edf3e0185 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -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, @@ -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 @@ -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): diff --git a/news/5478-24.9-removals b/news/5478-24.9-removals new file mode 100644 index 0000000000..5d19e52eda --- /dev/null +++ b/news/5478-24.9-removals @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* + +### 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 + +* + +### Other + +* diff --git a/tests/cli/test_main_build.py b/tests/cli/test_main_build.py index ed56cabceb..d78f87b749 100644 --- a/tests/cli/test_main_build.py +++ b/tests/cli/test_main_build.py @@ -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") diff --git a/tests/test_api_test.py b/tests/test_api_test.py index 10200d5a99..3fa6286dcb 100644 --- a/tests/test_api_test.py +++ b/tests/test_api_test.py @@ -14,15 +14,6 @@ from .utils import metadata_dir -@pytest.mark.sanity -def test_recipe_test(testing_config): - """Test calling conda build -t """ - 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 - rather than """ diff --git a/tests/test_build.py b/tests/test_build.py index 40ed500020..560602f83d 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -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 @@ -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,