From 3a23e255356c534375ad92bd7d8e695d6872c47f Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 7 Nov 2023 12:07:39 +0100 Subject: [PATCH 1/5] mark unicode_all_over as xfail --- tests/test_api_build.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_api_build.py b/tests/test_api_build.py index c3059f066d..999ec3e34b 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -30,6 +30,7 @@ from conda_build.conda_interface import ( CondaError, LinkError, + context, cc_conda_build, reset_context, url_path, @@ -123,6 +124,9 @@ def test_recipe_builds( # ``source_setup_py_data_subdir`` reproduces the problem. if recipe.name == "source_setup_py_data_subdir": pytest.xfail("Issue related to #3754 on conda-build.") + elif recipe.name == "unicode_all_over" and context.solver == "libmamba": + pytest.xfail("Unicode package names not supported in libmamba.") + # These variables are defined solely for testing purposes, # so they can be checked within build scripts testing_config.activate = True From 33e6523fc73f8ab047c1332afa042b512215b16a Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 10 Nov 2023 20:13:22 +0100 Subject: [PATCH 2/5] add news --- news/5059-ci-conda-libmamba-solver | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/5059-ci-conda-libmamba-solver diff --git a/news/5059-ci-conda-libmamba-solver b/news/5059-ci-conda-libmamba-solver new file mode 100644 index 0000000000..daf2d919bf --- /dev/null +++ b/news/5059-ci-conda-libmamba-solver @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* + +### Deprecations + +* + +### Docs + +* + +### Other + +* Mark Unicode tests as incompatible with `libmamba`. (#5059) From 082b5f549392764284da7776924671362ea18287 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 10 Nov 2023 20:13:33 +0100 Subject: [PATCH 3/5] pre-commit --- tests/test_api_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_api_build.py b/tests/test_api_build.py index 999ec3e34b..7c379237a3 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -30,8 +30,8 @@ from conda_build.conda_interface import ( CondaError, LinkError, - context, cc_conda_build, + context, reset_context, url_path, ) From 031dac440aa359463cec96f8ad91004dc56f0496 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 16 Nov 2023 22:58:28 -0600 Subject: [PATCH 4/5] Replace tempfile.TemporaryDirectory with tmp_path --- tests/cli/test_main_build.py | 64 ++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/cli/test_main_build.py b/tests/cli/test_main_build.py index 3f91d42d8c..ba6276310e 100644 --- a/tests/cli/test_main_build.py +++ b/tests/cli/test_main_build.py @@ -3,6 +3,7 @@ import os import re import sys +from pathlib import Path import pytest @@ -196,41 +197,40 @@ def test_build_multiple_recipes(testing_metadata, testing_workdir, testing_confi main_build.execute(args) -def test_build_output_folder(testing_workdir, testing_metadata, capfd): +def test_build_output_folder(testing_workdir, testing_metadata, tmp_path: Path): api.output_yaml(testing_metadata, "meta.yaml") - with TemporaryDirectory() as tmp: - out = os.path.join(tmp, "out") - args = [ - testing_workdir, - "--no-build-id", - "--croot", - tmp, - "--no-activate", - "--no-anaconda-upload", - "--output-folder", - out, - ] - output = main_build.execute(args)[0] - assert os.path.isfile( - os.path.join( - out, testing_metadata.config.host_subdir, os.path.basename(output) - ) - ) + out = tmp_path / "out" + out.mkdir(parents=True) -def test_build_source(testing_workdir): - with TemporaryDirectory() as tmp: - args = [ - os.path.join(metadata_dir, "_pyyaml_find_header"), - "--source", - "--no-build-id", - "--croot", - tmp, - "--no-activate", - "--no-anaconda-upload", - ] - main_build.execute(args) - assert os.path.isfile(os.path.join(tmp, "work", "setup.py")) + args = [ + testing_workdir, + "--no-build-id", + "--croot", + str(tmp_path), + "--no-activate", + "--no-anaconda-upload", + "--output-folder", + str(out), + ] + output = main_build.execute(args)[0] + assert ( + out / testing_metadata.config.host_subdir / os.path.basename(output) + ).is_file() + + +def test_build_source(testing_workdir, tmp_path: Path): + args = [ + os.path.join(metadata_dir, "_pyyaml_find_header"), + "--source", + "--no-build-id", + "--croot", + str(tmp_path), + "--no-activate", + "--no-anaconda-upload", + ] + main_build.execute(args) + assert (tmp_path / "work" / "setup.py").is_file() @pytest.mark.serial From d636ec990816eedfc82de4b84ee9fe96b059b613 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Fri, 17 Nov 2023 00:22:43 -0600 Subject: [PATCH 5/5] Update testing_workdir using tmp_path & monkeypatch --- tests/cli/test_main_build.py | 12 ++++++------ tests/conftest.py | 27 +++++++++++---------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/tests/cli/test_main_build.py b/tests/cli/test_main_build.py index ba6276310e..e1ccd90d8c 100644 --- a/tests/cli/test_main_build.py +++ b/tests/cli/test_main_build.py @@ -197,17 +197,17 @@ def test_build_multiple_recipes(testing_metadata, testing_workdir, testing_confi main_build.execute(args) -def test_build_output_folder(testing_workdir, testing_metadata, tmp_path: Path): +def test_build_output_folder(testing_workdir: str, testing_metadata): api.output_yaml(testing_metadata, "meta.yaml") - out = tmp_path / "out" + out = Path(testing_workdir, "out") out.mkdir(parents=True) args = [ testing_workdir, "--no-build-id", "--croot", - str(tmp_path), + testing_workdir, "--no-activate", "--no-anaconda-upload", "--output-folder", @@ -219,18 +219,18 @@ def test_build_output_folder(testing_workdir, testing_metadata, tmp_path: Path): ).is_file() -def test_build_source(testing_workdir, tmp_path: Path): +def test_build_source(testing_workdir: str): args = [ os.path.join(metadata_dir, "_pyyaml_find_header"), "--source", "--no-build-id", "--croot", - str(tmp_path), + testing_workdir, "--no-activate", "--no-anaconda-upload", ] main_build.execute(args) - assert (tmp_path / "work" / "setup.py").is_file() + assert Path(testing_workdir, "work", "setup.py").is_file() @pytest.mark.serial diff --git a/tests/conftest.py b/tests/conftest.py index 3aca5b4bc7..87bad5a659 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,6 +10,7 @@ import pytest from conda.common.compat import on_mac, on_win +from pytest import MonkeyPatch import conda_build.config from conda_build.config import ( @@ -32,31 +33,25 @@ @pytest.fixture(scope="function") -def testing_workdir(tmpdir, request): +def testing_workdir(monkeypatch: MonkeyPatch, tmp_path: Path) -> Iterator[str]: """Create a workdir in a safe temporary folder; cd into dir above before test, cd out after :param tmpdir: py.test fixture, will be injected :param request: py.test fixture-related, will be injected (see pytest docs) """ + saved_path = Path.cwd() + monkeypatch.chdir(tmp_path) - saved_path = os.getcwd() - - tmpdir.chdir() # temporary folder for profiling output, if any - tmpdir.mkdir("prof") - - def return_to_saved_path(): - if os.path.isdir(os.path.join(saved_path, "prof")): - profdir = tmpdir.join("prof") - files = profdir.listdir("*.prof") if profdir.isdir() else [] - - for f in files: - copy_into(str(f), os.path.join(saved_path, "prof", f.basename)) - os.chdir(saved_path) + prof = tmp_path / "prof" + prof.mkdir(parents=True) - request.addfinalizer(return_to_saved_path) + yield str(tmp_path) - return str(tmpdir) + # if the original CWD has a prof folder, copy any new prof files into it + if (saved_path / "prof").is_dir() and prof.is_dir(): + for file in prof.glob("*.prof"): + copy_into(str(file), str(saved_path / "prof" / file.name)) @pytest.fixture(scope="function")