Add pkg- prefix to builtin.mock a b c d ... (#45205)

This commit is contained in:
Harmen Stoppels 2024-07-12 11:27:40 +02:00 committed by Harmen Stoppels
parent d2096e8fc1
commit ed816d3f0c
49 changed files with 519 additions and 484 deletions

View file

@ -216,10 +216,12 @@ def test_satisfy_strict_constraint_when_not_concrete(architecture_tuple, constra
str(archspec.cpu.host().family) != "x86_64", reason="tests are for x86_64 uarch ranges"
)
def test_concretize_target_ranges(root_target_range, dep_target_range, result, monkeypatch):
spec = Spec(f"a %gcc@10 foobar=bar target={root_target_range} ^b target={dep_target_range}")
spec = Spec(
f"pkg-a %gcc@10 foobar=bar target={root_target_range} ^pkg-b target={dep_target_range}"
)
with spack.concretize.disable_compiler_existence_check():
spec.concretize()
assert spec.target == spec["b"].target == result
assert spec.target == spec["pkg-b"].target == result
@pytest.mark.parametrize(

View file

@ -437,14 +437,14 @@ def test_parallel_false_is_not_propagating(default_mock_concretization):
# a foobar=bar (parallel = False)
# |
# b (parallel =True)
s = default_mock_concretization("a foobar=bar")
s = default_mock_concretization("pkg-a foobar=bar")
spack.build_environment.set_package_py_globals(s.package)
assert s["a"].package.module.make_jobs == 1
assert s["pkg-a"].package.module.make_jobs == 1
spack.build_environment.set_package_py_globals(s["b"].package)
assert s["b"].package.module.make_jobs == spack.build_environment.determine_number_of_jobs(
parallel=s["b"].package.parallel
spack.build_environment.set_package_py_globals(s["pkg-b"].package)
assert s["pkg-b"].package.module.make_jobs == spack.build_environment.determine_number_of_jobs(
parallel=s["pkg-b"].package.parallel
)
@ -540,7 +540,7 @@ def test_dirty_disable_module_unload(config, mock_packages, working_env, mock_mo
"""Test that on CRAY platform 'module unload' is not called if the 'dirty'
option is on.
"""
s = spack.spec.Spec("a").concretized()
s = spack.spec.Spec("pkg-a").concretized()
# If called with "dirty" we don't unload modules, so no calls to the
# `module` function on Cray

View file

@ -97,7 +97,7 @@ def test_negative_ninja_check(self, input_dir, test_dir, concretize_and_setup):
@pytest.mark.usefixtures("config", "mock_packages")
class TestAutotoolsPackage:
def test_with_or_without(self, default_mock_concretization):
s = default_mock_concretization("a")
s = default_mock_concretization("pkg-a")
options = s.package.with_or_without("foo")
# Ensure that values that are not representing a feature
@ -129,7 +129,7 @@ def activate(value):
assert "--without-lorem-ipsum" in options
def test_none_is_allowed(self, default_mock_concretization):
s = default_mock_concretization("a foo=none")
s = default_mock_concretization("pkg-a foo=none")
options = s.package.with_or_without("foo")
# Ensure that values that are not representing a feature

View file

@ -102,24 +102,24 @@ def test_specs_staging(config, tmpdir):
"""
builder = repo.MockRepositoryBuilder(tmpdir)
builder.add_package("g")
builder.add_package("f")
builder.add_package("e")
builder.add_package("d", dependencies=[("f", None, None), ("g", None, None)])
builder.add_package("c")
builder.add_package("b", dependencies=[("d", None, None), ("e", None, None)])
builder.add_package("a", dependencies=[("b", None, None), ("c", None, None)])
builder.add_package("pkg-g")
builder.add_package("pkg-f")
builder.add_package("pkg-e")
builder.add_package("pkg-d", dependencies=[("pkg-f", None, None), ("pkg-g", None, None)])
builder.add_package("pkg-c")
builder.add_package("pkg-b", dependencies=[("pkg-d", None, None), ("pkg-e", None, None)])
builder.add_package("pkg-a", dependencies=[("pkg-b", None, None), ("pkg-c", None, None)])
with repo.use_repositories(builder.root):
spec_a = Spec("a").concretized()
spec_a = Spec("pkg-a").concretized()
spec_a_label = ci._spec_deps_key(spec_a)
spec_b_label = ci._spec_deps_key(spec_a["b"])
spec_c_label = ci._spec_deps_key(spec_a["c"])
spec_d_label = ci._spec_deps_key(spec_a["d"])
spec_e_label = ci._spec_deps_key(spec_a["e"])
spec_f_label = ci._spec_deps_key(spec_a["f"])
spec_g_label = ci._spec_deps_key(spec_a["g"])
spec_b_label = ci._spec_deps_key(spec_a["pkg-b"])
spec_c_label = ci._spec_deps_key(spec_a["pkg-c"])
spec_d_label = ci._spec_deps_key(spec_a["pkg-d"])
spec_e_label = ci._spec_deps_key(spec_a["pkg-e"])
spec_f_label = ci._spec_deps_key(spec_a["pkg-f"])
spec_g_label = ci._spec_deps_key(spec_a["pkg-g"])
spec_labels, dependencies, stages = ci.stage_spec_jobs([spec_a])
@ -1256,7 +1256,7 @@ def test_ci_generate_override_runner_attrs(
spack:
specs:
- flatten-deps
- a
- pkg-a
mirrors:
some-mirror: https://my.fake.mirror
ci:
@ -1273,12 +1273,12 @@ def test_ci_generate_override_runner_attrs(
- match:
- dependency-install
- match:
- a
- pkg-a
build-job:
tags:
- specific-a-2
- match:
- a
- pkg-a
build-job-remove:
tags:
- toplevel2
@ -1338,8 +1338,8 @@ def test_ci_generate_override_runner_attrs(
assert global_vars["SPACK_CHECKOUT_VERSION"] == git_version or "v0.20.0.test0"
for ci_key in yaml_contents.keys():
if ci_key.startswith("a"):
# Make sure a's attributes override variables, and all the
if ci_key.startswith("pkg-a"):
# Make sure pkg-a's attributes override variables, and all the
# scripts. Also, make sure the 'toplevel' tag doesn't
# appear twice, but that a's specific extra tag does appear
the_elt = yaml_contents[ci_key]
@ -1798,7 +1798,7 @@ def test_ci_generate_read_broken_specs_url(
tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, ci_base_environment
):
"""Verify that `broken-specs-url` works as intended"""
spec_a = Spec("a")
spec_a = Spec("pkg-a")
spec_a.concretize()
a_dag_hash = spec_a.dag_hash()
@ -1824,7 +1824,7 @@ def test_ci_generate_read_broken_specs_url(
spack:
specs:
- flatten-deps
- a
- pkg-a
mirrors:
some-mirror: https://my.fake.mirror
ci:
@ -1832,9 +1832,9 @@ def test_ci_generate_read_broken_specs_url(
pipeline-gen:
- submapping:
- match:
- a
- pkg-a
- flatten-deps
- b
- pkg-b
- dependency-install
build-job:
tags:

View file

@ -81,14 +81,14 @@ def test_match_spec_env(mock_packages, mutable_mock_env_path):
"""
# Initial sanity check: we are planning on choosing a non-default
# value, so make sure that is in fact not the default.
check_defaults = spack.cmd.parse_specs(["a"], concretize=True)[0]
check_defaults = spack.cmd.parse_specs(["pkg-a"], concretize=True)[0]
assert not check_defaults.satisfies("foobar=baz")
e = ev.create("test")
e.add("a foobar=baz")
e.add("pkg-a foobar=baz")
e.concretize()
with e:
env_spec = spack.cmd.matching_spec_from_env(spack.cmd.parse_specs(["a"])[0])
env_spec = spack.cmd.matching_spec_from_env(spack.cmd.parse_specs(["pkg-a"])[0])
assert env_spec.satisfies("foobar=baz")
assert env_spec.concrete
@ -96,12 +96,12 @@ def test_match_spec_env(mock_packages, mutable_mock_env_path):
@pytest.mark.usefixtures("config")
def test_multiple_env_match_raises_error(mock_packages, mutable_mock_env_path):
e = ev.create("test")
e.add("a foobar=baz")
e.add("a foobar=fee")
e.add("pkg-a foobar=baz")
e.add("pkg-a foobar=fee")
e.concretize()
with e:
with pytest.raises(ev.SpackEnvironmentError) as exc_info:
spack.cmd.matching_spec_from_env(spack.cmd.parse_specs(["a"])[0])
spack.cmd.matching_spec_from_env(spack.cmd.parse_specs(["pkg-a"])[0])
assert "matches multiple specs" in exc_info.value.message
@ -109,16 +109,16 @@ def test_multiple_env_match_raises_error(mock_packages, mutable_mock_env_path):
@pytest.mark.usefixtures("config")
def test_root_and_dep_match_returns_root(mock_packages, mutable_mock_env_path):
e = ev.create("test")
e.add("b@0.9")
e.add("a foobar=bar") # Depends on b, should choose b@1.0
e.add("pkg-b@0.9")
e.add("pkg-a foobar=bar") # Depends on b, should choose b@1.0
e.concretize()
with e:
# This query matches the root b and b as a dependency of a. In that
# case the root instance should be preferred.
env_spec1 = spack.cmd.matching_spec_from_env(spack.cmd.parse_specs(["b"])[0])
env_spec1 = spack.cmd.matching_spec_from_env(spack.cmd.parse_specs(["pkg-b"])[0])
assert env_spec1.satisfies("@0.9")
env_spec2 = spack.cmd.matching_spec_from_env(spack.cmd.parse_specs(["b@1.0"])[0])
env_spec2 = spack.cmd.matching_spec_from_env(spack.cmd.parse_specs(["pkg-b@1.0"])[0])
assert env_spec2

View file

@ -51,8 +51,8 @@ def test_concretize_root_test_dependencies_are_concretized(unify, mutable_mock_e
with ev.read("test") as e:
e.unify = unify
add("a")
add("b")
add("pkg-a")
add("pkg-b")
concretize("--test", "root")
assert e.matching_spec("test-dependency")

View file

@ -15,26 +15,26 @@
def test_env(mutable_mock_env_path, config, mock_packages):
ev.create("test")
with ev.read("test") as e:
e.add("a@2.0 foobar=bar ^b@1.0")
e.add("a@1.0 foobar=bar ^b@0.9")
e.add("pkg-a@2.0 foobar=bar ^pkg-b@1.0")
e.add("pkg-a@1.0 foobar=bar ^pkg-b@0.9")
e.concretize()
e.write()
def test_deconcretize_dep(test_env):
with ev.read("test") as e:
deconcretize("-y", "b@1.0")
deconcretize("-y", "pkg-b@1.0")
specs = [s for s, _ in e.concretized_specs()]
assert len(specs) == 1
assert specs[0].satisfies("a@1.0")
assert specs[0].satisfies("pkg-a@1.0")
def test_deconcretize_all_dep(test_env):
with ev.read("test") as e:
with pytest.raises(SpackCommandError):
deconcretize("-y", "b")
deconcretize("-y", "--all", "b")
deconcretize("-y", "pkg-b")
deconcretize("-y", "--all", "pkg-b")
specs = [s for s, _ in e.concretized_specs()]
assert len(specs) == 0
@ -42,27 +42,27 @@ def test_deconcretize_all_dep(test_env):
def test_deconcretize_root(test_env):
with ev.read("test") as e:
output = deconcretize("-y", "--root", "b@1.0")
output = deconcretize("-y", "--root", "pkg-b@1.0")
assert "No matching specs to deconcretize" in output
assert len(e.concretized_order) == 2
deconcretize("-y", "--root", "a@2.0")
deconcretize("-y", "--root", "pkg-a@2.0")
specs = [s for s, _ in e.concretized_specs()]
assert len(specs) == 1
assert specs[0].satisfies("a@1.0")
assert specs[0].satisfies("pkg-a@1.0")
def test_deconcretize_all_root(test_env):
with ev.read("test") as e:
with pytest.raises(SpackCommandError):
deconcretize("-y", "--root", "a")
deconcretize("-y", "--root", "pkg-a")
output = deconcretize("-y", "--root", "--all", "b")
output = deconcretize("-y", "--root", "--all", "pkg-b")
assert "No matching specs to deconcretize" in output
assert len(e.concretized_order) == 2
deconcretize("-y", "--root", "--all", "a")
deconcretize("-y", "--root", "--all", "pkg-a")
specs = [s for s, _ in e.concretized_specs()]
assert len(specs) == 0

View file

@ -27,7 +27,9 @@
import spack.package_base
import spack.paths
import spack.repo
import spack.store
import spack.util.spack_json as sjson
import spack.util.spack_yaml
from spack.cmd.env import _env_create
from spack.main import SpackCommand, SpackCommandError
from spack.spec import Spec
@ -346,7 +348,7 @@ def test_env_install_two_specs_same_dep(install_mockery, mock_fetch, tmpdir, cap
"""\
spack:
specs:
- a
- pkg-a
- depb
"""
)
@ -365,8 +367,8 @@ def test_env_install_two_specs_same_dep(install_mockery, mock_fetch, tmpdir, cap
depb = spack.store.STORE.db.query_one("depb", installed=True)
assert depb, "Expected depb to be installed"
a = spack.store.STORE.db.query_one("a", installed=True)
assert a, "Expected a to be installed"
a = spack.store.STORE.db.query_one("pkg-a", installed=True)
assert a, "Expected pkg-a to be installed"
def test_remove_after_concretize():
@ -635,7 +637,7 @@ def test_env_view_external_prefix(tmp_path, mutable_database, mock_packages):
"""\
spack:
specs:
- a
- pkg-a
view: true
"""
)
@ -643,9 +645,9 @@ def test_env_view_external_prefix(tmp_path, mutable_database, mock_packages):
external_config = io.StringIO(
"""\
packages:
a:
pkg-a:
externals:
- spec: a@2.0
- spec: pkg-a@2.0
prefix: {a_prefix}
buildable: false
""".format(

View file

@ -88,7 +88,7 @@ def check(pkg):
assert pkg.run_tests
monkeypatch.setattr(spack.package_base.PackageBase, "unit_test_check", check)
install("--test=all", "a")
install("--test=all", "pkg-a")
def test_install_package_already_installed(
@ -570,12 +570,11 @@ def test_cdash_upload_build_error(tmpdir, mock_fetch, install_mockery, capfd):
@pytest.mark.disable_clean_stage_check
def test_cdash_upload_clean_build(tmpdir, mock_fetch, install_mockery, capfd):
# capfd interferes with Spack's capturing of e.g., Build.xml output
with capfd.disabled():
with tmpdir.as_cwd():
install("--log-file=cdash_reports", "--log-format=cdash", "a")
with capfd.disabled(), tmpdir.as_cwd():
install("--log-file=cdash_reports", "--log-format=cdash", "pkg-a")
report_dir = tmpdir.join("cdash_reports")
assert report_dir in tmpdir.listdir()
report_file = report_dir.join("a_Build.xml")
report_file = report_dir.join("pkg-a_Build.xml")
assert report_file in report_dir.listdir()
content = report_file.open().read()
assert "</Build>" in content
@ -585,22 +584,21 @@ def test_cdash_upload_clean_build(tmpdir, mock_fetch, install_mockery, capfd):
@pytest.mark.disable_clean_stage_check
def test_cdash_upload_extra_params(tmpdir, mock_fetch, install_mockery, capfd):
# capfd interferes with Spack's capture of e.g., Build.xml output
with capfd.disabled():
with tmpdir.as_cwd():
with capfd.disabled(), tmpdir.as_cwd():
install(
"--log-file=cdash_reports",
"--log-format=cdash",
"--cdash-build=my_custom_build",
"--cdash-site=my_custom_site",
"--cdash-track=my_custom_track",
"a",
"pkg-a",
)
report_dir = tmpdir.join("cdash_reports")
assert report_dir in tmpdir.listdir()
report_file = report_dir.join("a_Build.xml")
report_file = report_dir.join("pkg-a_Build.xml")
assert report_file in report_dir.listdir()
content = report_file.open().read()
assert 'Site BuildName="my_custom_build - a"' in content
assert 'Site BuildName="my_custom_build - pkg-a"' in content
assert 'Name="my_custom_site"' in content
assert "-my_custom_track" in content
@ -608,8 +606,7 @@ def test_cdash_upload_extra_params(tmpdir, mock_fetch, install_mockery, capfd):
@pytest.mark.disable_clean_stage_check
def test_cdash_buildstamp_param(tmpdir, mock_fetch, install_mockery, capfd):
# capfd interferes with Spack's capture of e.g., Build.xml output
with capfd.disabled():
with tmpdir.as_cwd():
with capfd.disabled(), tmpdir.as_cwd():
cdash_track = "some_mocked_track"
buildstamp_format = "%Y%m%d-%H%M-{0}".format(cdash_track)
buildstamp = time.strftime(buildstamp_format, time.localtime(int(time.time())))
@ -617,11 +614,11 @@ def test_cdash_buildstamp_param(tmpdir, mock_fetch, install_mockery, capfd):
"--log-file=cdash_reports",
"--log-format=cdash",
"--cdash-buildstamp={0}".format(buildstamp),
"a",
"pkg-a",
)
report_dir = tmpdir.join("cdash_reports")
assert report_dir in tmpdir.listdir()
report_file = report_dir.join("a_Build.xml")
report_file = report_dir.join("pkg-a_Build.xml")
assert report_file in report_dir.listdir()
content = report_file.open().read()
assert buildstamp in content
@ -632,11 +629,10 @@ def test_cdash_install_from_spec_json(
tmpdir, mock_fetch, install_mockery, capfd, mock_packages, mock_archive, config
):
# capfd interferes with Spack's capturing
with capfd.disabled():
with tmpdir.as_cwd():
with capfd.disabled(), tmpdir.as_cwd():
spec_json_path = str(tmpdir.join("spec.json"))
pkg_spec = Spec("a")
pkg_spec = Spec("pkg-a")
pkg_spec.concretize()
with open(spec_json_path, "w") as fd:
@ -654,7 +650,7 @@ def test_cdash_install_from_spec_json(
report_dir = tmpdir.join("cdash_reports")
assert report_dir in tmpdir.listdir()
report_file = report_dir.join("a_Configure.xml")
report_file = report_dir.join("pkg-a_Configure.xml")
assert report_file in report_dir.listdir()
content = report_file.open().read()
install_command_regex = re.compile(
@ -663,7 +659,7 @@ def test_cdash_install_from_spec_json(
m = install_command_regex.search(content)
assert m
install_command = m.group(1)
assert "a@" in install_command
assert "pkg-a@" in install_command
@pytest.mark.disable_clean_stage_check
@ -795,15 +791,15 @@ def test_install_no_add_in_env(tmpdir, mock_fetch, install_mockery, mutable_mock
# ^libdwarf
# ^mpich
# libelf@0.8.10
# a~bvv
# ^b
# a
# ^b
# pkg-a~bvv
# ^pkg-b
# pkg-a
# ^pkg-b
e = ev.create("test", with_view=False)
e.add("mpileaks")
e.add("libelf@0.8.10") # so env has both root and dep libelf specs
e.add("a")
e.add("a ~bvv")
e.add("pkg-a")
e.add("pkg-a ~bvv")
e.concretize()
e.write()
env_specs = e.all_specs()
@ -814,9 +810,9 @@ def test_install_no_add_in_env(tmpdir, mock_fetch, install_mockery, mutable_mock
# First find and remember some target concrete specs in the environment
for e_spec in env_specs:
if e_spec.satisfies(Spec("a ~bvv")):
if e_spec.satisfies(Spec("pkg-a ~bvv")):
a_spec = e_spec
elif e_spec.name == "b":
elif e_spec.name == "pkg-b":
b_spec = e_spec
elif e_spec.satisfies(Spec("mpi")):
mpi_spec = e_spec
@ -839,8 +835,8 @@ def test_install_no_add_in_env(tmpdir, mock_fetch, install_mockery, mutable_mock
assert "You can add specs to the environment with 'spack add " in inst_out
# Without --add, ensure that two packages "a" get installed
inst_out = install("a", output=str)
assert len([x for x in e.all_specs() if x.installed and x.name == "a"]) == 2
inst_out = install("pkg-a", output=str)
assert len([x for x in e.all_specs() if x.installed and x.name == "pkg-a"]) == 2
# Install an unambiguous dependency spec (that already exists as a dep
# in the environment) and make sure it gets installed (w/ deps),
@ -873,7 +869,7 @@ def test_install_no_add_in_env(tmpdir, mock_fetch, install_mockery, mutable_mock
# root of the environment as well as installed.
assert b_spec not in e.roots()
install("--add", "b")
install("--add", "pkg-b")
assert b_spec in e.roots()
assert b_spec not in e.uninstalled_specs()
@ -908,7 +904,7 @@ def test_cdash_auth_token(tmpdir, mock_fetch, install_mockery, monkeypatch, capf
# capfd interferes with Spack's capturing
with tmpdir.as_cwd(), capfd.disabled():
monkeypatch.setenv("SPACK_CDASH_AUTH_TOKEN", "asdf")
out = install("-v", "--log-file=cdash_reports", "--log-format=cdash", "a")
out = install("-v", "--log-file=cdash_reports", "--log-format=cdash", "pkg-a")
assert "Using CDash auth token from environment" in out
@ -916,13 +912,12 @@ def test_cdash_auth_token(tmpdir, mock_fetch, install_mockery, monkeypatch, capf
@pytest.mark.disable_clean_stage_check
def test_cdash_configure_warning(tmpdir, mock_fetch, install_mockery, capfd):
# capfd interferes with Spack's capturing of e.g., Build.xml output
with capfd.disabled():
with tmpdir.as_cwd():
with capfd.disabled(), tmpdir.as_cwd():
# Test would fail if install raised an error.
# Ensure that even on non-x86_64 architectures, there are no
# dependencies installed
spec = spack.spec.Spec("configure-warning").concretized()
spec = Spec("configure-warning").concretized()
spec.clear_dependencies()
specfile = "./spec.json"
with open(specfile, "w") as f:
@ -952,7 +947,7 @@ def test_compiler_bootstrap(
assert CompilerSpec("gcc@=12.0") not in compilers.all_compiler_specs()
# Test succeeds if it does not raise an error
install("a%gcc@=12.0")
install("pkg-a%gcc@=12.0")
@pytest.mark.not_on_windows("Binary mirrors not supported on windows")
@ -992,8 +987,8 @@ def test_compiler_bootstrap_from_binary_mirror(
# Now make sure that when the compiler is installed from binary mirror,
# it also gets configured as a compiler. Test succeeds if it does not
# raise an error
install("--no-check-signature", "--cache-only", "--only", "dependencies", "b%gcc@=10.2.0")
install("--no-cache", "--only", "package", "b%gcc@10.2.0")
install("--no-check-signature", "--cache-only", "--only", "dependencies", "pkg-b%gcc@=10.2.0")
install("--no-cache", "--only", "package", "pkg-b%gcc@10.2.0")
@pytest.mark.not_on_windows("ArchSpec gives test platform debian rather than windows")
@ -1013,7 +1008,7 @@ def test_compiler_bootstrap_already_installed(
# Test succeeds if it does not raise an error
install("gcc@=12.0")
install("a%gcc@=12.0")
install("pkg-a%gcc@=12.0")
def test_install_fails_no_args(tmpdir):
@ -1195,7 +1190,7 @@ def test_report_filename_for_cdash(install_mockery_mutable_config, mock_fetch):
parser = argparse.ArgumentParser()
spack.cmd.install.setup_parser(parser)
args = parser.parse_args(
["--cdash-upload-url", "https://blahblah/submit.php?project=debugging", "a"]
["--cdash-upload-url", "https://blahblah/submit.php?project=debugging", "pkg-a"]
)
specs = spack.cmd.install.concrete_specs_from_cli(args, {})
filename = spack.cmd.install.report_filename(args, specs)

View file

@ -133,7 +133,7 @@ def test_maintainers_list_packages(mock_packages, capfd):
def test_maintainers_list_fails(mock_packages, capfd):
out = maintainers("a", fail_on_error=False)
out = maintainers("pkg-a", fail_on_error=False)
assert not out
assert maintainers.returncode == 1

View file

@ -11,6 +11,7 @@
import spack.config
import spack.main
import spack.modules
import spack.spec
import spack.store
module = spack.main.SpackCommand("module")
@ -178,8 +179,8 @@ def test_setdefault_command(mutable_database, mutable_config):
}
}
spack.config.set("modules", data)
# Install two different versions of a package
other_spec, preferred = "a@1.0", "a@2.0"
# Install two different versions of pkg-a
other_spec, preferred = "pkg-a@1.0", "pkg-a@2.0"
spack.spec.Spec(other_spec).concretized().package.do_install(fake=True)
spack.spec.Spec(preferred).concretized().package.do_install(fake=True)

View file

@ -28,8 +28,8 @@ def install(self, spec, prefix):
pass
"""
abc = set(("pkg-a", "pkg-b", "pkg-c"))
abd = set(("pkg-a", "pkg-b", "pkg-d"))
abc = {"mockpkg-a", "mockpkg-b", "mockpkg-c"}
abd = {"mockpkg-a", "mockpkg-b", "mockpkg-d"}
# Force all tests to use a git repository *in* the mock packages repo.
@ -53,27 +53,33 @@ def mock_pkg_git_repo(git, tmpdir_factory):
git("config", "user.name", "Spack Testing")
git("-c", "commit.gpgsign=false", "commit", "-m", "initial mock repo commit")
# add commit with pkg-a, pkg-b, pkg-c packages
mkdirp("pkg-a", "pkg-b", "pkg-c")
with open("pkg-a/package.py", "w") as f:
# add commit with mockpkg-a, mockpkg-b, mockpkg-c packages
mkdirp("mockpkg-a", "mockpkg-b", "mockpkg-c")
with open("mockpkg-a/package.py", "w") as f:
f.write(pkg_template.format(name="PkgA"))
with open("pkg-b/package.py", "w") as f:
with open("mockpkg-b/package.py", "w") as f:
f.write(pkg_template.format(name="PkgB"))
with open("pkg-c/package.py", "w") as f:
with open("mockpkg-c/package.py", "w") as f:
f.write(pkg_template.format(name="PkgC"))
git("add", "pkg-a", "pkg-b", "pkg-c")
git("-c", "commit.gpgsign=false", "commit", "-m", "add pkg-a, pkg-b, pkg-c")
git("add", "mockpkg-a", "mockpkg-b", "mockpkg-c")
git("-c", "commit.gpgsign=false", "commit", "-m", "add mockpkg-a, mockpkg-b, mockpkg-c")
# remove pkg-c, add pkg-d
with open("pkg-b/package.py", "a") as f:
f.write("\n# change pkg-b")
git("add", "pkg-b")
mkdirp("pkg-d")
with open("pkg-d/package.py", "w") as f:
# remove mockpkg-c, add mockpkg-d
with open("mockpkg-b/package.py", "a") as f:
f.write("\n# change mockpkg-b")
git("add", "mockpkg-b")
mkdirp("mockpkg-d")
with open("mockpkg-d/package.py", "w") as f:
f.write(pkg_template.format(name="PkgD"))
git("add", "pkg-d")
git("rm", "-rf", "pkg-c")
git("-c", "commit.gpgsign=false", "commit", "-m", "change pkg-b, remove pkg-c, add pkg-d")
git("add", "mockpkg-d")
git("rm", "-rf", "mockpkg-c")
git(
"-c",
"commit.gpgsign=false",
"commit",
"-m",
"change mockpkg-b, remove mockpkg-c, add mockpkg-d",
)
with spack.repo.use_repositories(str(repo_path)):
yield mock_repo_packages
@ -86,12 +92,11 @@ def mock_pkg_names():
# Be sure to include virtual packages since packages with stand-alone
# tests may inherit additional tests from the virtuals they provide,
# such as packages that implement `mpi`.
names = set(
return {
name
for name in repo.all_package_names(include_virtuals=True)
if not name.startswith("pkg-")
)
return names
if not name.startswith("mockpkg-")
}
def split(output):
@ -113,17 +118,17 @@ def test_mock_packages_path(mock_packages):
def test_pkg_add(git, mock_pkg_git_repo):
with working_dir(mock_pkg_git_repo):
mkdirp("pkg-e")
with open("pkg-e/package.py", "w") as f:
mkdirp("mockpkg-e")
with open("mockpkg-e/package.py", "w") as f:
f.write(pkg_template.format(name="PkgE"))
pkg("add", "pkg-e")
pkg("add", "mockpkg-e")
with working_dir(mock_pkg_git_repo):
try:
assert "A pkg-e/package.py" in git("status", "--short", output=str)
assert "A mockpkg-e/package.py" in git("status", "--short", output=str)
finally:
shutil.rmtree("pkg-e")
shutil.rmtree("mockpkg-e")
# Removing a package mid-run disrupts Spack's caching
if spack.repo.PATH.repos[0]._fast_package_checker:
spack.repo.PATH.repos[0]._fast_package_checker.invalidate()
@ -138,10 +143,10 @@ def test_pkg_list(mock_pkg_git_repo, mock_pkg_names):
assert sorted(mock_pkg_names) == sorted(out)
out = split(pkg("list", "HEAD^"))
assert sorted(mock_pkg_names.union(["pkg-a", "pkg-b", "pkg-c"])) == sorted(out)
assert sorted(mock_pkg_names.union(["mockpkg-a", "mockpkg-b", "mockpkg-c"])) == sorted(out)
out = split(pkg("list", "HEAD"))
assert sorted(mock_pkg_names.union(["pkg-a", "pkg-b", "pkg-d"])) == sorted(out)
assert sorted(mock_pkg_names.union(["mockpkg-a", "mockpkg-b", "mockpkg-d"])) == sorted(out)
# test with three dots to make sure pkg calls `git merge-base`
out = split(pkg("list", "HEAD^^..."))
@ -151,25 +156,25 @@ def test_pkg_list(mock_pkg_git_repo, mock_pkg_names):
@pytest.mark.not_on_windows("stdout format conflict")
def test_pkg_diff(mock_pkg_git_repo, mock_pkg_names):
out = split(pkg("diff", "HEAD^^", "HEAD^"))
assert out == ["HEAD^:", "pkg-a", "pkg-b", "pkg-c"]
assert out == ["HEAD^:", "mockpkg-a", "mockpkg-b", "mockpkg-c"]
out = split(pkg("diff", "HEAD^^", "HEAD"))
assert out == ["HEAD:", "pkg-a", "pkg-b", "pkg-d"]
assert out == ["HEAD:", "mockpkg-a", "mockpkg-b", "mockpkg-d"]
out = split(pkg("diff", "HEAD^", "HEAD"))
assert out == ["HEAD^:", "pkg-c", "HEAD:", "pkg-d"]
assert out == ["HEAD^:", "mockpkg-c", "HEAD:", "mockpkg-d"]
@pytest.mark.not_on_windows("stdout format conflict")
def test_pkg_added(mock_pkg_git_repo):
out = split(pkg("added", "HEAD^^", "HEAD^"))
assert ["pkg-a", "pkg-b", "pkg-c"] == out
assert ["mockpkg-a", "mockpkg-b", "mockpkg-c"] == out
out = split(pkg("added", "HEAD^^", "HEAD"))
assert ["pkg-a", "pkg-b", "pkg-d"] == out
assert ["mockpkg-a", "mockpkg-b", "mockpkg-d"] == out
out = split(pkg("added", "HEAD^", "HEAD"))
assert ["pkg-d"] == out
assert ["mockpkg-d"] == out
out = split(pkg("added", "HEAD", "HEAD"))
assert out == []
@ -184,7 +189,7 @@ def test_pkg_removed(mock_pkg_git_repo):
assert out == []
out = split(pkg("removed", "HEAD^", "HEAD"))
assert out == ["pkg-c"]
assert out == ["mockpkg-c"]
@pytest.mark.not_on_windows("stdout format conflict")
@ -196,34 +201,34 @@ def test_pkg_changed(mock_pkg_git_repo):
assert out == []
out = split(pkg("changed", "--type", "a", "HEAD^^", "HEAD^"))
assert out == ["pkg-a", "pkg-b", "pkg-c"]
assert out == ["mockpkg-a", "mockpkg-b", "mockpkg-c"]
out = split(pkg("changed", "--type", "r", "HEAD^^", "HEAD^"))
assert out == []
out = split(pkg("changed", "--type", "ar", "HEAD^^", "HEAD^"))
assert out == ["pkg-a", "pkg-b", "pkg-c"]
assert out == ["mockpkg-a", "mockpkg-b", "mockpkg-c"]
out = split(pkg("changed", "--type", "arc", "HEAD^^", "HEAD^"))
assert out == ["pkg-a", "pkg-b", "pkg-c"]
assert out == ["mockpkg-a", "mockpkg-b", "mockpkg-c"]
out = split(pkg("changed", "HEAD^", "HEAD"))
assert out == ["pkg-b"]
assert out == ["mockpkg-b"]
out = split(pkg("changed", "--type", "c", "HEAD^", "HEAD"))
assert out == ["pkg-b"]
assert out == ["mockpkg-b"]
out = split(pkg("changed", "--type", "a", "HEAD^", "HEAD"))
assert out == ["pkg-d"]
assert out == ["mockpkg-d"]
out = split(pkg("changed", "--type", "r", "HEAD^", "HEAD"))
assert out == ["pkg-c"]
assert out == ["mockpkg-c"]
out = split(pkg("changed", "--type", "ar", "HEAD^", "HEAD"))
assert out == ["pkg-c", "pkg-d"]
assert out == ["mockpkg-c", "mockpkg-d"]
out = split(pkg("changed", "--type", "arc", "HEAD^", "HEAD"))
assert out == ["pkg-b", "pkg-c", "pkg-d"]
assert out == ["mockpkg-b", "mockpkg-c", "mockpkg-d"]
# invalid type argument
with pytest.raises(spack.main.SpackCommandError):
@ -289,7 +294,7 @@ def test_pkg_canonical_source(mock_packages):
def test_pkg_hash(mock_packages):
output = pkg("hash", "a", "b").strip().split()
output = pkg("hash", "pkg-a", "pkg-b").strip().split()
assert len(output) == 2 and all(len(elt) == 32 for elt in output)
output = pkg("hash", "multimethod").strip().split()

View file

@ -59,7 +59,7 @@ def test_spec_concretizer_args(mutable_config, mutable_database):
def test_spec_parse_dependency_variant_value():
"""Verify that we can provide multiple key=value variants to multiple separate
packages within a spec string."""
output = spec("multivalue-variant fee=barbaz ^ a foobar=baz")
output = spec("multivalue-variant fee=barbaz ^ pkg-a foobar=baz")
assert "fee=barbaz" in output
assert "foobar=baz" in output

View file

@ -10,10 +10,14 @@
from llnl.util.filesystem import copy_tree
import spack.cmd.common.arguments
import spack.cmd.install
import spack.cmd.test
import spack.config
import spack.install_test
import spack.package_base
import spack.paths
import spack.spec
import spack.store
from spack.install_test import TestStatus
from spack.main import SpackCommand

View file

@ -23,6 +23,8 @@
import spack.platforms
import spack.repo
import spack.solver.asp
import spack.store
import spack.util.file_cache
import spack.variant as vt
from spack.concretize import find_spec
from spack.spec import CompilerSpec, Spec
@ -369,7 +371,7 @@ def test_compiler_flags_from_compiler_and_dependent(self):
def test_compiler_flags_differ_identical_compilers(self, mutable_config, clang12_with_flags):
mutable_config.set("compilers", [clang12_with_flags])
# Correct arch to use test compiler that has flags
spec = Spec("a %clang@12.2.0 platform=test os=fe target=fe")
spec = Spec("pkg-a %clang@12.2.0 platform=test os=fe target=fe")
# Get the compiler that matches the spec (
compiler = spack.compilers.compiler_for_spec("clang@=12.2.0", spec.architecture)
@ -438,7 +440,7 @@ def test_architecture_deep_inheritance(self, mock_targets, compiler_factory):
assert s.architecture.target == spec.architecture.target
def test_compiler_flags_from_user_are_grouped(self):
spec = Spec('a%gcc cflags="-O -foo-flag foo-val" platform=test')
spec = Spec('pkg-a%gcc cflags="-O -foo-flag foo-val" platform=test')
spec.concretize()
cflags = spec.compiler_flags["cflags"]
assert any(x == "-foo-flag foo-val" for x in cflags)
@ -546,20 +548,20 @@ def test_concretize_propagate_multivalue_variant(self):
spec = Spec("multivalue-variant foo==baz,fee")
spec.concretize()
assert spec.satisfies("^a foo=baz,fee")
assert spec.satisfies("^b foo=baz,fee")
assert not spec.satisfies("^a foo=bar")
assert not spec.satisfies("^b foo=bar")
assert spec.satisfies("^pkg-a foo=baz,fee")
assert spec.satisfies("^pkg-b foo=baz,fee")
assert not spec.satisfies("^pkg-a foo=bar")
assert not spec.satisfies("^pkg-b foo=bar")
def test_no_matching_compiler_specs(self, mock_low_high_config):
# only relevant when not building compilers as needed
with spack.concretize.enable_compiler_existence_check():
s = Spec("a %gcc@=0.0.0")
s = Spec("pkg-a %gcc@=0.0.0")
with pytest.raises(spack.concretize.UnavailableCompilerVersionError):
s.concretize()
def test_no_compilers_for_arch(self):
s = Spec("a arch=linux-rhel0-x86_64")
s = Spec("pkg-a arch=linux-rhel0-x86_64")
with pytest.raises(spack.error.SpackError):
s.concretize()
@ -768,7 +770,7 @@ def test_regression_issue_7941(self):
# The string representation of a spec containing
# an explicit multi-valued variant and a dependency
# might be parsed differently than the originating spec
s = Spec("a foobar=bar ^b")
s = Spec("pkg-a foobar=bar ^pkg-b")
t = Spec(str(s))
s.concretize()
@ -1140,14 +1142,14 @@ def test_conditional_provides_or_depends_on(self):
[
# Check that True is treated correctly and attaches test deps
# to all nodes in the DAG
("a", True, ["a"], []),
("a foobar=bar", True, ["a", "b"], []),
("pkg-a", True, ["pkg-a"], []),
("pkg-a foobar=bar", True, ["pkg-a", "pkg-b"], []),
# Check that a list of names activates the dependency only for
# packages in that list
("a foobar=bar", ["a"], ["a"], ["b"]),
("a foobar=bar", ["b"], ["b"], ["a"]),
("pkg-a foobar=bar", ["pkg-a"], ["pkg-a"], ["pkg-b"]),
("pkg-a foobar=bar", ["pkg-b"], ["pkg-b"], ["pkg-a"]),
# Check that False disregard test dependencies
("a foobar=bar", False, [], ["a", "b"]),
("pkg-a foobar=bar", False, [], ["pkg-a", "pkg-b"]),
],
)
def test_activating_test_dependencies(self, spec_str, tests_arg, with_dep, without_dep):
@ -1205,7 +1207,7 @@ def test_custom_compiler_version(self, mutable_config, compiler_factory):
mutable_config.set(
"compilers", [compiler_factory(spec="gcc@10foo", operating_system="redhat6")]
)
s = Spec("a %gcc@10foo os=redhat6").concretized()
s = Spec("pkg-a %gcc@10foo os=redhat6").concretized()
assert "%gcc@10foo" in s
def test_all_patches_applied(self):
@ -1330,10 +1332,10 @@ def test_reuse_installed_packages_when_package_def_changes(
@pytest.mark.only_clingo("Use case not supported by the original concretizer")
def test_reuse_with_flags(self, mutable_database, mutable_config):
spack.config.set("concretizer:reuse", True)
spec = Spec("a cflags=-g cxxflags=-g").concretized()
spec = Spec("pkg-a cflags=-g cxxflags=-g").concretized()
spack.store.STORE.db.add(spec, None)
testspec = Spec("a cflags=-g")
testspec = Spec("pkg-a cflags=-g")
testspec.concretize()
assert testspec == spec
@ -1674,31 +1676,31 @@ def test_reuse_with_unknown_namespace_dont_raise(
self, temporary_store, mock_custom_repository
):
with spack.repo.use_repositories(mock_custom_repository, override=False):
s = Spec("c").concretized()
s = Spec("pkg-c").concretized()
assert s.namespace != "builtin.mock"
s.package.do_install(fake=True, explicit=True)
with spack.config.override("concretizer:reuse", True):
s = Spec("c").concretized()
s = Spec("pkg-c").concretized()
assert s.namespace == "builtin.mock"
@pytest.mark.regression("28259")
def test_reuse_with_unknown_package_dont_raise(self, tmpdir, temporary_store, monkeypatch):
builder = spack.repo.MockRepositoryBuilder(tmpdir.mkdir("mock.repo"), namespace="myrepo")
builder.add_package("c")
builder.add_package("pkg-c")
with spack.repo.use_repositories(builder.root, override=False):
s = Spec("c").concretized()
s = Spec("pkg-c").concretized()
assert s.namespace == "myrepo"
s.package.do_install(fake=True, explicit=True)
del sys.modules["spack.pkg.myrepo.c"]
del sys.modules["spack.pkg.myrepo.pkg-c"]
del sys.modules["spack.pkg.myrepo"]
builder.remove("c")
builder.remove("pkg-c")
with spack.repo.use_repositories(builder.root, override=False) as repos:
# TODO (INJECT CONFIGURATION): unclear why the cache needs to be invalidated explicitly
repos.repos[0]._pkg_checker.invalidate()
with spack.config.override("concretizer:reuse", True):
s = Spec("c").concretized()
s = Spec("pkg-c").concretized()
assert s.namespace == "builtin.mock"
@pytest.mark.parametrize(
@ -1810,20 +1812,20 @@ def test_misleading_error_message_on_version(self, mutable_database):
@pytest.mark.only_clingo("Use case not supported by the original concretizer")
def test_version_weight_and_provenance(self):
"""Test package preferences during coconcretization."""
reusable_specs = [Spec(spec_str).concretized() for spec_str in ("b@0.9", "b@1.0")]
root_spec = Spec("a foobar=bar")
reusable_specs = [Spec(spec_str).concretized() for spec_str in ("pkg-b@0.9", "pkg-b@1.0")]
root_spec = Spec("pkg-a foobar=bar")
with spack.config.override("concretizer:reuse", True):
solver = spack.solver.asp.Solver()
setup = spack.solver.asp.SpackSolverSetup()
result, _, _ = solver.driver.solve(setup, [root_spec], reuse=reusable_specs)
# The result here should have a single spec to build ('a')
# and it should be using b@1.0 with a version badness of 2
# The result here should have a single spec to build ('pkg-a')
# and it should be using pkg-b@1.0 with a version badness of 2
# The provenance is:
# version_declared("b","1.0",0,"package_py").
# version_declared("b","0.9",1,"package_py").
# version_declared("b","1.0",2,"installed").
# version_declared("b","0.9",3,"installed").
# version_declared("pkg-b","1.0",0,"package_py").
# version_declared("pkg-b","0.9",1,"package_py").
# version_declared("pkg-b","1.0",2,"installed").
# version_declared("pkg-b","0.9",3,"installed").
#
# Depending on the target, it may also use gnuconfig
result_spec = result.specs[0]
@ -1836,12 +1838,12 @@ def test_version_weight_and_provenance(self):
for criterion in criteria:
assert criterion in result.criteria
assert result_spec.satisfies("^b@1.0")
assert result_spec.satisfies("^pkg-b@1.0")
@pytest.mark.regression("31169")
@pytest.mark.only_clingo("Use case not supported by the original concretizer")
def test_not_reusing_incompatible_os_or_compiler(self):
root_spec = Spec("b")
root_spec = Spec("pkg-b")
s = root_spec.concretized()
wrong_compiler, wrong_os = s.copy(), s.copy()
wrong_compiler.compiler = spack.spec.CompilerSpec("gcc@12.1.0")
@ -2096,7 +2098,7 @@ def test_external_python_extension_find_unified_python(self):
"specs",
[
["mpileaks^ callpath ^dyninst@8.1.1:8 ^mpich2@1.3:1"],
["multivalue-variant ^a@2:2"],
["multivalue-variant ^pkg-a@2:2"],
["v1-consumer ^conditional-provider@1:1 +disable-v1"],
],
)
@ -2146,7 +2148,7 @@ def test_compiler_match_constraints_when_selected(self):
},
]
spack.config.set("compilers", compiler_configuration)
s = Spec("a %gcc@:11").concretized()
s = Spec("pkg-a %gcc@:11").concretized()
assert s.compiler.version == ver("=11.1.0"), s
@pytest.mark.regression("36339")
@ -2167,7 +2169,7 @@ def test_compiler_with_custom_non_numeric_version(self, mock_executable):
}
]
spack.config.set("compilers", compiler_configuration)
s = Spec("a %gcc@foo").concretized()
s = Spec("pkg-a %gcc@foo").concretized()
assert s.compiler.version == ver("=foo")
@pytest.mark.regression("36628")
@ -2193,7 +2195,7 @@ def test_concretization_with_compilers_supporting_target_any(self):
]
with spack.config.override("compilers", compiler_configuration):
s = spack.spec.Spec("a").concretized()
s = Spec("pkg-a").concretized()
assert s.satisfies("%gcc@12.1.0")
@pytest.mark.parametrize("spec_str", ["mpileaks", "mpileaks ^mpich"])
@ -2228,7 +2230,7 @@ def test_dont_define_new_version_from_input_if_checksum_required(self, working_e
with pytest.raises(spack.error.UnsatisfiableSpecError):
# normally spack concretizes to @=3.0 if it's not defined in package.py, except
# when checksums are required
Spec("a@=3.0").concretized()
Spec("pkg-a@=3.0").concretized()
@pytest.mark.regression("39570")
@pytest.mark.db
@ -2453,7 +2455,9 @@ def test_drop_moving_targets(v_str, v_opts, checksummed):
class TestConcreteSpecsByHash:
"""Tests the container of concrete specs"""
@pytest.mark.parametrize("input_specs", [["a"], ["a foobar=bar", "b"], ["a foobar=baz", "b"]])
@pytest.mark.parametrize(
"input_specs", [["pkg-a"], ["pkg-a foobar=bar", "pkg-b"], ["pkg-a foobar=baz", "pkg-b"]]
)
def test_adding_specs(self, input_specs, default_mock_concretization):
"""Tests that concrete specs in the container are equivalent, but stored as different
objects in memory.

View file

@ -512,5 +512,5 @@ def test_default_preference_variant_different_type_does_not_error(self):
packages.yaml doesn't fail with an error.
"""
with spack.config.override("packages:all", {"variants": "+foo"}):
s = Spec("a").concretized()
s = Spec("pkg-a").concretized()
assert s.satisfies("foo=bar")

View file

@ -1176,13 +1176,13 @@ def test_license_dir_config(mutable_config, mock_packages):
expected_dir = spack.paths.default_license_dir
assert spack.config.get("config:license_dir") == expected_dir
assert spack.package_base.PackageBase.global_license_dir == expected_dir
assert spack.repo.PATH.get_pkg_class("a").global_license_dir == expected_dir
assert spack.repo.PATH.get_pkg_class("pkg-a").global_license_dir == expected_dir
rel_path = os.path.join(os.path.sep, "foo", "bar", "baz")
spack.config.set("config:license_dir", rel_path)
assert spack.config.get("config:license_dir") == rel_path
assert spack.package_base.PackageBase.global_license_dir == rel_path
assert spack.repo.PATH.get_pkg_class("a").global_license_dir == rel_path
assert spack.repo.PATH.get_pkg_class("pkg-a").global_license_dir == rel_path
@pytest.mark.regression("22547")

View file

@ -597,7 +597,7 @@ def mutable_mock_repo(mock_repo_path, request):
def mock_custom_repository(tmpdir, mutable_mock_repo):
"""Create a custom repository with a single package "c" and return its path."""
builder = spack.repo.MockRepositoryBuilder(tmpdir.mkdir("myrepo"))
builder.add_package("c")
builder.add_package("pkg-c")
return builder.root

View file

@ -69,7 +69,7 @@ def test_spec_installed_upstream(
# a known installed spec should say that it's installed
with spack.repo.use_repositories(mock_custom_repository):
spec = spack.spec.Spec("c").concretized()
spec = spack.spec.Spec("pkg-c").concretized()
assert not spec.installed
assert not spec.installed_upstream
@ -813,7 +813,7 @@ def test_query_virtual_spec(database):
def test_failed_spec_path_error(database):
"""Ensure spec not concrete check is covered."""
s = spack.spec.Spec("a")
s = spack.spec.Spec("pkg-a")
with pytest.raises(AssertionError, match="concrete spec required"):
spack.store.STORE.failure_tracker.mark(s)
@ -828,7 +828,7 @@ def _is(self, spec):
# Pretend the spec has been failure locked
monkeypatch.setattr(spack.database.FailureTracker, "lock_taken", _is)
s = spack.spec.Spec("a").concretized()
s = spack.spec.Spec("pkg-a").concretized()
spack.store.STORE.failure_tracker.clear(s)
out = capfd.readouterr()[0]
assert "Retaining failure marking" in out
@ -846,7 +846,7 @@ def _is(self, spec):
# Ensure raise OSError when try to remove the non-existent marking
monkeypatch.setattr(spack.database.FailureTracker, "persistent_mark", _is)
s = default_mock_concretization("a")
s = spack.spec.Spec("pkg-a").concretized()
spack.store.STORE.failure_tracker.clear(s, force=True)
out = capfd.readouterr()[1]
assert "Removing failure marking despite lock" in out
@ -860,15 +860,16 @@ def test_mark_failed(default_mock_concretization, mutable_database, monkeypatch,
def _raise_exc(lock):
raise lk.LockTimeoutError("write", "/mock-lock", 1.234, 10)
with tmpdir.as_cwd():
s = spack.spec.Spec("pkg-a").concretized()
# Ensure attempt to acquire write lock on the mark raises the exception
monkeypatch.setattr(lk.Lock, "acquire_write", _raise_exc)
with tmpdir.as_cwd():
s = default_mock_concretization("a")
spack.store.STORE.failure_tracker.mark(s)
out = str(capsys.readouterr()[1])
assert "Unable to mark a as failed" in out
assert "Unable to mark pkg-a as failed" in out
spack.store.STORE.failure_tracker.clear_all()
@ -877,7 +878,7 @@ def _raise_exc(lock):
def test_prefix_failed(default_mock_concretization, mutable_database, monkeypatch):
"""Add coverage to failed operation."""
s = default_mock_concretization("a")
s = spack.spec.Spec("pkg-a").concretized()
# Confirm the spec is not already marked as failed
assert not spack.store.STORE.failure_tracker.has_failed(s)
@ -901,7 +902,7 @@ def test_prefix_write_lock_error(default_mock_concretization, mutable_database,
def _raise(db, spec):
raise lk.LockError("Mock lock error")
s = default_mock_concretization("a")
s = spack.spec.Spec("pkg-a").concretized()
# Ensure subsequent lock operations fail
monkeypatch.setattr(lk.Lock, "acquire_write", _raise)

View file

@ -30,7 +30,7 @@ def test_true_directives_exist(mock_packages):
assert cls.dependencies
assert spack.spec.Spec() in cls.dependencies["extendee"]
assert spack.spec.Spec() in cls.dependencies["b"]
assert spack.spec.Spec() in cls.dependencies["pkg-b"]
assert cls.resources
assert spack.spec.Spec() in cls.resources
@ -43,7 +43,7 @@ def test_constraints_from_context(mock_packages):
pkg_cls = spack.repo.PATH.get_pkg_class("with-constraint-met")
assert pkg_cls.dependencies
assert spack.spec.Spec("@1.0") in pkg_cls.dependencies["b"]
assert spack.spec.Spec("@1.0") in pkg_cls.dependencies["pkg-b"]
assert pkg_cls.conflicts
assert (spack.spec.Spec("+foo@1.0"), None) in pkg_cls.conflicts["%gcc"]
@ -54,7 +54,7 @@ def test_constraints_from_context_are_merged(mock_packages):
pkg_cls = spack.repo.PATH.get_pkg_class("with-constraint-met")
assert pkg_cls.dependencies
assert spack.spec.Spec("@0.14:15 ^b@3.8:4.0") in pkg_cls.dependencies["c"]
assert spack.spec.Spec("@0.14:15 ^pkg-b@3.8:4.0") in pkg_cls.dependencies["pkg-c"]
@pytest.mark.regression("27754")
@ -68,7 +68,7 @@ def test_extends_spec(config, mock_packages):
@pytest.mark.regression("34368")
def test_error_on_anonymous_dependency(config, mock_packages):
pkg = spack.repo.PATH.get_pkg_class("a")
pkg = spack.repo.PATH.get_pkg_class("pkg-a")
with pytest.raises(spack.directives.DependencyError):
spack.directives._depends_on(pkg, "@4.5")

View file

@ -377,10 +377,10 @@ def test_can_add_specs_to_environment_without_specs_attribute(tmp_path, mock_pac
"""
)
env = ev.Environment(tmp_path)
env.add("a")
env.add("pkg-a")
assert len(env.user_specs) == 1
assert env.manifest.pristine_yaml_content["spack"]["specs"] == ["a"]
assert env.manifest.pristine_yaml_content["spack"]["specs"] == ["pkg-a"]
@pytest.mark.parametrize(
@ -578,7 +578,7 @@ def test_conflicts_with_packages_that_are_not_dependencies(
spack:
specs:
- {spec_str}
- b
- pkg-b
concretizer:
unify: true
"""
@ -706,7 +706,7 @@ def test_variant_propagation_with_unify_false(tmp_path, mock_packages, config):
spack:
specs:
- parent-foo ++foo
- c
- pkg-c
concretizer:
unify: false
"""
@ -791,10 +791,10 @@ def test_deconcretize_then_concretize_does_not_error(mutable_mock_env_path, mock
"""spack:
specs:
# These two specs concretize to the same hash
- c
- c@1.0
- pkg-c
- pkg-c@1.0
# Spec used to trigger the bug
- a
- pkg-a
concretizer:
unify: true
"""
@ -802,8 +802,8 @@ def test_deconcretize_then_concretize_does_not_error(mutable_mock_env_path, mock
e = ev.Environment(mutable_mock_env_path)
with e:
e.concretize()
e.deconcretize(spack.spec.Spec("a"), concrete=False)
e.deconcretize(spack.spec.Spec("pkg-a"), concrete=False)
e.concretize()
assert len(e.concrete_roots()) == 3
all_root_hashes = set(x.dag_hash() for x in e.concrete_roots())
all_root_hashes = {x.dag_hash() for x in e.concrete_roots()}
assert len(all_root_hashes) == 2

View file

@ -132,7 +132,7 @@ def test_hms(sec, result):
def test_get_dependent_ids(install_mockery, mock_packages):
# Concretize the parent package, which handle dependency too
spec = spack.spec.Spec("a")
spec = spack.spec.Spec("pkg-a")
spec.concretize()
assert spec.concrete
@ -223,11 +223,11 @@ def _spec(spec, unsigned=False, mirrors_for_spec=None):
# Skip database updates
monkeypatch.setattr(spack.database.Database, "add", _noop)
spec = spack.spec.Spec("a").concretized()
spec = spack.spec.Spec("pkg-a").concretized()
assert inst._process_binary_cache_tarball(spec.package, explicit=False, unsigned=False)
out = capfd.readouterr()[0]
assert "Extracting a" in out
assert "Extracting pkg-a" in out
assert "from binary cache" in out
@ -278,7 +278,7 @@ def test_installer_prune_built_build_deps(install_mockery, monkeypatch, tmpdir):
@property
def _mock_installed(self):
return self.name in ["c"]
return self.name == "pkg-c"
# Mock the installed property to say that (b) is installed
monkeypatch.setattr(spack.spec.Spec, "installed", _mock_installed)
@ -286,24 +286,25 @@ def _mock_installed(self):
# Create mock repository with packages (a), (b), (c), (d), and (e)
builder = spack.repo.MockRepositoryBuilder(tmpdir.mkdir("mock-repo"))
builder.add_package("a", dependencies=[("b", "build", None), ("c", "build", None)])
builder.add_package("b", dependencies=[("d", "build", None)])
builder.add_package("pkg-a", dependencies=[("pkg-b", "build", None), ("pkg-c", "build", None)])
builder.add_package("pkg-b", dependencies=[("pkg-d", "build", None)])
builder.add_package(
"c", dependencies=[("d", "build", None), ("e", "all", None), ("f", "build", None)]
"pkg-c",
dependencies=[("pkg-d", "build", None), ("pkg-e", "all", None), ("pkg-f", "build", None)],
)
builder.add_package("d")
builder.add_package("e")
builder.add_package("f")
builder.add_package("pkg-d")
builder.add_package("pkg-e")
builder.add_package("pkg-f")
with spack.repo.use_repositories(builder.root):
const_arg = installer_args(["a"], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
installer._init_queue()
# Assert that (c) is not in the build_pq
result = set([task.pkg_id[0] for _, task in installer.build_pq])
expected = set(["a", "b", "c", "d", "e"])
result = {task.pkg_id[:5] for _, task in installer.build_pq}
expected = {"pkg-a", "pkg-b", "pkg-c", "pkg-d", "pkg-e"}
assert result == expected
@ -418,8 +419,7 @@ def test_ensure_locked_have(install_mockery, tmpdir, capsys):
@pytest.mark.parametrize("lock_type,reads,writes", [("read", 1, 0), ("write", 0, 1)])
def test_ensure_locked_new_lock(install_mockery, tmpdir, lock_type, reads, writes):
pkg_id = "a"
const_arg = installer_args([pkg_id], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
spec = installer.build_requests[0].pkg.spec
with tmpdir.as_cwd():
@ -438,8 +438,7 @@ def _pl(db, spec, timeout):
lock.default_timeout = 1e-9 if timeout is None else None
return lock
pkg_id = "a"
const_arg = installer_args([pkg_id], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
spec = installer.build_requests[0].pkg.spec
@ -496,7 +495,7 @@ def test_packages_needed_to_bootstrap_compiler_packages(install_mockery, monkeyp
spec.concretize()
def _conc_spec(compiler):
return spack.spec.Spec("a").concretized()
return spack.spec.Spec("pkg-a").concretized()
# Ensure we can get past functions that are precluding obtaining
# packages.
@ -604,7 +603,7 @@ def test_clear_failures_success(tmpdir):
"""Test the clear_failures happy path."""
failures = spack.database.FailureTracker(str(tmpdir), default_timeout=0.1)
spec = spack.spec.Spec("a")
spec = spack.spec.Spec("pkg-a")
spec._mark_concrete()
# Set up a test prefix failure lock
@ -630,7 +629,7 @@ def test_clear_failures_success(tmpdir):
def test_clear_failures_errs(tmpdir, capsys):
"""Test the clear_failures exception paths."""
failures = spack.database.FailureTracker(str(tmpdir), default_timeout=0.1)
spec = spack.spec.Spec("a")
spec = spack.spec.Spec("pkg-a")
spec._mark_concrete()
failures.mark(spec)
@ -692,11 +691,11 @@ def test_check_deps_status_install_failure(install_mockery):
"""Tests that checking the dependency status on a request to install
'a' fails, if we mark the dependency as failed.
"""
s = spack.spec.Spec("a").concretized()
s = spack.spec.Spec("pkg-a").concretized()
for dep in s.traverse(root=False):
spack.store.STORE.failure_tracker.mark(dep)
const_arg = installer_args(["a"], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
request = installer.build_requests[0]
@ -705,7 +704,7 @@ def test_check_deps_status_install_failure(install_mockery):
def test_check_deps_status_write_locked(install_mockery, monkeypatch):
const_arg = installer_args(["a"], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
request = installer.build_requests[0]
@ -717,7 +716,7 @@ def test_check_deps_status_write_locked(install_mockery, monkeypatch):
def test_check_deps_status_external(install_mockery, monkeypatch):
const_arg = installer_args(["a"], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
request = installer.build_requests[0]
@ -730,7 +729,7 @@ def test_check_deps_status_external(install_mockery, monkeypatch):
def test_check_deps_status_upstream(install_mockery, monkeypatch):
const_arg = installer_args(["a"], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
request = installer.build_requests[0]
@ -807,7 +806,7 @@ def test_install_task_add_compiler(install_mockery, monkeypatch, capfd):
def _add(_compilers):
tty.msg(config_msg)
const_arg = installer_args(["a"], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
task = create_build_task(installer.build_requests[0].pkg)
task.compiler = True
@ -845,7 +844,7 @@ def test_release_lock_write_n_exception(install_mockery, tmpdir, capsys):
@pytest.mark.parametrize("installed", [True, False])
def test_push_task_skip_processed(install_mockery, installed):
"""Test to ensure skip re-queueing a processed package."""
const_arg = installer_args(["a"], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
assert len(list(installer.build_tasks)) == 0
@ -863,7 +862,7 @@ def test_push_task_skip_processed(install_mockery, installed):
def test_requeue_task(install_mockery, capfd):
"""Test to ensure cover _requeue_task."""
const_arg = installer_args(["a"], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
task = create_build_task(installer.build_requests[0].pkg)
@ -881,7 +880,7 @@ def test_requeue_task(install_mockery, capfd):
assert qtask.attempts == task.attempts + 1
out = capfd.readouterr()[1]
assert "Installing a" in out
assert "Installing pkg-a" in out
assert " in progress by another process" in out
@ -894,17 +893,17 @@ def _mktask(pkg):
def _rmtask(installer, pkg_id):
raise RuntimeError("Raise an exception to test except path")
const_arg = installer_args(["a"], {})
const_arg = installer_args(["pkg-a"], {})
installer = create_installer(const_arg)
spec = installer.build_requests[0].pkg.spec
# Cover task removal happy path
installer.build_tasks["a"] = _mktask(spec.package)
installer.build_tasks["pkg-a"] = _mktask(spec.package)
installer._cleanup_all_tasks()
assert len(installer.build_tasks) == 0
# Cover task removal exception path
installer.build_tasks["a"] = _mktask(spec.package)
installer.build_tasks["pkg-a"] = _mktask(spec.package)
monkeypatch.setattr(inst.PackageInstaller, "_remove_task", _rmtask)
installer._cleanup_all_tasks()
assert len(installer.build_tasks) == 1
@ -998,7 +997,7 @@ def test_install_uninstalled_deps(install_mockery, monkeypatch, capsys):
def test_install_failed(install_mockery, monkeypatch, capsys):
"""Test install with failed install."""
const_arg = installer_args(["b"], {})
const_arg = installer_args(["pkg-b"], {})
installer = create_installer(const_arg)
# Make sure the package is identified as failed
@ -1014,7 +1013,7 @@ def test_install_failed(install_mockery, monkeypatch, capsys):
def test_install_failed_not_fast(install_mockery, monkeypatch, capsys):
"""Test install with failed install."""
const_arg = installer_args(["a"], {"fail_fast": False})
const_arg = installer_args(["pkg-a"], {"fail_fast": False})
installer = create_installer(const_arg)
# Make sure the package is identified as failed
@ -1025,12 +1024,12 @@ def test_install_failed_not_fast(install_mockery, monkeypatch, capsys):
out = str(capsys.readouterr())
assert "failed to install" in out
assert "Skipping build of a" in out
assert "Skipping build of pkg-a" in out
def test_install_fail_on_interrupt(install_mockery, monkeypatch):
"""Test ctrl-c interrupted install."""
spec_name = "a"
spec_name = "pkg-a"
err_msg = "mock keyboard interrupt for {0}".format(spec_name)
def _interrupt(installer, task, install_status, **kwargs):
@ -1048,13 +1047,13 @@ def _interrupt(installer, task, install_status, **kwargs):
with pytest.raises(KeyboardInterrupt, match=err_msg):
installer.install()
assert "b" in installer.installed # ensure dependency of a is 'installed'
assert "pkg-b" in installer.installed # ensure dependency of pkg-a is 'installed'
assert spec_name not in installer.installed
def test_install_fail_single(install_mockery, monkeypatch):
"""Test expected results for failure of single package."""
spec_name = "a"
spec_name = "pkg-a"
err_msg = "mock internal package build error for {0}".format(spec_name)
class MyBuildException(Exception):
@ -1075,13 +1074,13 @@ def _install(installer, task, install_status, **kwargs):
with pytest.raises(MyBuildException, match=err_msg):
installer.install()
assert "b" in installer.installed # ensure dependency of a is 'installed'
assert "pkg-b" in installer.installed # ensure dependency of a is 'installed'
assert spec_name not in installer.installed
def test_install_fail_multi(install_mockery, monkeypatch):
"""Test expected results for failure of multiple packages."""
spec_name = "c"
spec_name = "pkg-c"
err_msg = "mock internal package build error"
class MyBuildException(Exception):
@ -1093,7 +1092,7 @@ def _install(installer, task, install_status, **kwargs):
else:
installer.installed.add(task.pkg.name)
const_arg = installer_args([spec_name, "a"], {})
const_arg = installer_args([spec_name, "pkg-a"], {})
installer = create_installer(const_arg)
# Raise a KeyboardInterrupt error to trigger early termination
@ -1102,14 +1101,14 @@ def _install(installer, task, install_status, **kwargs):
with pytest.raises(inst.InstallError, match="Installation request failed"):
installer.install()
assert "a" in installer.installed # ensure the the second spec installed
assert "pkg-a" in installer.installed # ensure the the second spec installed
assert spec_name not in installer.installed
def test_install_fail_fast_on_detect(install_mockery, monkeypatch, capsys):
"""Test fail_fast install when an install failure is detected."""
const_arg = installer_args(["b"], {"fail_fast": False})
const_arg.extend(installer_args(["c"], {"fail_fast": True}))
const_arg = installer_args(["pkg-b"], {"fail_fast": False})
const_arg.extend(installer_args(["pkg-c"], {"fail_fast": True}))
installer = create_installer(const_arg)
pkg_ids = [inst.package_id(spec.package) for spec, _ in const_arg]
@ -1139,7 +1138,7 @@ def _test_install_fail_fast_on_except_patch(installer, **kwargs):
@pytest.mark.disable_clean_stage_check
def test_install_fail_fast_on_except(install_mockery, monkeypatch, capsys):
"""Test fail_fast install when an install failure results from an error."""
const_arg = installer_args(["a"], {"fail_fast": True})
const_arg = installer_args(["pkg-a"], {"fail_fast": True})
installer = create_installer(const_arg)
# Raise a non-KeyboardInterrupt exception to trigger fast failure.
@ -1154,7 +1153,7 @@ def test_install_fail_fast_on_except(install_mockery, monkeypatch, capsys):
installer.install()
out = str(capsys.readouterr())
assert "Skipping build of a" in out
assert "Skipping build of pkg-a" in out
def test_install_lock_failures(install_mockery, monkeypatch, capfd):
@ -1163,7 +1162,7 @@ def test_install_lock_failures(install_mockery, monkeypatch, capfd):
def _requeued(installer, task, install_status):
tty.msg("requeued {0}".format(task.pkg.spec.name))
const_arg = installer_args(["b"], {})
const_arg = installer_args(["pkg-b"], {})
installer = create_installer(const_arg)
# Ensure never acquire a lock
@ -1183,7 +1182,7 @@ def _requeued(installer, task, install_status):
def test_install_lock_installed_requeue(install_mockery, monkeypatch, capfd):
"""Cover basic install handling for installed package."""
const_arg = installer_args(["b"], {})
const_arg = installer_args(["pkg-b"], {})
b, _ = const_arg[0]
installer = create_installer(const_arg)
b_pkg_id = inst.package_id(b.package)
@ -1239,7 +1238,7 @@ def _requeued(installer, task, install_status):
# Ensure don't continually requeue the task
monkeypatch.setattr(inst.PackageInstaller, "_requeue_task", _requeued)
const_arg = installer_args(["b"], {})
const_arg = installer_args(["pkg-b"], {})
installer = create_installer(const_arg)
with pytest.raises(inst.InstallError, match="request failed"):
@ -1255,7 +1254,7 @@ def _requeued(installer, task, install_status):
def test_install_skip_patch(install_mockery, mock_fetch):
"""Test the path skip_patch install path."""
spec_name = "b"
spec_name = "pkg-b"
const_arg = installer_args([spec_name], {"fake": False, "skip_patch": True})
installer = create_installer(const_arg)
@ -1282,7 +1281,7 @@ def test_overwrite_install_backup_success(temporary_store, config, mock_packages
of the original prefix, and leave the original spec marked installed.
"""
# Get a build task. TODO: refactor this to avoid calling internal methods
const_arg = installer_args(["b"])
const_arg = installer_args(["pkg-b"], {})
installer = create_installer(const_arg)
installer._init_queue()
task = installer._pop_task()
@ -1343,7 +1342,7 @@ def remove(self, spec):
self.called = True
# Get a build task. TODO: refactor this to avoid calling internal methods
const_arg = installer_args(["b"])
const_arg = installer_args(["pkg-b"], {})
installer = create_installer(const_arg)
installer._init_queue()
task = installer._pop_task()
@ -1372,8 +1371,8 @@ def test_term_status_line():
# accept that. `with log_output(buf)` doesn't really work because it trims output
# and we actually want to test for escape sequences etc.
x = inst.TermStatusLine(enabled=True)
x.add("a")
x.add("b")
x.add("pkg-a")
x.add("pkg-b")
x.clear()

View file

@ -289,8 +289,8 @@ def test_mirror_cache_symlinks(tmpdir):
@pytest.mark.parametrize(
"specs,expected_specs",
[
(["a"], ["a@=1.0", "a@=2.0"]),
(["a", "brillig"], ["a@=1.0", "a@=2.0", "brillig@=1.0.0", "brillig@=2.0.0"]),
(["pkg-a"], ["pkg-a@=1.0", "pkg-a@=2.0"]),
(["pkg-a", "brillig"], ["pkg-a@=1.0", "pkg-a@=2.0", "brillig@=1.0.0", "brillig@=2.0.0"]),
],
)
def test_get_all_versions(specs, expected_specs):

View file

@ -13,28 +13,44 @@
# Normalize simple conditionals
("optional-dep-test", {"optional-dep-test": None}),
("optional-dep-test~a", {"optional-dep-test~a": None}),
("optional-dep-test+a", {"optional-dep-test+a": {"a": None}}),
("optional-dep-test a=true", {"optional-dep-test a=true": {"a": None}}),
("optional-dep-test a=true", {"optional-dep-test+a": {"a": None}}),
("optional-dep-test@1.1", {"optional-dep-test@1.1": {"b": None}}),
("optional-dep-test%intel", {"optional-dep-test%intel": {"c": None}}),
("optional-dep-test%intel@64.1", {"optional-dep-test%intel@64.1": {"c": None, "d": None}}),
("optional-dep-test+a", {"optional-dep-test+a": {"pkg-a": None}}),
("optional-dep-test a=true", {"optional-dep-test a=true": {"pkg-a": None}}),
("optional-dep-test a=true", {"optional-dep-test+a": {"pkg-a": None}}),
("optional-dep-test@1.1", {"optional-dep-test@1.1": {"pkg-b": None}}),
("optional-dep-test%intel", {"optional-dep-test%intel": {"pkg-c": None}}),
(
"optional-dep-test%intel@64.1",
{"optional-dep-test%intel@64.1": {"pkg-c": None, "pkg-d": None}},
),
(
"optional-dep-test%intel@64.1.2",
{"optional-dep-test%intel@64.1.2": {"c": None, "d": None}},
{"optional-dep-test%intel@64.1.2": {"pkg-c": None, "pkg-d": None}},
),
("optional-dep-test%clang@35", {"optional-dep-test%clang@35": {"e": None}}),
("optional-dep-test%clang@35", {"optional-dep-test%clang@35": {"pkg-e": None}}),
# Normalize multiple conditionals
("optional-dep-test+a@1.1", {"optional-dep-test+a@1.1": {"a": None, "b": None}}),
("optional-dep-test+a%intel", {"optional-dep-test+a%intel": {"a": None, "c": None}}),
("optional-dep-test@1.1%intel", {"optional-dep-test@1.1%intel": {"b": None, "c": None}}),
("optional-dep-test+a@1.1", {"optional-dep-test+a@1.1": {"pkg-a": None, "pkg-b": None}}),
(
"optional-dep-test+a%intel",
{"optional-dep-test+a%intel": {"pkg-a": None, "pkg-c": None}},
),
(
"optional-dep-test@1.1%intel",
{"optional-dep-test@1.1%intel": {"pkg-b": None, "pkg-c": None}},
),
(
"optional-dep-test@1.1%intel@64.1.2+a",
{"optional-dep-test@1.1%intel@64.1.2+a": {"a": None, "b": None, "c": None, "d": None}},
{
"optional-dep-test@1.1%intel@64.1.2+a": {
"pkg-a": None,
"pkg-b": None,
"pkg-c": None,
"pkg-d": None,
}
},
),
(
"optional-dep-test@1.1%clang@36.5+a",
{"optional-dep-test@1.1%clang@36.5+a": {"b": None, "a": None, "e": None}},
{"optional-dep-test@1.1%clang@36.5+a": {"pkg-b": None, "pkg-a": None, "pkg-e": None}},
),
# Chained MPI
(
@ -44,7 +60,10 @@
# Each of these dependencies comes from a conditional
# dependency on another. This requires iterating to evaluate
# the whole chain.
("optional-dep-test+f", {"optional-dep-test+f": {"f": None, "g": None, "mpi": None}}),
(
"optional-dep-test+f",
{"optional-dep-test+f": {"pkg-f": None, "pkg-g": None, "mpi": None}},
),
]
)
def spec_and_expected(request):
@ -63,12 +82,12 @@ def test_normalize(spec_and_expected, config, mock_packages):
def test_default_variant(config, mock_packages):
spec = Spec("optional-dep-test-3")
spec.concretize()
assert "a" in spec
assert "pkg-a" in spec
spec = Spec("optional-dep-test-3~var")
spec.concretize()
assert "a" in spec
assert "pkg-a" in spec
spec = Spec("optional-dep-test-3+var")
spec.concretize()
assert "b" in spec
assert "pkg-b" in spec

View file

@ -21,6 +21,7 @@
import spack.install_test
import spack.package_base
import spack.repo
import spack.spec
from spack.build_systems.generic import Package
from spack.installer import InstallError
@ -141,19 +142,19 @@ def setup_install_test(source_paths, test_root):
"spec,sources,extras,expect",
[
(
"a",
"pkg-a",
["example/a.c"], # Source(s)
["example/a.c"], # Extra test source
["example/a.c"],
), # Test install dir source(s)
(
"b",
"pkg-b",
["test/b.cpp", "test/b.hpp", "example/b.txt"], # Source(s)
["test"], # Extra test source
["test/b.cpp", "test/b.hpp"],
), # Test install dir source
(
"c",
"pkg-c",
["examples/a.py", "examples/b.py", "examples/c.py", "tests/d.py"],
["examples/b.py", "tests"],
["examples/b.py", "tests/d.py"],
@ -201,7 +202,7 @@ def test_cache_extra_sources(install_mockery, spec, sources, extras, expect):
def test_cache_extra_sources_fails(install_mockery):
s = spack.spec.Spec("a").concretized()
s = spack.spec.Spec("pkg-a").concretized()
s.package.spec.concretize()
with pytest.raises(InstallError) as exc_info:
@ -225,7 +226,7 @@ class URLsPackage(spack.package.Package):
url = "https://www.example.com/url-package-1.0.tgz"
urls = ["https://www.example.com/archive"]
s = spack.spec.Spec("a")
s = spack.spec.Spec("pkg-a")
with pytest.raises(ValueError, match="defines both"):
URLsPackage(s)
@ -235,7 +236,7 @@ class LicensedPackage(spack.package.Package):
extendees = None # currently a required attribute for is_extension()
license_files = None
s = spack.spec.Spec("a")
s = spack.spec.Spec("pkg-a")
pkg = LicensedPackage(s)
assert pkg.global_license_file is None
@ -248,21 +249,21 @@ class BaseTestPackage(Package):
def test_package_version_fails():
s = spack.spec.Spec("a")
s = spack.spec.Spec("pkg-a")
pkg = BaseTestPackage(s)
with pytest.raises(ValueError, match="does not have a concrete version"):
pkg.version()
def test_package_tester_fails():
s = spack.spec.Spec("a")
s = spack.spec.Spec("pkg-a")
pkg = BaseTestPackage(s)
with pytest.raises(ValueError, match="without concrete version"):
pkg.tester()
def test_package_fetcher_fails():
s = spack.spec.Spec("a")
s = spack.spec.Spec("pkg-a")
pkg = BaseTestPackage(s)
with pytest.raises(ValueError, match="without concrete version"):
pkg.fetcher
@ -280,7 +281,7 @@ def compilers(compiler, arch_spec):
monkeypatch.setattr(spack.compilers, "compilers_for_spec", compilers)
s = spack.spec.Spec("a")
s = spack.spec.Spec("pkg-a")
pkg = BaseTestPackage(s)
pkg.test_requires_compiler = True
pkg.do_test()

View file

@ -517,7 +517,7 @@ def test_manual_download(
def _instr(pkg):
return f"Download instructions for {pkg.spec.name}"
spec = default_mock_concretization("a")
spec = default_mock_concretization("pkg-a")
spec.package.manual_download = manual
if instr:
monkeypatch.setattr(spack.package_base.PackageBase, "download_instr", _instr)
@ -543,7 +543,7 @@ def test_fetch_without_code_is_noop(
default_mock_concretization, install_mockery, fetching_not_allowed
):
"""do_fetch for packages without code should be a no-op"""
pkg = default_mock_concretization("a").package
pkg = default_mock_concretization("pkg-a").package
pkg.has_code = False
pkg.do_fetch()
@ -552,7 +552,7 @@ def test_fetch_external_package_is_noop(
default_mock_concretization, install_mockery, fetching_not_allowed
):
"""do_fetch for packages without code should be a no-op"""
spec = default_mock_concretization("a")
spec = default_mock_concretization("pkg-a")
spec.external_path = "/some/where"
assert spec.external
spec.package.do_fetch()

View file

@ -9,6 +9,8 @@
import spack.package_base
import spack.paths
import spack.repo
import spack.spec
import spack.util.file_cache
@pytest.fixture(params=["packages", "", "foo"])
@ -30,25 +32,25 @@ def extra_repo(tmpdir_factory, request):
def test_repo_getpkg(mutable_mock_repo):
mutable_mock_repo.get_pkg_class("a")
mutable_mock_repo.get_pkg_class("builtin.mock.a")
mutable_mock_repo.get_pkg_class("pkg-a")
mutable_mock_repo.get_pkg_class("builtin.mock.pkg-a")
def test_repo_multi_getpkg(mutable_mock_repo, extra_repo):
mutable_mock_repo.put_first(extra_repo[0])
mutable_mock_repo.get_pkg_class("a")
mutable_mock_repo.get_pkg_class("builtin.mock.a")
mutable_mock_repo.get_pkg_class("pkg-a")
mutable_mock_repo.get_pkg_class("builtin.mock.pkg-a")
def test_repo_multi_getpkgclass(mutable_mock_repo, extra_repo):
mutable_mock_repo.put_first(extra_repo[0])
mutable_mock_repo.get_pkg_class("a")
mutable_mock_repo.get_pkg_class("builtin.mock.a")
mutable_mock_repo.get_pkg_class("pkg-a")
mutable_mock_repo.get_pkg_class("builtin.mock.pkg-a")
def test_repo_pkg_with_unknown_namespace(mutable_mock_repo):
with pytest.raises(spack.repo.UnknownNamespaceError):
mutable_mock_repo.get_pkg_class("unknown.a")
mutable_mock_repo.get_pkg_class("unknown.pkg-a")
def test_repo_unknown_pkg(mutable_mock_repo):
@ -142,14 +144,14 @@ def test_get_all_mock_packages(mock_packages):
def test_repo_path_handles_package_removal(tmpdir, mock_packages):
builder = spack.repo.MockRepositoryBuilder(tmpdir, namespace="removal")
builder.add_package("c")
builder.add_package("pkg-c")
with spack.repo.use_repositories(builder.root, override=False) as repos:
r = repos.repo_for_pkg("c")
r = repos.repo_for_pkg("pkg-c")
assert r.namespace == "removal"
builder.remove("c")
builder.remove("pkg-c")
with spack.repo.use_repositories(builder.root, override=False) as repos:
r = repos.repo_for_pkg("c")
r = repos.repo_for_pkg("pkg-c")
assert r.namespace == "builtin.mock"

View file

@ -138,19 +138,19 @@ def test_specify_preinstalled_dep(tmpdir, monkeypatch):
transitive dependency that is only supplied by the preinstalled package.
"""
builder = spack.repo.MockRepositoryBuilder(tmpdir)
builder.add_package("c")
builder.add_package("b", dependencies=[("c", None, None)])
builder.add_package("a", dependencies=[("b", None, None)])
builder.add_package("pkg-c")
builder.add_package("pkg-b", dependencies=[("pkg-c", None, None)])
builder.add_package("pkg-a", dependencies=[("pkg-b", None, None)])
with spack.repo.use_repositories(builder.root):
b_spec = Spec("b").concretized()
monkeypatch.setattr(Spec, "installed", property(lambda x: x.name != "a"))
b_spec = Spec("pkg-b").concretized()
monkeypatch.setattr(Spec, "installed", property(lambda x: x.name != "pkg-a"))
a_spec = Spec("a")
a_spec = Spec("pkg-a")
a_spec._add_dependency(b_spec, depflag=dt.BUILD | dt.LINK, virtuals=())
a_spec.concretize()
assert set(x.name for x in a_spec.traverse()) == set(["a", "b", "c"])
assert {x.name for x in a_spec.traverse()} == {"pkg-a", "pkg-b", "pkg-c"}
@pytest.mark.usefixtures("config")
@ -982,15 +982,15 @@ def test_synthetic_construction_of_split_dependencies_from_same_package(mock_pac
# Construct in a synthetic way (i.e. without using the solver)
# the following spec:
#
# b
# pkg-b
# build / \ link,run
# c@2.0 c@1.0
# pkg-c@2.0 pkg-c@1.0
#
# To demonstrate that a spec can now hold two direct
# dependencies from the same package
root = Spec("b").concretized()
link_run_spec = Spec("c@=1.0").concretized()
build_spec = Spec("c@=2.0").concretized()
root = Spec("pkg-b").concretized()
link_run_spec = Spec("pkg-c@=1.0").concretized()
build_spec = Spec("pkg-c@=2.0").concretized()
root.add_dependency_edge(link_run_spec, depflag=dt.LINK, virtuals=())
root.add_dependency_edge(link_run_spec, depflag=dt.RUN, virtuals=())
@ -998,10 +998,10 @@ def test_synthetic_construction_of_split_dependencies_from_same_package(mock_pac
# Check dependencies from the perspective of root
assert len(root.dependencies()) == 2
assert all(x.name == "c" for x in root.dependencies())
assert all(x.name == "pkg-c" for x in root.dependencies())
assert "@2.0" in root.dependencies(name="c", deptype=dt.BUILD)[0]
assert "@1.0" in root.dependencies(name="c", deptype=dt.LINK | dt.RUN)[0]
assert "@2.0" in root.dependencies(name="pkg-c", deptype=dt.BUILD)[0]
assert "@1.0" in root.dependencies(name="pkg-c", deptype=dt.LINK | dt.RUN)[0]
# Check parent from the perspective of the dependencies
assert len(build_spec.dependents()) == 1
@ -1013,30 +1013,30 @@ def test_synthetic_construction_of_split_dependencies_from_same_package(mock_pac
def test_synthetic_construction_bootstrapping(mock_packages, config):
# Construct the following spec:
#
# b@2.0
# pkg-b@2.0
# | build
# b@1.0
# pkg-b@1.0
#
root = Spec("b@=2.0").concretized()
bootstrap = Spec("b@=1.0").concretized()
root = Spec("pkg-b@=2.0").concretized()
bootstrap = Spec("pkg-b@=1.0").concretized()
root.add_dependency_edge(bootstrap, depflag=dt.BUILD, virtuals=())
assert len(root.dependencies()) == 1
assert root.dependencies()[0].name == "b"
assert root.name == "b"
assert root.dependencies()[0].name == "pkg-b"
assert root.name == "pkg-b"
def test_addition_of_different_deptypes_in_multiple_calls(mock_packages, config):
# Construct the following spec:
#
# b@2.0
# pkg-b@2.0
# | build,link,run
# b@1.0
# pkg-b@1.0
#
# with three calls and check we always have a single edge
root = Spec("b@=2.0").concretized()
bootstrap = Spec("b@=1.0").concretized()
root = Spec("pkg-b@=2.0").concretized()
bootstrap = Spec("pkg-b@=1.0").concretized()
for current_depflag in (dt.BUILD, dt.LINK, dt.RUN):
root.add_dependency_edge(bootstrap, depflag=current_depflag, virtuals=())
@ -1063,9 +1063,9 @@ def test_addition_of_different_deptypes_in_multiple_calls(mock_packages, config)
def test_adding_same_deptype_with_the_same_name_raises(
mock_packages, config, c1_depflag, c2_depflag
):
p = Spec("b@=2.0").concretized()
c1 = Spec("b@=1.0").concretized()
c2 = Spec("b@=2.0").concretized()
p = Spec("pkg-b@=2.0").concretized()
c1 = Spec("pkg-b@=1.0").concretized()
c2 = Spec("pkg-b@=2.0").concretized()
p.add_dependency_edge(c1, depflag=c1_depflag, virtuals=())
with pytest.raises(spack.error.SpackError):

View file

@ -373,7 +373,7 @@ def test_satisfies_single_valued_variant(self):
https://github.com/spack/spack/pull/2386#issuecomment-282147639
is handled correctly.
"""
a = Spec("a foobar=bar")
a = Spec("pkg-a foobar=bar")
a.concretize()
assert a.satisfies("foobar=bar")
@ -390,21 +390,21 @@ def test_satisfies_single_valued_variant(self):
assert "foo=bar" in a
# Check that conditional dependencies are treated correctly
assert "^b" in a
assert "^pkg-b" in a
def test_unsatisfied_single_valued_variant(self):
a = Spec("a foobar=baz")
a = Spec("pkg-a foobar=baz")
a.concretize()
assert "^b" not in a
assert "^pkg-b" not in a
mv = Spec("multivalue-variant")
mv.concretize()
assert "a@1.0" not in mv
assert "pkg-a@1.0" not in mv
def test_indirect_unsatisfied_single_valued_variant(self):
spec = Spec("singlevalue-variant-dependent")
spec.concretize()
assert "a@1.0" not in spec
assert "pkg-a@1.0" not in spec
def test_unsatisfiable_multi_value_variant(self, default_mock_concretization):
# Semantics for a multi-valued variant is different
@ -982,8 +982,8 @@ def test_splice_swap_names_mismatch_virtuals(self, default_mock_concretization,
spec.splice(dep, transitive)
def test_spec_override(self):
init_spec = Spec("a foo=baz foobar=baz cflags=-O3 cxxflags=-O1")
change_spec = Spec("a foo=fee cflags=-O2")
init_spec = Spec("pkg-a foo=baz foobar=baz cflags=-O3 cxxflags=-O1")
change_spec = Spec("pkg-a foo=fee cflags=-O2")
new_spec = Spec.override(init_spec, change_spec)
new_spec.concretize()
assert "foo=fee" in new_spec
@ -1253,15 +1253,15 @@ def test_spec_installed(default_mock_concretization, database):
spec = Spec("not-a-real-package")
assert not spec.installed
# 'a' is not in the mock DB and is not installed
spec = default_mock_concretization("a")
# pkg-a is not in the mock DB and is not installed
spec = default_mock_concretization("pkg-a")
assert not spec.installed
@pytest.mark.regression("30678")
def test_call_dag_hash_on_old_dag_hash_spec(mock_packages, default_mock_concretization):
# create a concrete spec
a = default_mock_concretization("a")
a = default_mock_concretization("pkg-a")
dag_hashes = {spec.name: spec.dag_hash() for spec in a.traverse()}
# make it look like an old DAG hash spec with no package hash on the spec.
@ -1309,8 +1309,8 @@ def test_unsupported_compiler():
def test_package_hash_affects_dunder_and_dag_hash(mock_packages, default_mock_concretization):
a1 = default_mock_concretization("a")
a2 = default_mock_concretization("a")
a1 = default_mock_concretization("pkg-a")
a2 = default_mock_concretization("pkg-a")
assert hash(a1) == hash(a2)
assert a1.dag_hash() == a2.dag_hash()
@ -1334,8 +1334,8 @@ def test_intersects_and_satisfies_on_concretized_spec(default_mock_concretizatio
"""Test that a spec obtained by concretizing an abstract spec, satisfies the abstract spec
but not vice-versa.
"""
a1 = default_mock_concretization("a@1.0")
a2 = Spec("a@1.0")
a1 = default_mock_concretization("pkg-a@1.0")
a2 = Spec("pkg-a@1.0")
assert a1.intersects(a2)
assert a2.intersects(a1)
@ -1461,17 +1461,17 @@ def test_constrain(factory, lhs_str, rhs_str, result, constrained_str):
def test_abstract_hash_intersects_and_satisfies(default_mock_concretization):
concrete: Spec = default_mock_concretization("a")
concrete: Spec = default_mock_concretization("pkg-a")
hash = concrete.dag_hash()
hash_5 = hash[:5]
hash_6 = hash[:6]
# abstract hash that doesn't have a common prefix with the others.
hash_other = f"{'a' if hash_5[0] == 'b' else 'b'}{hash_5[1:]}"
abstract_5 = Spec(f"a/{hash_5}")
abstract_6 = Spec(f"a/{hash_6}")
abstract_none = Spec(f"a/{hash_other}")
abstract = Spec("a")
abstract_5 = Spec(f"pkg-a/{hash_5}")
abstract_6 = Spec(f"pkg-a/{hash_6}")
abstract_none = Spec(f"pkg-a/{hash_other}")
abstract = Spec("pkg-a")
def assert_subset(a: Spec, b: Spec):
assert a.intersects(b) and b.intersects(a) and a.satisfies(b) and not b.satisfies(a)
@ -1508,6 +1508,6 @@ def test_edge_equality_does_not_depend_on_virtual_order():
def test_old_format_strings_trigger_error(default_mock_concretization):
s = Spec("a").concretized()
s = Spec("pkg-a").concretized()
with pytest.raises(SpecFormatStringError):
s.format("${PACKAGE}-${VERSION}-${HASH}")

View file

@ -699,7 +699,7 @@ def test_spec_by_hash_tokens(text, tokens):
@pytest.mark.db
def test_spec_by_hash(database, monkeypatch, config):
mpileaks = database.query_one("mpileaks ^zmpi")
b = spack.spec.Spec("b").concretized()
b = spack.spec.Spec("pkg-b").concretized()
monkeypatch.setattr(spack.binary_distribution, "update_cache_and_get_specs", lambda: [b])
hash_str = f"/{mpileaks.dag_hash()}"
@ -796,7 +796,7 @@ def test_ambiguous_hash(mutable_database, default_mock_concretization, config):
In the past this ambiguity error would happen during parse time."""
# This is a very sketchy as manually setting hashes easily breaks invariants
x1 = default_mock_concretization("a")
x1 = spack.spec.Spec("pkg-a").concretized()
x2 = x1.copy()
x1._hash = "xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
x1._process_hash = "xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
@ -814,7 +814,7 @@ def test_ambiguous_hash(mutable_database, default_mock_concretization, config):
s1.lookup_hash()
# ambiguity in first hash character AND spec name
s2 = SpecParser("a/x").next_spec()
s2 = SpecParser("pkg-a/x").next_spec()
with pytest.raises(spack.spec.AmbiguousHashError):
s2.lookup_hash()

View file

@ -314,23 +314,23 @@ def test_save_dependency_spec_jsons_subset(tmpdir, config):
output_path = str(tmpdir.mkdir("spec_jsons"))
builder = spack.repo.MockRepositoryBuilder(tmpdir.mkdir("mock-repo"))
builder.add_package("g")
builder.add_package("f")
builder.add_package("e")
builder.add_package("d", dependencies=[("f", None, None), ("g", None, None)])
builder.add_package("c")
builder.add_package("b", dependencies=[("d", None, None), ("e", None, None)])
builder.add_package("a", dependencies=[("b", None, None), ("c", None, None)])
builder.add_package("pkg-g")
builder.add_package("pkg-f")
builder.add_package("pkg-e")
builder.add_package("pkg-d", dependencies=[("pkg-f", None, None), ("pkg-g", None, None)])
builder.add_package("pkg-c")
builder.add_package("pkg-b", dependencies=[("pkg-d", None, None), ("pkg-e", None, None)])
builder.add_package("pkg-a", dependencies=[("pkg-b", None, None), ("pkg-c", None, None)])
with spack.repo.use_repositories(builder.root):
spec_a = Spec("a").concretized()
b_spec = spec_a["b"]
c_spec = spec_a["c"]
spec_a = Spec("pkg-a").concretized()
b_spec = spec_a["pkg-b"]
c_spec = spec_a["pkg-c"]
save_dependency_specfiles(spec_a, output_path, [Spec("b"), Spec("c")])
save_dependency_specfiles(spec_a, output_path, [Spec("pkg-b"), Spec("pkg-c")])
assert check_specs_equal(b_spec, os.path.join(output_path, "b.json"))
assert check_specs_equal(c_spec, os.path.join(output_path, "c.json"))
assert check_specs_equal(b_spec, os.path.join(output_path, "pkg-b.json"))
assert check_specs_equal(c_spec, os.path.join(output_path, "pkg-c.json"))
def test_legacy_yaml(tmpdir, install_mockery, mock_packages):

View file

@ -519,7 +519,7 @@ def test_find_required_file(tmpdir):
def test_packagetest_fails(mock_packages):
MyPackage = collections.namedtuple("MyPackage", ["spec"])
s = spack.spec.Spec("a")
s = spack.spec.Spec("pkg-a")
pkg = MyPackage(s)
with pytest.raises(ValueError, match="require a concrete package"):
spack.install_test.PackageTest(pkg)

View file

@ -33,8 +33,8 @@ def test_view_with_spec_not_contributing_files(mock_packages, tmpdir):
layout = DirectoryLayout(view_dir)
view = SimpleFilesystemView(view_dir, layout)
a = Spec("a")
b = Spec("b")
a = Spec("pkg-a")
b = Spec("pkg-b")
a.prefix = os.path.join(tmpdir, "a")
b.prefix = os.path.join(tmpdir, "b")
a._mark_concrete()

View file

@ -14,7 +14,7 @@ class Depb(AutotoolsPackage):
version("1.0", md5="0123456789abcdef0123456789abcdef")
depends_on("b")
depends_on("pkg-b")
def install(self, spec, prefix):
# sanity_check_prefix requires something in the install directory

View file

@ -15,4 +15,4 @@ class ExternalBuildableWithVariant(Package):
variant("baz", default=False, description="nope")
depends_on("c@1.0", when="@0.9")
depends_on("pkg-c@1.0", when="@0.9")

View file

@ -18,4 +18,4 @@ class MissingDependency(Package):
depends_on("this-is-a-missing-dependency")
# this one is a "real" mock dependency
depends_on("a")
depends_on("pkg-a")

View file

@ -40,5 +40,5 @@ class MultivalueVariant(Package):
depends_on("mpi")
depends_on("callpath")
depends_on("a")
depends_on("a@1.0", when="fee=barbaz")
depends_on("pkg-a")
depends_on("pkg-a@1.0", when="fee=barbaz")

View file

@ -16,5 +16,5 @@ class OptionalDepTest3(Package):
variant("var", default=False)
depends_on("a", when="~var")
depends_on("b", when="+var")
depends_on("pkg-a", when="~var")
depends_on("pkg-b", when="+var")

View file

@ -19,14 +19,14 @@ class OptionalDepTest(Package):
variant("f", default=False)
variant("mpi", default=False)
depends_on("a", when="+a")
depends_on("b", when="@1.1")
depends_on("c", when="%intel")
depends_on("d", when="%intel@64.1")
depends_on("e", when="%clang@34:40")
depends_on("pkg-a", when="+a")
depends_on("pkg-b", when="@1.1")
depends_on("pkg-c", when="%intel")
depends_on("pkg-d", when="%intel@64.1")
depends_on("pkg-e", when="%clang@34:40")
depends_on("f", when="+f")
depends_on("g", when="^f")
depends_on("mpi", when="^g")
depends_on("pkg-f", when="+f")
depends_on("pkg-g", when="^pkg-f")
depends_on("mpi", when="^pkg-g")
depends_on("mpi", when="+mpi")

View file

@ -6,7 +6,7 @@
from spack.package import *
class A(AutotoolsPackage):
class PkgA(AutotoolsPackage):
"""Simple package with one optional dependency"""
homepage = "http://www.example.com"
@ -25,7 +25,7 @@ class A(AutotoolsPackage):
variant("bvv", default=True, description="The good old BV variant")
depends_on("b", when="foobar=bar")
depends_on("pkg-b", when="foobar=bar")
depends_on("test-dependency", type="test")
parallel = False

View file

@ -6,7 +6,7 @@
from spack.package import *
class B(Package):
class PkgB(Package):
"""Simple package with no dependencies"""
homepage = "http://www.example.com"

View file

@ -6,7 +6,7 @@
from spack.package import *
class C(Package):
class PkgC(Package):
"""Simple package with no dependencies"""
homepage = "http://www.example.com"

View file

@ -6,7 +6,7 @@
from spack.package import *
class E(Package):
class PkgE(Package):
"""Simple package with no dependencies"""
homepage = "http://www.example.com"

View file

@ -14,4 +14,4 @@ class TestDepWithImposedConditions(Package):
version("1.0", md5="0123456789abcdef0123456789abcdef")
depends_on("c@1.0", type="test")
depends_on("pkg-c@1.0", type="test")

View file

@ -15,5 +15,5 @@ class Vendorsb(Package):
version("1.1", md5="0123456789abcdef0123456789abcdef")
version("1.0", md5="0123456789abcdef0123456789abcdef")
# b is not a dependency
conflicts("b", when="@=1.1")
# pkg-b is not a dependency
conflicts("pkg-b", when="@=1.1")

View file

@ -20,7 +20,7 @@ class WhenDirectivesFalse(Package):
when=False,
)
extends("extendee", when=False)
depends_on("b", when=False)
depends_on("pkg-b", when=False)
conflicts("@1.0", when=False)
resource(
url="http://www.example.com/example-1.0-resource.tar.gz",

View file

@ -20,7 +20,7 @@ class WhenDirectivesTrue(Package):
when=True,
)
extends("extendee", when=True)
depends_on("b", when=True)
depends_on("pkg-b", when=True)
conflicts("@1.0", when=True)
resource(
url="http://www.example.com/example-1.0-resource.tar.gz",

View file

@ -16,8 +16,8 @@ class WithConstraintMet(Package):
version("1.0", md5="0123456789abcdef0123456789abcdef")
with when("@1.0"):
depends_on("b")
depends_on("pkg-b")
conflicts("%gcc", when="+foo")
with when("@0.14: ^b@:4.0"):
depends_on("c", when="@:15 ^b@3.8:")
with when("@0.14: ^pkg-b@:4.0"):
depends_on("pkg-c", when="@:15 ^pkg-b@3.8:")

View file

@ -13,4 +13,4 @@ class WrongVariantInDependsOn(Package):
version("1.0", md5="0123456789abcdef0123456789abcdef")
depends_on("b+doesnotexist")
depends_on("pkg-b+doesnotexist")