Add unit-tests to verify requirements
This commit is contained in:
parent
d94892493b
commit
0dcc164346
@ -8,6 +8,7 @@
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
|
||||
import pathlib
|
||||
import pytest
|
||||
|
||||
import spack.cmd as cmd
|
||||
@ -612,3 +613,18 @@ def _nresults(_qresult):
|
||||
assert _nresults(_query(e, "--tag=tag0")) == (1, 0)
|
||||
assert _nresults(_query(e, "--tag=tag1")) == (1, 1)
|
||||
assert _nresults(_query(e, "--tag=tag2")) == (0, 1)
|
||||
|
||||
|
||||
@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):
|
||||
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)
|
||||
|
||||
env("create", "test")
|
||||
with ev.read("test") as e:
|
||||
install("--fake", "--add", f"git-test-commit commit={commits[0]}")
|
||||
|
||||
output = find(f"commit={commits[0]}")
|
||||
assert "git-test-commit" in output
|
||||
|
@ -6,6 +6,7 @@
|
||||
import sys
|
||||
|
||||
import jinja2
|
||||
import pathlib
|
||||
import pytest
|
||||
|
||||
import archspec.cpu
|
||||
@ -2727,6 +2728,32 @@ def test_correct_external_is_selected_from_packages_yaml(self, mutable_config):
|
||||
assert s.satisfies("%clang")
|
||||
assert s.prefix == "/tmp/prefix2"
|
||||
|
||||
def test_phil_add_git_based_version_must_exist_to_use_ref(self):
|
||||
s = spack.concretize.concretize_one(f"git-ref-package commit={'a' * 40}")
|
||||
assert s.satisifes("@main")
|
||||
|
||||
#gmake should fail, only has sha256
|
||||
with pytest.raises(AssertionError):
|
||||
s = spack.concretize.concretize_one(f"gmake={'a' * 40}")
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mutable_config", "mock_packages", "do_not_check_runtimes_on_reuse")
|
||||
def test_phil_add_git_based_version_commit_must_be_valid(mock_git_version_info, monkeypatch):
|
||||
"""Test installing a git package from a commit.
|
||||
|
||||
This ensures Spack associates commit versions with their packages in time to do
|
||||
version lookups. Details of version lookup tested elsewhere.
|
||||
|
||||
"""
|
||||
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)
|
||||
|
||||
spack.concretize.concretize_one(f"git-test-commit@main commit={commits[0]}")
|
||||
with pytest.raises(AssertionError):
|
||||
spack.concretize.concretize_one(f"git-test-commit@main commit={'a' * 40}")
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def duplicates_test_repository():
|
||||
|
@ -11,6 +11,7 @@ class GitTestCommit(Package):
|
||||
homepage = "http://www.git-fetch-example.com"
|
||||
# git='to-be-filled-in-by-test'
|
||||
|
||||
version("main", branch="main")
|
||||
version("1.0", tag="v1.0")
|
||||
version("1.1", tag="v1.1")
|
||||
version("1.2", tag="1.2") # not a typo
|
||||
|
Loading…
Reference in New Issue
Block a user