Add lookup check tests
This commit is contained in:
parent
b4269ff8f1
commit
a5f0ba5692
@ -3101,6 +3101,14 @@ def setup(
|
|||||||
if node.namespace is not None:
|
if node.namespace is not None:
|
||||||
self.explicitly_required_namespaces[node.name] = node.namespace
|
self.explicitly_required_namespaces[node.name] = node.namespace
|
||||||
|
|
||||||
|
# abstract specs with commit variants are assigend version most likely to have commit sha
|
||||||
|
for spec in specs:
|
||||||
|
version = spec.versions.concrete_range_as_version
|
||||||
|
if not version:
|
||||||
|
version = max(spack.repo.PATH.get_pkg_class(spec.fullname).versions.keys())
|
||||||
|
spec.versions = spack.version.VersionList([version])
|
||||||
|
|
||||||
|
|
||||||
self.gen = ProblemInstanceBuilder()
|
self.gen = ProblemInstanceBuilder()
|
||||||
compiler_parser = CompilerParser(configuration=spack.config.CONFIG).with_input_specs(specs)
|
compiler_parser = CompilerParser(configuration=spack.config.CONFIG).with_input_specs(specs)
|
||||||
|
|
||||||
@ -3128,7 +3136,6 @@ def setup(
|
|||||||
specs = tuple(specs) # ensure compatible types to add
|
specs = tuple(specs) # ensure compatible types to add
|
||||||
|
|
||||||
self.gen.h1("Reusable concrete specs")
|
self.gen.h1("Reusable concrete specs")
|
||||||
# TODO(psakiev) need fact spec has commit
|
|
||||||
self.define_concrete_input_specs(specs, self.pkgs)
|
self.define_concrete_input_specs(specs, self.pkgs)
|
||||||
if reuse:
|
if reuse:
|
||||||
self.gen.fact(fn.optimize_for_reuse())
|
self.gen.fact(fn.optimize_for_reuse())
|
||||||
@ -4219,6 +4226,7 @@ def _specs_with_commits(spec):
|
|||||||
if not spec.version.commit_sha:
|
if not spec.version.commit_sha:
|
||||||
# TODO(psakiev) this will be a failure when commit look up is automated
|
# TODO(psakiev) this will be a failure when commit look up is automated
|
||||||
return
|
return
|
||||||
|
if not "commit" in spec.variants:
|
||||||
spec.variants["commit"] = vt.SingleValuedVariant("commit", spec.version.commit_sha)
|
spec.variants["commit"] = vt.SingleValuedVariant("commit", spec.version.commit_sha)
|
||||||
|
|
||||||
|
|
||||||
|
@ -617,7 +617,7 @@ def _nresults(_qresult):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("install_mockery", "mock_fetch", "mutable_mock_env_path")
|
@pytest.mark.usefixtures("install_mockery", "mock_fetch", "mutable_mock_env_path")
|
||||||
def test_phil_add_find_based_on_commit_sha(mock_git_version_info, monkeypatch):
|
def test_find_based_on_commit_sha(mock_git_version_info, monkeypatch):
|
||||||
repo_path, filename, commits = mock_git_version_info
|
repo_path, filename, commits = mock_git_version_info
|
||||||
file_url = pathlib.Path(repo_path).as_uri()
|
file_url = pathlib.Path(repo_path).as_uri()
|
||||||
|
|
||||||
|
@ -2729,13 +2729,13 @@ def test_correct_external_is_selected_from_packages_yaml(self, mutable_config):
|
|||||||
assert s.satisfies("%clang")
|
assert s.satisfies("%clang")
|
||||||
assert s.prefix == "/tmp/prefix2"
|
assert s.prefix == "/tmp/prefix2"
|
||||||
|
|
||||||
def test_phil_add_git_based_version_must_exist_to_use_ref(self):
|
def test_git_based_version_must_exist_to_use_ref(self):
|
||||||
# gmake should fail, only has sha256
|
# gmake should fail, only has sha256
|
||||||
with pytest.raises(spack.error.UnsatisfiableSpecError) as e:
|
with pytest.raises(spack.error.UnsatisfiableSpecError) as e:
|
||||||
s = spack.concretize.concretize_one(f"gmake commit={'a' * 40}")
|
s = spack.concretize.concretize_one(f"gmake commit={'a' * 40}")
|
||||||
assert "Cannot use commit variant with" in e.value.message
|
assert "Cannot use commit variant with" in e.value.message
|
||||||
|
|
||||||
def test_phil_add_commit_variant_in_absence_of_version_selects_max_infinity_version(self):
|
def test_commit_variant_in_absence_of_version_selects_max_infinity_version(self):
|
||||||
spec = spack.concretize.concretize_one(f"git-ref-package commit={'a' * 40}")
|
spec = spack.concretize.concretize_one(f"git-ref-package commit={'a' * 40}")
|
||||||
assert spec.satisfies("@develop")
|
assert spec.satisfies("@develop")
|
||||||
|
|
||||||
@ -3277,11 +3277,10 @@ def test_spec_unification(unify, mutable_config, mock_packages):
|
|||||||
(f"git-ref-package@main commit={'a' * 39}", AssertionError),
|
(f"git-ref-package@main commit={'a' * 39}", AssertionError),
|
||||||
(f"git-ref-package@2.1.6 commit={'a' * 40}", spack.error.UnsatisfiableSpecError),
|
(f"git-ref-package@2.1.6 commit={'a' * 40}", spack.error.UnsatisfiableSpecError),
|
||||||
(f"git-ref-package@git.2.1.6=2.1.6 commit={'a' * 40}", None),
|
(f"git-ref-package@git.2.1.6=2.1.6 commit={'a' * 40}", None),
|
||||||
# TODO(psakiev): need to monkeypatch git so this case doesn't query the web
|
(f"git-ref-package@git.{'a' * 40}=2.1.6 commit={'a' * 40}", None),
|
||||||
# (f"git-ref-package@git.2.1.6 commit={'a' * 40}", None),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_spec_containing_commit_variant(spec_str, error_type):
|
def test_phil_spec_containing_commit_variant(spec_str, error_type):
|
||||||
spec = spack.spec.Spec(spec_str)
|
spec = spack.spec.Spec(spec_str)
|
||||||
if error_type is None:
|
if error_type is None:
|
||||||
spack.concretize.concretize_one(spec)
|
spack.concretize.concretize_one(spec)
|
||||||
@ -3290,6 +3289,30 @@ def test_spec_containing_commit_variant(spec_str, error_type):
|
|||||||
spack.concretize.concretize_one(spec)
|
spack.concretize.concretize_one(spec)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mutable_config", "mock_packages", "do_not_check_runtimes_on_reuse")
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"spec_str, error_type",
|
||||||
|
[
|
||||||
|
(f"git-test-commit@git.main commit={'a' * 40}", None),
|
||||||
|
(f"git-test-commit@git.v1.0 commit={'a' * 40}", None),
|
||||||
|
("git-test-commit@{sha} commit={sha}", None),
|
||||||
|
("git-test-commit@{sha} commit=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", None),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_phil_spec_with_commit_interacts_with_lookup(mock_git_version_info, monkeypatch, spec_str, error_type):
|
||||||
|
# This test will be short lived. Technically we could do further checks with a Lookup
|
||||||
|
# but skipping impl since we are going to deprecate
|
||||||
|
repo_path, filename, commits = mock_git_version_info
|
||||||
|
file_url = pathlib.Path(repo_path).as_uri()
|
||||||
|
monkeypatch.setattr(spack.package_base.PackageBase, "git", file_url, raising=False)
|
||||||
|
spec = spack.spec.Spec(spec_str.format(sha = commits[-1]))
|
||||||
|
if error_type is None:
|
||||||
|
spack.concretize.concretize_one(spec)
|
||||||
|
else:
|
||||||
|
with pytest.raises(error_type):
|
||||||
|
spack.concretize.concretize_one(spec)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("mutable_config", "mock_packages", "do_not_check_runtimes_on_reuse")
|
@pytest.mark.usefixtures("mutable_config", "mock_packages", "do_not_check_runtimes_on_reuse")
|
||||||
@pytest.mark.parametrize("version_str", [f"git.{'a' * 40}=main", "git.2.1.5=main"])
|
@pytest.mark.parametrize("version_str", [f"git.{'a' * 40}=main", "git.2.1.5=main"])
|
||||||
def test_relationship_git_versions_and_commit_variant(version_str):
|
def test_relationship_git_versions_and_commit_variant(version_str):
|
||||||
|
Loading…
Reference in New Issue
Block a user