Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start using inline-snapshot #1997

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies:
- mock
- pytest
- pytest-cov
- inline-snapshot
# Runtime dependencies
- conda >=4.2
- conda-build >=24.3
Expand Down
107 changes: 89 additions & 18 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pytest
import yaml
from inline_snapshot import snapshot

from conda_smithy import cli

Expand Down Expand Up @@ -50,7 +51,7 @@ def test_init(py_recipe):
assert os.path.isdir(destination)


def test_init_with_custom_config(py_recipe):
def test_init_with_custom_config(py_recipe, request):
"""This is the command that takes the initial staged-recipe folder and turns it into a
feedstock"""
# actual parser doesn't matter. It's used for initialization only
Expand All @@ -59,7 +60,6 @@ def test_init_with_custom_config(py_recipe):
init_obj = cli.Init(subparser)
recipe = py_recipe.recipe
# expected args object has

with open(os.path.join(recipe, "recipe", "conda-forge.yml"), "w") as fp:
fp.write(
dedent(
Expand All @@ -82,9 +82,18 @@ def test_init_with_custom_config(py_recipe):
data = yaml.safe_load(
open(os.path.join(destination, "conda-forge.yml")).read()
)
assert data.get("bot") is not None
assert data["bot"]["automerge"] is True
assert data["bot"]["run_deps_from_wheel"] is True

if data.get("conda_build_tool") == "rattler-build":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about using "rattler-build" value from conda_smithy.utils module?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

assert data == snapshot(
{
"conda_build_tool": "rattler-build",
"bot": {"automerge": True, "run_deps_from_wheel": True},
}
)
else:
assert data == snapshot(
{"bot": {"automerge": True, "run_deps_from_wheel": True}}
)


def test_init_multiple_output_matrix(testing_workdir):
Expand Down Expand Up @@ -234,24 +243,80 @@ def test_init_cuda_docker_images(testing_workdir):
# configs.
matrix_dir_len = len(os.listdir(matrix_dir))
assert matrix_dir_len == 7 # 6 docker images plus the README
result = {}
for v in [None, "9.2", "10.0", "10.1", "10.2", "11.0"]:
fn = os.path.join(
matrix_dir, f"linux_64_cuda_compiler_version{v}.yaml"
)
assert os.path.isfile(fn)
with open(fn) as fh:
config = yaml.safe_load(fh)
assert config["cuda_compiler"] == ["nvcc"]
assert config["cuda_compiler_version"] == [f"{v}"]
if v is None:
docker_image = "condaforge/linux-anvil-comp7"
else:
docker_image = f"condaforge/linux-anvil-cuda:{v}"
assert config["docker_image"] == [docker_image]
if v == "11.0":
assert config["cdt_name"] == ["cos7"]
else:
assert config["cdt_name"] == ["cos6"]
result[v] = config

assert result == snapshot(
{
None: {
"cdt_name": ["cos6"],
"cuda_compiler": ["nvcc"],
"cuda_compiler_version": ["None"],
"docker_image": ["condaforge/linux-anvil-comp7"],
"target_platform": ["linux-64"],
"zip_keys": [
["cdt_name", "cuda_compiler_version", "docker_image"]
],
},
"9.2": {
"cdt_name": ["cos6"],
"cuda_compiler": ["nvcc"],
"cuda_compiler_version": ["9.2"],
"docker_image": ["condaforge/linux-anvil-cuda:9.2"],
"target_platform": ["linux-64"],
"zip_keys": [
["cdt_name", "cuda_compiler_version", "docker_image"]
],
},
"10.0": {
"cdt_name": ["cos6"],
"cuda_compiler": ["nvcc"],
"cuda_compiler_version": ["10.0"],
"docker_image": ["condaforge/linux-anvil-cuda:10.0"],
"target_platform": ["linux-64"],
"zip_keys": [
["cdt_name", "cuda_compiler_version", "docker_image"]
],
},
"10.1": {
"cdt_name": ["cos6"],
"cuda_compiler": ["nvcc"],
"cuda_compiler_version": ["10.1"],
"docker_image": ["condaforge/linux-anvil-cuda:10.1"],
"target_platform": ["linux-64"],
"zip_keys": [
["cdt_name", "cuda_compiler_version", "docker_image"]
],
},
"10.2": {
"cdt_name": ["cos6"],
"cuda_compiler": ["nvcc"],
"cuda_compiler_version": ["10.2"],
"docker_image": ["condaforge/linux-anvil-cuda:10.2"],
"target_platform": ["linux-64"],
"zip_keys": [
["cdt_name", "cuda_compiler_version", "docker_image"]
],
},
"11.0": {
"cdt_name": ["cos7"],
"cuda_compiler": ["nvcc"],
"cuda_compiler_version": ["11.0"],
"docker_image": ["condaforge/linux-anvil-cuda:11.0"],
"target_platform": ["linux-64"],
"zip_keys": [
["cdt_name", "cuda_compiler_version", "docker_image"]
],
},
}
)


def test_init_multiple_docker_images(testing_workdir):
Expand Down Expand Up @@ -292,8 +357,14 @@ def test_init_multiple_docker_images(testing_workdir):
assert os.path.isfile(fn)
with open(fn) as fh:
config = yaml.safe_load(fh)
assert config["docker_image"] == ["pickme_a"]
assert config["cdt_name"] == ["pickme_1"]
assert config == snapshot(
{
"cdt_name": ["pickme_1"],
"docker_image": ["pickme_a"],
"target_platform": ["linux-64"],
"zip_keys": [["docker_image", "cdt_name"]],
}
)


def test_regenerate(py_recipe, testing_workdir):
Expand Down
Loading