Fix spack view hardlink (#6130)

Fix a typo in "spack view hardlink" introduced in #5415
("os.hardlink" does not exist).
This commit is contained in:
Johann Klähn 2017-11-07 04:19:27 +01:00 committed by scheibelp
parent 8bae192d5c
commit ac3a807f58
2 changed files with 14 additions and 1 deletions

View file

@ -177,7 +177,7 @@ def view(parser, args):
view = YamlFilesystemView( view = YamlFilesystemView(
path, spack.store.layout, path, spack.store.layout,
ignore_conflicts=getattr(args, "ignore_conflicts", False), 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, else os.symlink,
verbose=args.verbose) verbose=args.verbose)

View file

@ -24,6 +24,7 @@
############################################################################## ##############################################################################
from spack.main import SpackCommand from spack.main import SpackCommand
import os.path import os.path
import pytest
activate = SpackCommand('activate') activate = SpackCommand('activate')
extensions = SpackCommand('extensions') extensions = SpackCommand('extensions')
@ -31,6 +32,18 @@
view = SpackCommand('view') 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( def test_view_external(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, builtin_mock, mock_archive, mock_fetch, config,
install_mockery): install_mockery):