Skip to content

Commit

Permalink
test: test_package for .tar.bz2 and .conda
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <[email protected]>
  • Loading branch information
mbargull committed May 6, 2024
1 parent 6b605c0 commit 125a285
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion test/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
import sys
import subprocess as sp
import pytest
Expand All @@ -10,9 +11,10 @@
import tarfile
import logging
import shutil
from pathlib import Path
from textwrap import dedent

from conda_build import metadata
from conda_build import api, metadata

from bioconda_utils import __version__
from bioconda_utils import utils
Expand Down Expand Up @@ -1246,3 +1248,47 @@ def test_skip_unsatisfiable_pin_compatible(config_fixture):
)
assert build_result
assert len(utils.load_all_meta(r.recipe_dirs["two"])) == 1


@pytest.mark.parametrize('mulled_test', PARAMS, ids=IDS)
@pytest.mark.parametrize('pkg_format', ["1", "2"])
def test_pkg_test_conda_package_format(
config_fixture, recipes_fixture, mulled_test, pkg_format, monkeypatch, tmp_path
):
"""
Running a mulled-build test with .tar.bz2/.conda package formats
"""
condarc = Path(tmp_path, ".condarc")
condarc.write_text(f"conda_build:\n pkg_format: {pkg_format}\n")
monkeypatch.setenv("CONDARC", str(condarc))
docker_builder = None
if mulled_test:
# Override conda_build.pkg_format in build_script_template.
# ("1" is .tar.bz2 and "2" is .conda)
build_script_template = re.sub(
"^(conda config.*)",
f"conda config --set conda_build.pkg_format {pkg_format}\n\\1",
docker_utils.BUILD_SCRIPT_TEMPLATE,
count=1,
flags=re.M,
)
docker_builder = docker_utils.RecipeBuilder(
use_host_conda_bld=True,
docker_base_image=DOCKER_BASE_IMAGE,
build_script_template=build_script_template,
)
recipe = recipes_fixture.recipe_dirs['one']
build_result = build.build_recipes(
recipes_fixture.basedir,
config_fixture,
(recipe,),
docker_builder=docker_builder,
mulled_test=mulled_test,
)
assert build_result

config = load_conda_build_config()
config.conda_package_format = pkg_format
for pkg in api.get_output_file_paths(recipe, config=config, bypass_env_check=True):
assert pkg.endswith({"1": ".tar.bz2", "2": ".conda"}[pkg_format])
assert os.path.exists(pkg)

0 comments on commit 125a285

Please sign in to comment.