Compare commits

...

7 Commits

Author SHA1 Message Date
Gregory Becker
1aa900668d rework test to parametrize by order and depth of dev spec 2022-03-09 09:54:41 -08:00
psakiev
76da5a1141 Unit test changes 2022-03-08 16:20:34 -07:00
psakiev
6d9a214339 style 2022-03-08 14:16:45 -07:00
psakiev
17713c0151 Remove unneccessary work due to mock_fetch 2022-03-08 14:16:45 -07:00
psakiev
f383ca40db WIP: Add some unit tests 2022-03-08 14:16:45 -07:00
Gregory Becker
453d36ca00 do not allow dev specs to be reused 2022-03-08 14:16:45 -07:00
psakiev
eb95a50e08 Fix to concretize.lp 2022-03-08 14:16:45 -07:00
3 changed files with 40 additions and 4 deletions

View File

@@ -1668,12 +1668,14 @@ def define_installed_packages(self, specs, possible):
# Specs from local store
with spack.store.db.read_transaction():
for spec in spack.store.db.query(installed=True):
if not spec.satisfies('dev_path=*'):
self._facts_from_concrete_spec(spec, possible)
# Specs from configured buildcaches
try:
index = spack.binary_distribution.update_cache_and_get_specs()
for spec in index:
if not spec.satisfies('dev_path=*'):
self._facts_from_concrete_spec(spec, possible)
except (spack.binary_distribution.FetchCacheError, IndexError):
# this is raised when no mirrors had indices.

View File

@@ -827,6 +827,9 @@ no_flags(Package, FlagType)
{ hash(Package, Hash) : installed_hash(Package, Hash) } 1
:- node(Package), error("Internal error: package must resolve to at most one hash").
% you can't choose an installed hash for a dev spec
:- hash(Package, Hash), variant_set(Package, "dev_path", _).
% if a hash is selected, we impose all the constraints that implies
impose(Hash) :- hash(Package, Hash).

View File

@@ -332,7 +332,6 @@ def concretize_difficult_packages(self, a, b):
assert s[a].version == ver(b)
def test_concretize_two_virtuals(self):
"""Test a package with multiple virtual dependencies."""
Spec('hypre').concretize()
@@ -1138,6 +1137,38 @@ def test_external_package_versions(self, spec_str, is_external, expected):
assert s.external == is_external
assert s.satisfies(expected)
@pytest.mark.parametrize('dev_first,spec', [
(True, 'dev-build-test-install'),
(True, 'dev-build-test-dependent'),
(False, 'dev-build-test-install'),
(False, 'dev-build-test-dependent')
])
def test_reuse_does_not_overwrite_dev_specs(
self, dev_first, spec, tmpdir, mock_packages, install_mockery, mock_fetch):
"""Test that reuse does not mix dev specs with non-dev specs.
Tests for either order (dev specs are not reused for non-dev, and
non-dev specs are not reused for dev specs)
Tests for a spec in which the root is developed and a spec in
which a dep is developed."""
# dev and non-dev specs that are otherwise identical
spec = Spec(spec).normalized() # ensure dependencies present
dev_spec = spec.copy()
dev_constraint = 'dev_path=%s' % tmpdir.strpath
dev_spec['dev-build-test-install'].constrain(dev_constraint)
# run the test in both orders
first_spec = dev_spec if dev_first else spec
second_spec = spec if dev_first else dev_spec
# concretize and install a non-dev version
first_spec.concretize()
first_spec.package.do_install(fake=True)
# concretize a dev version
with spack.config.override("concretizer:reuse", True):
second_spec.concretize()
assert first_spec.dag_hash() != second_spec.dag_hash()
@pytest.mark.regression('20292')
@pytest.mark.parametrize('context', [
{'add_variant': True, 'delete_variant': False},
@@ -1145,7 +1176,7 @@ def test_external_package_versions(self, spec_str, is_external, expected):
{'add_variant': True, 'delete_variant': True}
])
@pytest.mark.xfail()
def test_reuse_installed_packages(
def test_reuse_installed_packages_when_package_def_changes(
self, context, mutable_database, repo_with_changing_recipe
):
# Install a spec