From 05cc56a7ea2a0fa6acbe882208ea35dad8add8f9 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 17 Nov 2023 19:06:16 +0100 Subject: [PATCH] CI adjustments for conda-libmamba-solver as default (#5059) Co-authored-by: Ken Odegard --- news/5059-ci-conda-libmamba-solver | 19 +++++++++ tests/cli/test_main_build.py | 64 +++++++++++++++--------------- tests/conftest.py | 27 +++++-------- tests/test_api_build.py | 4 ++ 4 files changed, 66 insertions(+), 48 deletions(-) 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) diff --git a/tests/cli/test_main_build.py b/tests/cli/test_main_build.py index 3f91d42d8c..e1ccd90d8c 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: str, testing_metadata): 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 = Path(testing_workdir, "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", + testing_workdir, + "--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: str): + args = [ + os.path.join(metadata_dir, "_pyyaml_find_header"), + "--source", + "--no-build-id", + "--croot", + testing_workdir, + "--no-activate", + "--no-anaconda-upload", + ] + main_build.execute(args) + assert Path(testing_workdir, "work", "setup.py").is_file() @pytest.mark.serial diff --git a/tests/conftest.py b/tests/conftest.py index 9da98ee1d4..9bb2c27616 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") diff --git a/tests/test_api_build.py b/tests/test_api_build.py index c3059f066d..7c379237a3 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -31,6 +31,7 @@ CondaError, LinkError, cc_conda_build, + context, 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