Skip to content

Commit

Permalink
Add virtual package-related solver tests
Browse files Browse the repository at this point in the history
Starting work on improving/fixing solver messaging and logic
  • Loading branch information
chenghlee committed Oct 11, 2020
1 parent 64269c6 commit 6bf40f2
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 1 deletion.
103 changes: 102 additions & 1 deletion tests/core/test_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from conda._vendor.auxlib.ish import dals
from conda.base.context import context, Context, reset_context, conda_tests_ctxt_mgmt_def_pol
from conda.common.compat import on_linux
from conda.common.io import env_var, env_vars, stderr_log_level, captured
from conda.core.prefix_data import PrefixData
from conda.core.solve import DepsModifier, Solver, UpdateModifier, Resolve
Expand Down Expand Up @@ -257,6 +258,18 @@ def test_virtual_package_solver(tmpdir):
assert ssc.r.bad_installed(ssc.solution_precs, ())[1] is None


def test_solve_msgs_exclude_vp(tmpdir):
# Sovler hints should exclude virtual packages that are not dependencies
specs = MatchSpec("python =2.7.5"), MatchSpec("readline =7.0"),

with env_var('CONDA_OVERRIDE_CUDA', '10.0'):
with get_solver_cuda(tmpdir, specs) as solver:
with pytest.raises(UnsatisfiableError) as exc:
final_state = solver.solve_final_state()

assert "__cuda==10.0" not in str(exc.value).strip()


def test_cuda_1(tmpdir):
specs = MatchSpec("cudatoolkit"),

Expand Down Expand Up @@ -312,7 +325,6 @@ def test_cuda_fail_1(tmpdir):
Your installed version is: 8.0""".format(plat))



def test_cuda_fail_2(tmpdir):
specs = MatchSpec("cudatoolkit"),

Expand All @@ -328,6 +340,95 @@ def test_cuda_fail_2(tmpdir):
Your installed version is: not available""")


def test_cuda_constrain_absent(tmpdir):
specs = MatchSpec("cuda-constrain"),

with env_var('CONDA_OVERRIDE_CUDA', ''):
with get_solver_cuda(tmpdir, specs) as solver:
final_state = solver.solve_final_state()
# print(convert_to_dist_str(final_state))
order = add_subdir_to_iter((
'channel-1::cuda-constrain-11.0-0',
))
assert convert_to_dist_str(final_state) == order


@pytest.mark.skip(reason="known broken; fix to be implemented")
def test_cuda_constrain_sat(tmpdir):
specs = MatchSpec("cuda-constrain"),

with env_var('CONDA_OVERRIDE_CUDA', '10.0'):
with get_solver_cuda(tmpdir, specs) as solver:
final_state = solver.solve_final_state()
# print(convert_to_dist_str(final_state))
order = add_subdir_to_iter((
'channel-1::cuda-constrain-10.0-0',
))
assert convert_to_dist_str(final_state) == order


@pytest.mark.skip(reason="known broken; fix to be implemented")
def test_cuda_constrain_unsat(tmpdir):
specs = MatchSpec("cuda-constrain"),

# No cudatoolkit in index for CUDA 8.0
with env_var('CONDA_OVERRIDE_CUDA', '8.0'):
with get_solver_cuda(tmpdir, specs) as solver:
with pytest.raises(UnsatisfiableError) as exc:
final_state = solver.solve_final_state()

assert str(exc.value).strip() == dals("""The following specifications were found to be incompatible with your system:
- feature:|@/{}::__cuda==8.0=0
- __cuda[version='>=10.0'] -> feature:/linux-64::__cuda==8.0=0
Your installed version is: 8.0""".format(context.subdir))


@pytest.mark.skipif(not on_linux, reason="linux-only test")
def test_cuda_glibc_sat(tmpdir):
specs = MatchSpec("cuda-glibc"),

with env_var('CONDA_OVERRIDE_CUDA', '10.0'), env_var('CONDA_OVERRIDE_GLIBC', '2.23'):
with get_solver_cuda(tmpdir, specs) as solver:
final_state = solver.solve_final_state()
# print(convert_to_dist_str(final_state))
order = add_subdir_to_iter((
'channel-1::cuda-glibc-10.0-0',
))
assert convert_to_dist_str(final_state) == order


@pytest.mark.skip(reason="known broken; fix to be implemented")
@pytest.mark.skipif(not on_linux, reason="linux-only test")
def test_cuda_glibc_unsat_depend(tmpdir):
specs = MatchSpec("cuda-glibc"),

with env_var('CONDA_OVERRIDE_CUDA', '8.0'), env_var('CONDA_OVERRIDE_GLIBC', '2.23'):
with get_solver_cuda(tmpdir, specs) as solver:
with pytest.raises(UnsatisfiableError) as exc:
final_state = solver.solve_final_state()

assert str(exc.value).strip() == dals("""The following specifications were found to be incompatible with your system:
- feature:|@/{}::__cuda==8.0=0
- __cuda[version='>=10.0'] -> feature:/linux-64::__cuda==8.0=0
Your installed version is: 8.0""".format(context.subdir))


@pytest.mark.skip(reason="known broken; fix to be implemented")
@pytest.mark.skipif(not on_linux, reason="linux-only test")
def test_cuda_glibc_unsat_constrain(tmpdir):
specs = MatchSpec("cuda-glibc"),

with env_var('CONDA_OVERRIDE_CUDA', '10.0'), env_var('CONDA_OVERRIDE_GLIBC', '2.12'):
with get_solver_cuda(tmpdir, specs) as solver:
with pytest.raises(UnsatisfiableError) as exc:
final_state = solver.solve_final_state()


def test_prune_1(tmpdir):
specs = MatchSpec("numpy=1.6"), MatchSpec("python=2.7.3"), MatchSpec("accelerate"),

Expand Down
48 changes: 48 additions & 0 deletions tests/data/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -16769,6 +16769,15 @@
"requires": [],
"version": "6.2"
},
"readline-7.0-0.tar.bz2": {
"build": "0",
"build_number": 0,
"depends": [],
"md5": "7802f80168494982f4f72fff244f72d5",
"name": "readline",
"requires": [],
"version": "7.0"
},
"redis-2.4.15-0.tar.bz2": {
"build": "0",
"build_number": 0,
Expand Down Expand Up @@ -20972,6 +20981,45 @@
],
"version": "4.1.1.1"
},
"cuda-glibc-10.0-0.tar.bz2": {
"build": "0",
"build_number": 0,
"constrains": [
"__glibc>=2.17"
],
"depends": [
"__cuda>=10.0,<11"
],
"md5": "57833caff02605fb87946d8758c6cc99",
"name": "cuda-glibc",
"pub_date": "2020-09-08",
"size": 1,
"version": "10.0"
},
"cuda-constrain-10.0-0.tar.bz2": {
"build": "0",
"build_number": 0,
"constrains": [
"__cuda>=10.0,<11"
],
"md5": "3c83ba17a3bb9de3e4f13e62a909fb7e",
"name": "cuda-constrain",
"pub_date": "2020-09-01",
"size": 1,
"version": "10.0"
},
"cuda-constrain-11.0-0.tar.bz2": {
"build": "0",
"build_number": 0,
"constrains": [
"__cuda>=11.0,<12"
],
"md5": "8ef4b9b28da3c107676450ff0461deb3",
"name": "cuda-constrain",
"pub_date": "2020-09-01",
"size": 1,
"version": "11.0"
},
"cudatoolkit-9.0-0.tar.bz2": {
"build": "0",
"build_number": 0,
Expand Down

0 comments on commit 6bf40f2

Please sign in to comment.