summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann Klähn <github@web.jklaehn.de>2017-11-07 04:19:27 +0100
committerscheibelp <scheibel1@llnl.gov>2017-11-06 19:19:27 -0800
commitac3a807f5893cb0fd653b1121e7cb032fda1341e (patch)
tree39e855af052cd80e8d34c9df9b137caf769defbb
parent8bae192d5c6e40d3d90c3873d3d9cc78b971f6c5 (diff)
downloadspack-ac3a807f5893cb0fd653b1121e7cb032fda1341e.tar.gz
spack-ac3a807f5893cb0fd653b1121e7cb032fda1341e.tar.bz2
spack-ac3a807f5893cb0fd653b1121e7cb032fda1341e.tar.xz
spack-ac3a807f5893cb0fd653b1121e7cb032fda1341e.zip
Fix spack view hardlink (#6130)
Fix a typo in "spack view hardlink" introduced in #5415 ("os.hardlink" does not exist).
-rw-r--r--lib/spack/spack/cmd/view.py2
-rw-r--r--lib/spack/spack/test/cmd/view.py13
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/spack/spack/cmd/view.py b/lib/spack/spack/cmd/view.py
index f6e7e7d9ad..13005053ff 100644
--- a/lib/spack/spack/cmd/view.py
+++ b/lib/spack/spack/cmd/view.py
@@ -177,7 +177,7 @@ def view(parser, args):
view = YamlFilesystemView(
path, spack.store.layout,
ignore_conflicts=getattr(args, "ignore_conflicts", False),
- link=os.hardlink if args.action in ["hardlink", "hard"]
+ link=os.link if args.action in ["hardlink", "hard"]
else os.symlink,
verbose=args.verbose)
diff --git a/lib/spack/spack/test/cmd/view.py b/lib/spack/spack/test/cmd/view.py
index 51d37814d0..9ab3e528d2 100644
--- a/lib/spack/spack/test/cmd/view.py
+++ b/lib/spack/spack/test/cmd/view.py
@@ -24,6 +24,7 @@
##############################################################################
from spack.main import SpackCommand
import os.path
+import pytest
activate = SpackCommand('activate')
extensions = SpackCommand('extensions')
@@ -31,6 +32,18 @@ install = SpackCommand('install')
view = SpackCommand('view')
+@pytest.mark.parametrize('cmd', ['hardlink', 'symlink', 'hard', 'add'])
+def test_view_link_type(
+ tmpdir, builtin_mock, mock_archive, mock_fetch, config,
+ install_mockery, cmd):
+ install('libdwarf')
+ viewpath = str(tmpdir.mkdir('view_{0}'.format(cmd)))
+ view(cmd, viewpath, 'libdwarf')
+ package_prefix = os.path.join(viewpath, 'libdwarf')
+ assert os.path.exists(package_prefix)
+ assert os.path.islink(package_prefix) == (not cmd.startswith('hard'))
+
+
def test_view_external(
tmpdir, builtin_mock, mock_archive, mock_fetch, config,
install_mockery):