add environment-awareness to buildcache create
(#16580)
* add buildcache create test * add functionality and test to create buildcache from environment * use env.concretized_user_specs rather than env.roots to get concretized specs, as suggested in review from becker33
This commit is contained in:
parent
ec108dbebd
commit
1602b7a561
@ -338,10 +338,14 @@ def _createtarball(env, spec_yaml, packages, add_spec, add_deps,
|
|||||||
elif packages:
|
elif packages:
|
||||||
packages = packages
|
packages = packages
|
||||||
|
|
||||||
|
elif env:
|
||||||
|
packages = env.concretized_user_specs
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tty.die("build cache file creation requires at least one" +
|
tty.die("build cache file creation requires at least one" +
|
||||||
" installed package argument or else path to a" +
|
" installed package spec, an activate environment," +
|
||||||
" yaml file containing a spec to install")
|
" or else a path to a yaml file containing a spec" +
|
||||||
|
" to install")
|
||||||
pkgs = set(packages)
|
pkgs = set(packages)
|
||||||
specs = set()
|
specs = set()
|
||||||
|
|
||||||
|
@ -5,14 +5,19 @@
|
|||||||
|
|
||||||
import errno
|
import errno
|
||||||
import platform
|
import platform
|
||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import spack.main
|
import spack.main
|
||||||
import spack.binary_distribution
|
import spack.binary_distribution
|
||||||
|
import spack.environment as ev
|
||||||
|
from spack.spec import Spec
|
||||||
|
|
||||||
buildcache = spack.main.SpackCommand('buildcache')
|
buildcache = spack.main.SpackCommand('buildcache')
|
||||||
install = spack.main.SpackCommand('install')
|
install = spack.main.SpackCommand('install')
|
||||||
|
env = spack.main.SpackCommand('env')
|
||||||
|
add = spack.main.SpackCommand('add')
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
@ -45,6 +50,52 @@ def test_buildcache_list_duplicates(mock_get_specs, capsys):
|
|||||||
assert output.count('mpileaks') == 3
|
assert output.count('mpileaks') == 3
|
||||||
|
|
||||||
|
|
||||||
|
def tests_buildcache_create(
|
||||||
|
install_mockery, mock_fetch, monkeypatch, tmpdir):
|
||||||
|
""""Ensure that buildcache create creates output files"""
|
||||||
|
pkg = 'trivial-install-test-package'
|
||||||
|
install(pkg)
|
||||||
|
|
||||||
|
buildcache('create', '-d', str(tmpdir), '--unsigned', pkg)
|
||||||
|
|
||||||
|
spec = Spec(pkg).concretized()
|
||||||
|
tarball_path = spack.binary_distribution.tarball_path_name(spec, '.spack')
|
||||||
|
tarball = spack.binary_distribution.tarball_name(spec, '.spec.yaml')
|
||||||
|
assert os.path.exists(
|
||||||
|
os.path.join(str(tmpdir), 'build_cache', tarball_path))
|
||||||
|
assert os.path.exists(
|
||||||
|
os.path.join(str(tmpdir), 'build_cache', tarball))
|
||||||
|
|
||||||
|
|
||||||
|
def tests_buildcache_create_env(
|
||||||
|
install_mockery, mock_fetch, monkeypatch,
|
||||||
|
tmpdir, mutable_mock_env_path):
|
||||||
|
""""Ensure that buildcache create creates output files from env"""
|
||||||
|
pkg = 'trivial-install-test-package'
|
||||||
|
|
||||||
|
env('create', 'test')
|
||||||
|
with ev.read('test'):
|
||||||
|
add(pkg)
|
||||||
|
install()
|
||||||
|
|
||||||
|
buildcache('create', '-d', str(tmpdir), '--unsigned')
|
||||||
|
|
||||||
|
spec = Spec(pkg).concretized()
|
||||||
|
tarball_path = spack.binary_distribution.tarball_path_name(spec, '.spack')
|
||||||
|
tarball = spack.binary_distribution.tarball_name(spec, '.spec.yaml')
|
||||||
|
assert os.path.exists(
|
||||||
|
os.path.join(str(tmpdir), 'build_cache', tarball_path))
|
||||||
|
assert os.path.exists(
|
||||||
|
os.path.join(str(tmpdir), 'build_cache', tarball))
|
||||||
|
|
||||||
|
|
||||||
|
def test_buildcache_create_fails_on_noargs(tmpdir):
|
||||||
|
"""Ensure that buildcache create fails when given no args or
|
||||||
|
environment."""
|
||||||
|
with pytest.raises(spack.main.SpackCommandError):
|
||||||
|
buildcache('create', '-d', str(tmpdir), '--unsigned')
|
||||||
|
|
||||||
|
|
||||||
def test_buildcache_create_fail_on_perm_denied(
|
def test_buildcache_create_fail_on_perm_denied(
|
||||||
install_mockery, mock_fetch, monkeypatch, tmpdir):
|
install_mockery, mock_fetch, monkeypatch, tmpdir):
|
||||||
"""Ensure that buildcache create fails on permission denied error."""
|
"""Ensure that buildcache create fails on permission denied error."""
|
||||||
|
Loading…
Reference in New Issue
Block a user