diff options
author | John W. Parent <45471568+johnwparent@users.noreply.github.com> | 2024-10-14 03:02:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-14 09:02:49 +0200 |
commit | 6c6b26214062374065cf69ad71357baf19127195 (patch) | |
tree | e5968552a6d9eaacd3c697af57cdc21e784072f1 | |
parent | 796e372bdec4968afdf7ebf44acf0cd9ff5c5880 (diff) | |
download | spack-6c6b26214062374065cf69ad71357baf19127195.tar.gz spack-6c6b26214062374065cf69ad71357baf19127195.tar.bz2 spack-6c6b26214062374065cf69ad71357baf19127195.tar.xz spack-6c6b26214062374065cf69ad71357baf19127195.zip |
Add "only_windows" marker for unit tests (#45979)
-rw-r--r-- | lib/spack/spack/test/conftest.py | 5 | ||||
-rw-r--r-- | lib/spack/spack/test/llnl/util/filesystem.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/test/llnl/util/symlink.py | 21 | ||||
-rw-r--r-- | pytest.ini | 1 |
4 files changed, 17 insertions, 12 deletions
diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 613a51162a..5f461d9d35 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -2015,6 +2015,11 @@ def pytest_runtest_setup(item): if not_on_windows_marker and sys.platform == "win32": pytest.skip(*not_on_windows_marker.args) + # Skip items marked "only windows" if they're run anywhere but Windows + only_windows_marker = item.get_closest_marker(name="only_windows") + if only_windows_marker and sys.platform != "win32": + pytest.skip(*only_windows_marker.args) + def _sequential_executor(*args, **kwargs): return spack.util.parallel.SequentialExecutor() diff --git a/lib/spack/spack/test/llnl/util/filesystem.py b/lib/spack/spack/test/llnl/util/filesystem.py index 7803ecaf8c..a0c9874769 100644 --- a/lib/spack/spack/test/llnl/util/filesystem.py +++ b/lib/spack/spack/test/llnl/util/filesystem.py @@ -1000,7 +1000,7 @@ def test_rename_dest_exists(tmpdir): shutil.rmtree(tmpdir.join("f")) -@pytest.mark.skipif(sys.platform != "win32", reason="No-op on non Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_windows_sfn(tmpdir): # first check some standard Windows locations # we know require sfn names diff --git a/lib/spack/spack/test/llnl/util/symlink.py b/lib/spack/spack/test/llnl/util/symlink.py index 73a9d05e97..f4c1f16816 100644 --- a/lib/spack/spack/test/llnl/util/symlink.py +++ b/lib/spack/spack/test/llnl/util/symlink.py @@ -5,7 +5,6 @@ """Tests for ``llnl/util/symlink.py``""" import os -import sys import tempfile import pytest @@ -37,7 +36,7 @@ def test_symlink_dir(tmpdir): assert symlink.islink(link_dir) -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_symlink_source_not_exists(tmpdir): """Test the symlink.symlink method for the case where a source path does not exist""" with tmpdir.as_cwd(): @@ -71,7 +70,7 @@ def test_symlink_src_relative_to_link(tmpdir): assert os.path.lexists(link_dir) -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_symlink_src_not_relative_to_link(tmpdir): """Test the symlink.symlink functionality where the source value does not exist relative to the link and not relative to the cwd. NOTE that this symlink api call is EXPECTED to raise @@ -98,7 +97,7 @@ def test_symlink_src_not_relative_to_link(tmpdir): assert not os.path.lexists(link_dir) -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_symlink_link_already_exists(tmpdir): """Test the symlink.symlink method for the case where a link already exists""" with tmpdir.as_cwd(): @@ -113,7 +112,7 @@ def test_symlink_link_already_exists(tmpdir): @pytest.mark.skipif(not symlink._windows_can_symlink(), reason="Test requires elevated privileges") -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_symlink_win_file(tmpdir): """Check that symlink.symlink makes a symlink file when run with elevated permissions""" with tmpdir.as_cwd(): @@ -130,7 +129,7 @@ def test_symlink_win_file(tmpdir): @pytest.mark.skipif(not symlink._windows_can_symlink(), reason="Test requires elevated privileges") -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_symlink_win_dir(tmpdir): """Check that symlink.symlink makes a symlink dir when run with elevated permissions""" with tmpdir.as_cwd(): @@ -147,7 +146,7 @@ def test_symlink_win_dir(tmpdir): assert not symlink._windows_is_junction(link_dir) -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_windows_create_junction(tmpdir): """Test the symlink._windows_create_junction method""" with tmpdir.as_cwd(): @@ -163,7 +162,7 @@ def test_windows_create_junction(tmpdir): assert not os.path.islink(junction_link_dir) -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_windows_create_hard_link(tmpdir): """Test the symlink._windows_create_hard_link method""" with tmpdir.as_cwd(): @@ -179,7 +178,7 @@ def test_windows_create_hard_link(tmpdir): assert not os.path.islink(link_file) -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_windows_create_link_dir(tmpdir): """Test the functionality of the windows_create_link method with a directory which should result in making a junction. @@ -198,7 +197,7 @@ def test_windows_create_link_dir(tmpdir): assert not os.path.islink(link_dir) -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_windows_create_link_file(tmpdir): """Test the functionality of the windows_create_link method with a file which should result in the creation of a hard link. It also tests the @@ -215,7 +214,7 @@ def test_windows_create_link_file(tmpdir): assert not symlink._windows_is_junction(link_file) -@pytest.mark.skipif(sys.platform != "win32", reason="Test is only for Windows") +@pytest.mark.only_windows("Test is for Windows specific behavior") def test_windows_read_link(tmpdir): """Makes sure symlink.readlink can read the link source for hard links and junctions on windows.""" diff --git a/pytest.ini b/pytest.ini index 8465cb8085..79d187fa70 100644 --- a/pytest.ini +++ b/pytest.ini @@ -15,3 +15,4 @@ markers = enable_compiler_execution: enable compiler execution to detect link paths and libc disable_clean_stage_check: avoid failing tests if there are leftover files in the stage area not_on_windows: mark tests that are skipped on Windows + only_windows: mark tests that are skipped everywhere but Windows |