summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/cmd/buildcache.py
diff options
context:
space:
mode:
authorJeffrey Salmond <js947@users.noreply.github.com>2020-06-26 16:01:12 +0100
committerGitHub <noreply@github.com>2020-06-26 10:01:12 -0500
commit1602b7a56192c23fb7fc110a1c8a17ec0837bdd3 (patch)
tree24ae56b5c740822f2175943c9eddcfd65d583b4a /lib/spack/spack/test/cmd/buildcache.py
parentec108dbebdbb00ab517dd8f84dbb976d6078a93a (diff)
downloadspack-1602b7a56192c23fb7fc110a1c8a17ec0837bdd3.tar.gz
spack-1602b7a56192c23fb7fc110a1c8a17ec0837bdd3.tar.bz2
spack-1602b7a56192c23fb7fc110a1c8a17ec0837bdd3.tar.xz
spack-1602b7a56192c23fb7fc110a1c8a17ec0837bdd3.zip
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
Diffstat (limited to 'lib/spack/spack/test/cmd/buildcache.py')
-rw-r--r--lib/spack/spack/test/cmd/buildcache.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/spack/spack/test/cmd/buildcache.py b/lib/spack/spack/test/cmd/buildcache.py
index 03d09b9771..af02d2d097 100644
--- a/lib/spack/spack/test/cmd/buildcache.py
+++ b/lib/spack/spack/test/cmd/buildcache.py
@@ -5,14 +5,19 @@
import errno
import platform
+import os
import pytest
import spack.main
import spack.binary_distribution
+import spack.environment as ev
+from spack.spec import Spec
buildcache = spack.main.SpackCommand('buildcache')
install = spack.main.SpackCommand('install')
+env = spack.main.SpackCommand('env')
+add = spack.main.SpackCommand('add')
@pytest.fixture()
@@ -45,6 +50,52 @@ def test_buildcache_list_duplicates(mock_get_specs, capsys):
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(
install_mockery, mock_fetch, monkeypatch, tmpdir):
"""Ensure that buildcache create fails on permission denied error."""