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 @@ 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):