Windows/Testing: enable spack view
tests on Windows (#46335)
Enable tests for symlink-based views (this works with almost no modifications to the view logic). View logic is not yet robust for hardlink/junction-based views, so those are disabled for now (both in the tests and as subcommands to `spack view`).
This commit is contained in:
parent
92d940b7f4
commit
a09b9f0659
@ -33,6 +33,8 @@
|
||||
YamlFilesystemView.
|
||||
|
||||
"""
|
||||
import sys
|
||||
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.link_tree import MergeConflictError
|
||||
|
||||
@ -178,7 +180,12 @@ def setup_parser(sp):
|
||||
|
||||
|
||||
def view(parser, args):
|
||||
"Produce a view of a set of packages."
|
||||
"""Produce a view of a set of packages."""
|
||||
|
||||
if sys.platform == "win32" and args.action in ("hardlink", "hard"):
|
||||
# Hard-linked views are not yet allowed on Windows.
|
||||
# See https://github.com/spack/spack/pull/46335#discussion_r1757411915
|
||||
tty.die("Hard linking is not supported on Windows. Please use symlinks or copy methods.")
|
||||
|
||||
specs = spack.cmd.parse_specs(args.specs)
|
||||
path = args.path[0]
|
||||
|
@ -100,10 +100,12 @@ def view_copy(
|
||||
|
||||
spack.relocate.relocate_text(files=[dst], prefixes=prefix_to_projection)
|
||||
|
||||
try:
|
||||
os.chown(dst, src_stat.st_uid, src_stat.st_gid)
|
||||
except OSError:
|
||||
tty.debug(f"Can't change the permissions for {dst}")
|
||||
# The os module on Windows does not have a chown function.
|
||||
if sys.platform != "win32":
|
||||
try:
|
||||
os.chown(dst, src_stat.st_uid, src_stat.st_gid)
|
||||
except OSError:
|
||||
tty.debug(f"Can't change the permissions for {dst}")
|
||||
|
||||
|
||||
#: supported string values for `link_type` in an env, mapped to canonical values
|
||||
|
@ -4,9 +4,12 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from llnl.util.symlink import _windows_can_symlink
|
||||
|
||||
import spack.util.spack_yaml as s_yaml
|
||||
from spack.installer import PackageInstaller
|
||||
from spack.main import SpackCommand
|
||||
@ -16,7 +19,16 @@
|
||||
install = SpackCommand("install")
|
||||
view = SpackCommand("view")
|
||||
|
||||
pytestmark = pytest.mark.not_on_windows("does not run on windows")
|
||||
if sys.platform == "win32":
|
||||
if not _windows_can_symlink():
|
||||
pytest.skip(
|
||||
"Windows must be able to create symlinks to run tests.", allow_module_level=True
|
||||
)
|
||||
# TODO: Skipping hardlink command testing on windows until robust checks can be added.
|
||||
# See https://github.com/spack/spack/pull/46335#discussion_r1757411915
|
||||
commands = ["symlink", "add", "copy", "relocate"]
|
||||
else:
|
||||
commands = ["hardlink", "symlink", "hard", "add", "copy", "relocate"]
|
||||
|
||||
|
||||
def create_projection_file(tmpdir, projection):
|
||||
@ -28,7 +40,7 @@ def create_projection_file(tmpdir, projection):
|
||||
return projection_file
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cmd", ["hardlink", "symlink", "hard", "add", "copy", "relocate"])
|
||||
@pytest.mark.parametrize("cmd", commands)
|
||||
def test_view_link_type(tmpdir, mock_packages, mock_archive, mock_fetch, install_mockery, cmd):
|
||||
install("libdwarf")
|
||||
viewpath = str(tmpdir.mkdir("view_{0}".format(cmd)))
|
||||
@ -41,7 +53,7 @@ def test_view_link_type(tmpdir, mock_packages, mock_archive, mock_fetch, install
|
||||
assert os.path.islink(package_prefix) == is_link_cmd
|
||||
|
||||
|
||||
@pytest.mark.parametrize("add_cmd", ["hardlink", "symlink", "hard", "add", "copy", "relocate"])
|
||||
@pytest.mark.parametrize("add_cmd", commands)
|
||||
def test_view_link_type_remove(
|
||||
tmpdir, mock_packages, mock_archive, mock_fetch, install_mockery, add_cmd
|
||||
):
|
||||
@ -55,7 +67,7 @@ def test_view_link_type_remove(
|
||||
assert not os.path.exists(bindir)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cmd", ["hardlink", "symlink", "hard", "add", "copy", "relocate"])
|
||||
@pytest.mark.parametrize("cmd", commands)
|
||||
def test_view_projections(tmpdir, mock_packages, mock_archive, mock_fetch, install_mockery, cmd):
|
||||
install("libdwarf@20130207")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user