diff --git a/.github/workflows/windows_python.yml b/.github/workflows/windows_python.yml index 7549273628..0c517eef5f 100644 --- a/.github/workflows/windows_python.yml +++ b/.github/workflows/windows_python.yml @@ -27,9 +27,9 @@ jobs: python -m pip install --upgrade pip python -m pip install --upgrade vermin - name: vermin (Spack's Core) - run: vermin --backport argparse --backport typing -t='2.6-' -t='3.5-' -v spack/lib/spack/spack/ spack/lib/spack/llnl/ spack/bin/ + run: vermin --backport argparse --backport typing -t='2.7-' -t='3.5-' -v spack/lib/spack/spack/ spack/lib/spack/llnl/ spack/bin/ - name: vermin (Repositories) - run: vermin --backport argparse --backport typing -t='2.6-' -t='3.5-' -v spack/var/spack/repos + run: vermin --backport argparse --backport typing -t='2.7-' -t='3.5-' -v spack/var/spack/repos # Run style checks on the files that have been changed style: runs-on: windows-latest diff --git a/bin/spack_cmd.bat b/bin/spack_cmd.bat index 56b6024665..839f1828da 100644 --- a/bin/spack_cmd.bat +++ b/bin/spack_cmd.bat @@ -16,7 +16,7 @@ popd :: Check if Python is on the PATH if not defined python_pf_ver ( (for /f "delims=" %%F in ('where python.exe') do ( - set python_pf_ver=%%F + set "python_pf_ver=%%F" goto :found_python ) ) 2> NUL ) @@ -25,19 +25,19 @@ if not defined python_pf_ver ( :: If not, look for Python from the Spack installer :get_builtin (for /f "tokens=*" %%g in ('dir /b /a:d "!spackinstdir!\Python*"') do ( - set python_ver=%%g)) 2> NUL + set "python_ver=%%g")) 2> NUL if not defined python_ver ( echo Python was not found on your system. echo Please install Python or add Python to your PATH. ) else ( - set py_path=!spackinstdir!\!python_ver! - set py_exe=!py_path!\python.exe + set "py_path=!spackinstdir!\!python_ver!" + set "py_exe=!py_path!\python.exe" ) goto :exitpoint ) else ( :: Python is already on the path - set py_exe=!python_pf_ver! + set "py_exe=!python_pf_ver!" (for /F "tokens=* USEBACKQ" %%F in ( `"!py_exe!" --version`) do (set "output=%%F")) 2>NUL if not "!output:Microsoft Store=!"=="!output!" goto :get_builtin diff --git a/lib/spack/external/ctest_log_parser.py b/lib/spack/external/ctest_log_parser.py index 2b2746003a..d1c8db16c8 100644 --- a/lib/spack/external/ctest_log_parser.py +++ b/lib/spack/external/ctest_log_parser.py @@ -71,6 +71,8 @@ import re import math import multiprocessing +import sys +import threading import time from contextlib import contextmanager @@ -409,7 +411,12 @@ def parse(self, stream, context=6, jobs=None): pool = multiprocessing.Pool(jobs) try: # this is a workaround for a Python bug in Pool with ctrl-C - results = pool.map_async(_parse_unpack, args, 1).get(9999999) + if sys.version_info >= (3, 2): + max_timeout = threading.TIMEOUT_MAX + else: + max_timeout = 9999999 + results = pool.map_async(_parse_unpack, args, 1).get(max_timeout) + errors, warnings, timings = zip(*results) finally: pool.terminate() diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index 2435da4b2f..09909c656e 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -304,7 +304,9 @@ def candidate_urls(self): urls = [] for url in [self.url] + (self.mirrors or []): - if url.startswith('file://'): + if sys.platform == "win32": + url = url.replace("\\", "/") + if sys.platform != "win32" and url.startswith('file://'): path = urllib_parse.quote(url[len('file://'):]) url = 'file://' + path urls.append(url) @@ -1718,7 +1720,7 @@ def destroy(self): class FetchError(spack.error.SpackError): - """Superclass fo fetcher errors.""" + """Superclass for fetcher errors.""" class NoCacheError(FetchError): diff --git a/lib/spack/spack/test/architecture.py b/lib/spack/spack/test/architecture.py index cc70bb2fb9..a9b168f863 100644 --- a/lib/spack/spack/test/architecture.py +++ b/lib/spack/spack/test/architecture.py @@ -25,6 +25,8 @@ def current_host_platform(): current_platform = spack.platforms.Linux() elif 'Darwin' in platform.system(): current_platform = spack.platforms.Darwin() + elif 'Windows' in platform.system(): + current_platform = spack.platforms.Windows() return current_platform @@ -56,6 +58,8 @@ def test_platform(current_host_platform): assert str(detected_platform) == str(current_host_platform) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Test unsupported on Windows") def test_user_input_combination(config, target_str, os_str): """Test for all the valid user input combinations that both the target and the operating system match. diff --git a/lib/spack/spack/test/bindist.py b/lib/spack/spack/test/bindist.py index e45d2eb07d..858871d495 100644 --- a/lib/spack/spack/test/bindist.py +++ b/lib/spack/spack/test/bindist.py @@ -338,6 +338,8 @@ def test_relative_rpaths_install_nondefault(mirror_dir): buildcache_cmd('install', '-auf', cspec.name) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_push_and_fetch_keys(mock_gnupghome): testpath = str(mock_gnupghome) @@ -426,6 +428,8 @@ def fake_full_hash(spec): 'install_mockery_mutable_config', 'mock_packages', 'mock_fetch', 'test_mirror' ) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_spec_needs_rebuild(monkeypatch, tmpdir): """Make sure needs_rebuild properly compares remote full_hash against locally computed one, avoiding unnecessary rebuilds""" @@ -454,6 +458,8 @@ def test_spec_needs_rebuild(monkeypatch, tmpdir): assert rebuild +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures( 'install_mockery_mutable_config', 'mock_packages', 'mock_fetch', ) @@ -493,6 +499,8 @@ def test_generate_index_missing(monkeypatch, tmpdir, mutable_config): assert 'libelf' not in cache_list +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_generate_indices_key_error(monkeypatch, capfd): def mock_list_url(url, recursive=False): @@ -541,6 +549,8 @@ def mock_list_url(url, recursive=False): assert expect in err +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('mock_fetch', 'install_mockery') def test_update_sbang(tmpdir, test_mirror): """Test the creation and installation of buildcaches with default rpaths @@ -612,6 +622,8 @@ def test_update_sbang(tmpdir, test_mirror): uninstall_cmd('-y', '/%s' % new_spec.dag_hash()) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") # Need one where the platform has been changed to the test platform. def test_install_legacy_yaml(test_legacy_mirror, install_mockery_mutable_config, mock_packages): @@ -621,6 +633,8 @@ def test_install_legacy_yaml(test_legacy_mirror, install_mockery_mutable_config, uninstall_cmd('-y', '/t5mczux3tfqpxwmg7egp7axy2jvyulqk') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures( 'install_mockery_mutable_config', 'mock_packages', 'mock_fetch', ) diff --git a/lib/spack/spack/test/bootstrap.py b/lib/spack/spack/test/bootstrap.py index d753e2cdfa..f5f6026a5c 100644 --- a/lib/spack/spack/test/bootstrap.py +++ b/lib/spack/spack/test/bootstrap.py @@ -2,6 +2,8 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import os + import pytest import spack.bootstrap @@ -125,6 +127,10 @@ def test_custom_store_in_environment(mutable_config, tmpdir): install_tree: root: /tmp/store """) + if os.name == 'nt': + sep = '\\' + else: + sep = '/' with spack.environment.Environment(str(tmpdir)): assert spack.environment.active_environment() assert spack.config.get('config:install_tree:root') == '/tmp/store' diff --git a/lib/spack/spack/test/build_distribution.py b/lib/spack/spack/test/build_distribution.py index 765063258a..aeb1a9a878 100644 --- a/lib/spack/spack/test/build_distribution.py +++ b/lib/spack/spack/test/build_distribution.py @@ -5,6 +5,7 @@ import os import os.path +import sys import pytest @@ -14,6 +15,8 @@ install = spack.main.SpackCommand('install') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_build_tarball_overwrite( install_mockery, mock_fetch, monkeypatch, tmpdir): diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py index 7cc63a42c0..92bf6ebe32 100644 --- a/lib/spack/spack/test/build_environment.py +++ b/lib/spack/spack/test/build_environment.py @@ -5,6 +5,8 @@ import os import platform +import posixpath +import sys import pytest @@ -81,6 +83,8 @@ def _ensure(env_mods): return _ensure +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_static_to_shared_library(build_environment): os.environ['SPACK_TEST_COMMAND'] = 'dump-args' @@ -135,6 +139,8 @@ def _set_wrong_cc(x): assert os.environ['ANOTHER_VAR'] == 'THIS_IS_SET' +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('initial,modifications,expected', [ # Set and unset variables ({'SOME_VAR_STR': '', 'SOME_VAR_NUM': '0'}, @@ -184,7 +190,10 @@ def test_compiler_config_modifications( # Check they were applied for name, value in expected.items(): if value is not None: - assert os.environ[name] == value + eviron_value = os.environ[name] + if sys.platform == "win32": + eviron_value = eviron_value.replace("\\", "/") + assert eviron_value == value continue assert name not in os.environ @@ -199,7 +208,7 @@ def test_spack_paths_before_module_paths( module_path = '/path/to/module' def _set_wrong_cc(x): - os.environ['PATH'] = module_path + ':' + os.environ['PATH'] + os.environ['PATH'] = module_path + os.pathsep + os.environ['PATH'] monkeypatch.setattr( spack.build_environment, 'load_module', _set_wrong_cc @@ -210,8 +219,11 @@ def _set_wrong_cc(x): spack.build_environment.setup_package(pkg, False) - spack_path = os.path.join(spack.paths.prefix, 'lib/spack/env') - paths = os.environ['PATH'].split(':') + spack_path = posixpath.join(spack.paths.prefix, 'lib/spack/env') + + paths = os.environ['PATH'].split(os.pathsep) + if sys.platform == 'win32': + paths = [p.replace("\\", "/") for p in paths] assert paths.index(spack_path) < paths.index(module_path) @@ -244,10 +256,10 @@ def test_wrapper_variables( 'prefix/include/cuda/atomic', 'prefix/include/cuda/std/detail/libcxx/include/ctype.h']) cuda_include_dirs = cuda_headers.directories - assert(os.path.join('prefix', 'include') + assert(posixpath.join('prefix', 'include') in cuda_include_dirs) - assert(os.path.join('prefix', 'include', 'cuda', 'std', 'detail', - 'libcxx', 'include') + assert(posixpath.join('prefix', 'include', 'cuda', 'std', 'detail', + 'libcxx', 'include') not in cuda_include_dirs) root = spack.spec.Spec('dt-diamond') @@ -293,7 +305,7 @@ def normpaths(paths): # The default implementation looks for header files only # in /include and subdirectories prefix = str(installation_dir_with_headers) - include_dirs = normpaths(header_dir_var.split(':')) + include_dirs = normpaths(header_dir_var.split(os.pathsep)) assert os.path.join(prefix, 'include') in include_dirs assert os.path.join(prefix, 'include', 'boost') not in include_dirs @@ -334,7 +346,8 @@ def _trust_me_its_a_dir(path): env_mods.apply_modifications() link_dir_var = os.environ['SPACK_LINK_DIRS'] link_dirs = link_dir_var.split(':') - external_lib_paths = set(['/fake/path1/lib', '/fake/path1/lib64']) + external_lib_paths = set([os.path.normpath('/fake/path1/lib'), + os.path.normpath('/fake/path1/lib64')]) # The external lib paths should be the last two entries of the list and # should not appear anywhere before the last two entries assert (set(os.path.normpath(x) for x in link_dirs[-2:]) == diff --git a/lib/spack/spack/test/build_system_guess.py b/lib/spack/spack/test/build_system_guess.py index 7eac51c8d8..f5b329b9e5 100644 --- a/lib/spack/spack/test/build_system_guess.py +++ b/lib/spack/spack/test/build_system_guess.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys import pytest @@ -51,6 +52,8 @@ def url_and_build_system(request, tmpdir): orig_dir.chdir() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_build_systems(url_and_build_system): url, build_system = url_and_build_system with spack.stage.Stage(url) as stage: diff --git a/lib/spack/spack/test/build_systems.py b/lib/spack/spack/test/build_systems.py index 733381e8f2..0ec2854337 100644 --- a/lib/spack/spack/test/build_systems.py +++ b/lib/spack/spack/test/build_systems.py @@ -5,12 +5,15 @@ import glob import os +import sys import pytest import llnl.util.filesystem as fs import spack.environment +import spack.error as serr +import spack.platforms import spack.repo from spack.build_environment import ChildError, get_std_cmake_args, setup_package from spack.spec import Spec @@ -19,6 +22,8 @@ DATA_PATH = os.path.join(spack.paths.test_path, 'data') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( 'directory', glob.iglob(os.path.join(DATA_PATH, 'make', 'affirmative', '*')) @@ -38,6 +43,8 @@ def test_affirmative_make_check(directory, config, mock_packages, working_env): pkg._if_make_target_execute('check') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( 'directory', glob.iglob(os.path.join(DATA_PATH, 'make', 'negative', '*')) @@ -104,6 +111,8 @@ def test_negative_ninja_check(directory, config, mock_packages, working_env): pkg._if_ninja_target_execute('check') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_cmake_std_args(config, mock_packages): # Call the function on a CMakePackage instance s = Spec('cmake-client') @@ -118,15 +127,16 @@ def test_cmake_std_args(config, mock_packages): assert get_std_cmake_args(pkg) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_cmake_bad_generator(config, mock_packages): - s = Spec('cmake-client') - s.concretize() - pkg = spack.repo.get(s) - pkg.generator = 'Yellow Sticky Notes' - with pytest.raises(spack.package.InstallError): - get_std_cmake_args(pkg) + with pytest.raises(serr.SpackError): + s = Spec('cmake-client generator="Yellow Sticky Note"') + s.concretize() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_cmake_secondary_generator(config, mock_packages): s = Spec('cmake-client') s.concretize() @@ -138,6 +148,8 @@ def test_cmake_secondary_generator(config, mock_packages): @pytest.mark.usefixtures('config', 'mock_packages') class TestAutotoolsPackage(object): + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_with_or_without(self): s = Spec('a') s.concretize() @@ -173,6 +185,8 @@ def activate(value): options = pkg.with_or_without('lorem-ipsum', variant='lorem_ipsum') assert '--without-lorem-ipsum' in options + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_none_is_allowed(self): s = Spec('a foo=none') s.concretize() @@ -187,6 +201,8 @@ def test_none_is_allowed(self): assert '--without-baz' in options assert '--no-fee' in options + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_libtool_archive_files_are_deleted_by_default( self, mutable_database ): @@ -204,6 +220,8 @@ def test_libtool_archive_files_are_deleted_by_default( ) assert libtool_deletion_log + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_libtool_archive_files_might_be_installed_on_demand( self, mutable_database, monkeypatch ): @@ -217,6 +235,8 @@ def test_libtool_archive_files_might_be_installed_on_demand( # Assert libtool archives are installed assert os.path.exists(s.package.libtool_archive_file) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_autotools_gnuconfig_replacement(self, mutable_database): """ Tests whether only broken config.sub and config.guess are replaced with @@ -238,6 +258,8 @@ def test_autotools_gnuconfig_replacement(self, mutable_database): with open(os.path.join(s.prefix.working, 'config.guess')) as f: assert "gnuconfig version of config.guess" not in f.read() + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_autotools_gnuconfig_replacement_disabled(self, mutable_database): """ Tests whether disabling patch_config_files @@ -258,6 +280,8 @@ def test_autotools_gnuconfig_replacement_disabled(self, mutable_database): with open(os.path.join(s.prefix.working, 'config.guess')) as f: assert "gnuconfig version of config.guess" not in f.read() + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.disable_clean_stage_check def test_autotools_gnuconfig_replacement_no_gnuconfig(self, mutable_database): """ @@ -271,6 +295,8 @@ def test_autotools_gnuconfig_replacement_no_gnuconfig(self, mutable_database): with pytest.raises(ChildError, match=msg): s.package.do_install() + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.disable_clean_stage_check def test_broken_external_gnuconfig(self, mutable_database, tmpdir): """ @@ -301,6 +327,8 @@ def test_broken_external_gnuconfig(self, mutable_database, tmpdir): e.install_all() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config', 'mock_packages') class TestCMakePackage(object): @@ -342,6 +370,8 @@ def test_define_from_variant(self): pkg.define_from_variant('NONEXISTENT') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config', 'mock_packages') class TestGNUMirrorPackage(object): @@ -365,6 +395,8 @@ def test_define(self): 'make/make-4.2.1.tar.gz' +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config', 'mock_packages') class TestSourceforgePackage(object): @@ -388,6 +420,8 @@ def test_define(self): 'tcl/tcl8.6.5-src.tar.gz' +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config', 'mock_packages') class TestSourcewarePackage(object): @@ -411,6 +445,8 @@ def test_define(self): 'bzip2/bzip2-1.0.8.tar.gz' +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config', 'mock_packages') class TestXorgPackage(object): diff --git a/lib/spack/spack/test/buildrequest.py b/lib/spack/spack/test/buildrequest.py index 13fbfba231..e76e0f4768 100644 --- a/lib/spack/spack/test/buildrequest.py +++ b/lib/spack/spack/test/buildrequest.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import spack.installer as inst @@ -19,6 +21,8 @@ def test_build_request_errors(install_mockery): inst.BuildRequest(pkg, {}) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_build_request_basics(install_mockery): spec = spack.spec.Spec('dependent-install') spec.concretize() @@ -35,6 +39,8 @@ def test_build_request_basics(install_mockery): assert 'install_deps' in request.install_args +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_build_request_strings(install_mockery): """Tests of BuildRequest repr and str for coverage purposes.""" # Using a package with one dependency diff --git a/lib/spack/spack/test/cache_fetch.py b/lib/spack/spack/test/cache_fetch.py index 44a5275868..c809ebb871 100644 --- a/lib/spack/spack/test/cache_fetch.py +++ b/lib/spack/spack/test/cache_fetch.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -25,6 +26,8 @@ def test_fetch_missing_cache(tmpdir, _fetch_method): fetcher.fetch() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('_fetch_method', ['curl', 'urllib']) def test_fetch(tmpdir, _fetch_method): """Ensure a fetch after expanding is effectively a no-op.""" diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py index 0663e5c58e..9bed592ed8 100644 --- a/lib/spack/spack/test/cc.py +++ b/lib/spack/spack/test/cc.py @@ -8,6 +8,7 @@ arguments correctly. """ import os +import sys import pytest @@ -170,12 +171,14 @@ def dump_mode(cc, args): return cc(*args, output=str).strip() +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_no_wrapper_environment(): with pytest.raises(ProcessError): output = cc(output=str) assert "Spack compiler must be run from Spack" in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_vcheck_mode(wrapper_environment): assert dump_mode(cc, ['-I/include', '--version']) == 'vcheck' assert dump_mode(cc, ['-I/include', '-V']) == 'vcheck' @@ -185,16 +188,19 @@ def test_vcheck_mode(wrapper_environment): assert dump_mode(cc, ['-I/include', '-V', '-o', 'output']) == 'vcheck' +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_cpp_mode(wrapper_environment): assert dump_mode(cc, ['-E']) == 'cpp' assert dump_mode(cxx, ['-E']) == 'cpp' assert dump_mode(cpp, []) == 'cpp' +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_as_mode(wrapper_environment): assert dump_mode(cc, ['-S']) == 'as' +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ccld_mode(wrapper_environment): assert dump_mode(cc, []) == 'ccld' assert dump_mode(cc, ['foo.c', '-o', 'foo']) == 'ccld' @@ -203,12 +209,14 @@ def test_ccld_mode(wrapper_environment): 'foo.o', 'bar.o', 'baz.o', '-o', 'foo', '-Wl,-rpath,foo']) == 'ccld' +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ld_mode(wrapper_environment): assert dump_mode(ld, []) == 'ld' assert dump_mode(ld, [ 'foo.o', 'bar.o', 'baz.o', '-o', 'foo', '-Wl,-rpath,foo']) == 'ld' +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ld_flags(wrapper_environment, wrapper_flags): check_args( ld, test_args, @@ -222,6 +230,7 @@ def test_ld_flags(wrapper_environment, wrapper_flags): spack_ldlibs) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_cpp_flags(wrapper_environment, wrapper_flags): check_args( cpp, test_args, @@ -232,6 +241,7 @@ def test_cpp_flags(wrapper_environment, wrapper_flags): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_cc_flags(wrapper_environment, wrapper_flags): check_args( cc, test_args, @@ -244,6 +254,7 @@ def test_cc_flags(wrapper_environment, wrapper_flags): spack_ldlibs) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_cxx_flags(wrapper_environment, wrapper_flags): check_args( cxx, test_args, @@ -256,6 +267,7 @@ def test_cxx_flags(wrapper_environment, wrapper_flags): spack_ldlibs) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_fc_flags(wrapper_environment, wrapper_flags): check_args( fc, test_args, @@ -268,6 +280,7 @@ def test_fc_flags(wrapper_environment, wrapper_flags): spack_ldlibs) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_dep_rpath(wrapper_environment): """Ensure RPATHs for root package are added.""" check_args( @@ -277,6 +290,7 @@ def test_dep_rpath(wrapper_environment): common_compile_args) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_dep_include(wrapper_environment): """Ensure a single dependency include directory is added.""" with set_env(SPACK_INCLUDE_DIRS='x'): @@ -292,6 +306,7 @@ def test_dep_include(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_system_path_cleanup(wrapper_environment): """Ensure SPACK_ENV_PATH is removed from PATH, even with trailing / @@ -312,6 +327,7 @@ def test_system_path_cleanup(wrapper_environment): check_env_var(cc, 'PATH', system_path) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_dep_lib(wrapper_environment): """Ensure a single dependency RPATH is added.""" with set_env(SPACK_LINK_DIRS='x', @@ -329,6 +345,7 @@ def test_dep_lib(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_dep_lib_no_rpath(wrapper_environment): """Ensure a single dependency link flag is added with no dep RPATH.""" with set_env(SPACK_LINK_DIRS='x'): @@ -344,6 +361,7 @@ def test_dep_lib_no_rpath(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_dep_lib_no_lib(wrapper_environment): """Ensure a single dependency RPATH is added with no -L.""" with set_env(SPACK_RPATH_DIRS='x'): @@ -359,6 +377,7 @@ def test_dep_lib_no_lib(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ccld_deps(wrapper_environment): """Ensure all flags are added in ccld mode.""" with set_env(SPACK_INCLUDE_DIRS='xinc:yinc:zinc', @@ -384,6 +403,7 @@ def test_ccld_deps(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ccld_deps_isystem(wrapper_environment): """Ensure all flags are added in ccld mode. When a build uses -isystem, Spack should inject it's @@ -415,6 +435,7 @@ def test_ccld_deps_isystem(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_cc_deps(wrapper_environment): """Ensure -L and RPATHs are not added in cc mode.""" with set_env(SPACK_INCLUDE_DIRS='xinc:yinc:zinc', @@ -433,6 +454,7 @@ def test_cc_deps(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ccld_with_system_dirs(wrapper_environment): """Ensure all flags are added in ccld mode.""" with set_env(SPACK_INCLUDE_DIRS='xinc:yinc:zinc', @@ -469,6 +491,7 @@ def test_ccld_with_system_dirs(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ccld_with_system_dirs_isystem(wrapper_environment): """Ensure all flags are added in ccld mode. Ensure that includes are in the proper @@ -508,6 +531,7 @@ def test_ccld_with_system_dirs_isystem(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ld_deps(wrapper_environment): """Ensure no (extra) -I args or -Wl, are passed in ld mode.""" with set_env(SPACK_INCLUDE_DIRS='xinc:yinc:zinc', @@ -529,6 +553,7 @@ def test_ld_deps(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ld_deps_no_rpath(wrapper_environment): """Ensure SPACK_LINK_DEPS controls -L for ld.""" with set_env(SPACK_INCLUDE_DIRS='xinc:yinc:zinc', @@ -546,6 +571,7 @@ def test_ld_deps_no_rpath(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ld_deps_no_link(wrapper_environment): """Ensure SPACK_RPATH_DEPS controls -rpath for ld.""" with set_env(SPACK_INCLUDE_DIRS='xinc:yinc:zinc', @@ -563,6 +589,7 @@ def test_ld_deps_no_link(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ld_deps_partial(wrapper_environment): """Make sure ld -r (partial link) is handled correctly on OS's where it doesn't accept rpaths. @@ -601,6 +628,7 @@ def test_ld_deps_partial(wrapper_environment): test_args_without_paths) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ccache_prepend_for_cc(wrapper_environment): with set_env(SPACK_CCACHE_BINARY='ccache'): os.environ['SPACK_SHORT_SPEC'] = "foo@1.2=linux-x86_64" @@ -620,6 +648,7 @@ def test_ccache_prepend_for_cc(wrapper_environment): common_compile_args) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_no_ccache_prepend_for_fc(wrapper_environment): os.environ['SPACK_SHORT_SPEC'] = "foo@1.2=linux-x86_64" check_args( @@ -638,6 +667,8 @@ def test_no_ccache_prepend_for_fc(wrapper_environment): common_compile_args) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('9160') def test_disable_new_dtags(wrapper_environment, wrapper_flags): with set_env(SPACK_TEST_COMMAND='dump-args'): @@ -647,6 +678,8 @@ def test_disable_new_dtags(wrapper_environment, wrapper_flags): assert '-Wl,--disable-new-dtags' in result +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('9160') def test_filter_enable_new_dtags(wrapper_environment, wrapper_flags): with set_env(SPACK_TEST_COMMAND='dump-args'): @@ -659,6 +692,8 @@ def test_filter_enable_new_dtags(wrapper_environment, wrapper_flags): assert '-Wl,--enable-new-dtags' not in result +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('22643') def test_linker_strips_loopopt(wrapper_environment, wrapper_flags): with set_env(SPACK_TEST_COMMAND='dump-args'): diff --git a/lib/spack/spack/test/ci.py b/lib/spack/spack/test/ci.py index 7bff8f8447..4b74959f68 100644 --- a/lib/spack/spack/test/ci.py +++ b/lib/spack/spack/test/ci.py @@ -6,6 +6,7 @@ import itertools as it import json import os +import sys import pytest @@ -50,6 +51,8 @@ def test_urlencode_string(): assert(s_enc == 'Spack+Test+Project') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_import_signing_key(mock_gnupghome): signing_key_dir = spack_paths.mock_gpg_keys_path signing_key_path = os.path.join(signing_key_dir, 'package-signing-key') @@ -83,6 +86,8 @@ def assert_present(config): assert_present(last_config) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_get_concrete_specs(config, mutable_mock_env_path, mock_packages): e = ev.create('test1') e.add('dyninst') @@ -172,6 +177,8 @@ def test_register_cdash_build(monkeypatch): assert(build_id == 42) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_relate_cdash_builds(config, mutable_mock_env_path, mock_packages, monkeypatch, capfd): e = ev.create('test1') @@ -236,6 +243,8 @@ def test_relate_cdash_builds(config, mutable_mock_env_path, mock_packages, [cdashids_mirror_url]) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_read_write_cdash_ids(config, tmp_scope, tmpdir, mock_packages): working_dir = tmpdir.join('working_dir') mirror_dir = working_dir.join('mirror') diff --git a/lib/spack/spack/test/cmd/activate.py b/lib/spack/spack/test/cmd/activate.py index cf2bdbbbf8..bc15aa7613 100644 --- a/lib/spack/spack/test/cmd/activate.py +++ b/lib/spack/spack/test/cmd/activate.py @@ -2,6 +2,9 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + +import pytest from spack.main import SpackCommand @@ -11,6 +14,7 @@ extensions = SpackCommand('extensions') +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_activate( mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -20,6 +24,7 @@ def test_activate( assert 'extension1' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_deactivate( mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -30,6 +35,7 @@ def test_deactivate( assert 'extension1' not in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_deactivate_all( mock_packages, mock_archive, mock_fetch, config, install_mockery): diff --git a/lib/spack/spack/test/cmd/analyze.py b/lib/spack/spack/test/cmd/analyze.py index 2782043178..f662a48948 100644 --- a/lib/spack/spack/test/cmd/analyze.py +++ b/lib/spack/spack/test/cmd/analyze.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -104,6 +105,7 @@ def _run_analyzer(name, package, tmpdir): return output_file +@pytest.mark.skipif(sys.platform == 'win32', reason="Install hangs on windows") def test_installfiles_analyzer(tmpdir, mock_fetch, install_mockery_mutable_config): """ test the install files analyzer @@ -124,6 +126,7 @@ def test_installfiles_analyzer(tmpdir, mock_fetch, install_mockery_mutable_confi assert key in basenames +@pytest.mark.skipif(sys.platform == 'win32', reason="Install hangs on windows") def test_environment_analyzer(tmpdir, mock_fetch, install_mockery_mutable_config): """ test the environment variables analyzer. diff --git a/lib/spack/spack/test/cmd/blame.py b/lib/spack/spack/test/cmd/blame.py index 18ca4803e6..f6ca34b4b1 100644 --- a/lib/spack/spack/test/cmd/blame.py +++ b/lib/spack/spack/test/cmd/blame.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest from llnl.util.filesystem import working_dir @@ -36,6 +38,8 @@ def test_blame_by_percent(mock_packages): assert 'EMAIL' in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_blame_file(mock_packages): """Sanity check the blame command to make sure it works.""" with working_dir(spack.paths.prefix): @@ -68,6 +72,7 @@ def test_blame_json(mock_packages): assert key in loaded['authors'][0] +@pytest.mark.skipif(sys.platform == 'win32', reason="git hangs") def test_blame_by_git(mock_packages, capfd): """Sanity check the blame command to make sure it works.""" with capfd.disabled(): diff --git a/lib/spack/spack/test/cmd/bootstrap.py b/lib/spack/spack/test/cmd/bootstrap.py index b39a950c95..660b1a5314 100644 --- a/lib/spack/spack/test/cmd/bootstrap.py +++ b/lib/spack/spack/test/cmd/bootstrap.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os.path +import sys import pytest @@ -38,6 +39,8 @@ def test_root_get_and_set(mutable_config, scope): _bootstrap('root', path, *scope_args) out = _bootstrap('root', *scope_args, output=str) + if sys.platform == 'win32': + out = out.replace("\\", "/") assert out.strip() == path diff --git a/lib/spack/spack/test/cmd/buildcache.py b/lib/spack/spack/test/cmd/buildcache.py index 5bda617d5a..f1b51447fa 100644 --- a/lib/spack/spack/test/cmd/buildcache.py +++ b/lib/spack/spack/test/cmd/buildcache.py @@ -7,6 +7,7 @@ import os import platform import shutil +import sys import pytest @@ -57,6 +58,7 @@ def test_buildcache_preview_just_runs(database): buildcache('preview', 'mpileaks') +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") @pytest.mark.db @pytest.mark.regression('13757') def test_buildcache_list_duplicates(mock_get_specs, capsys): @@ -66,6 +68,7 @@ def test_buildcache_list_duplicates(mock_get_specs, capsys): assert output.count('mpileaks') == 3 +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") @pytest.mark.db @pytest.mark.regression('17827') def test_buildcache_list_allarch(database, mock_get_specs_multiarch, capsys): @@ -80,6 +83,7 @@ def test_buildcache_list_allarch(database, mock_get_specs_multiarch, capsys): assert output.count('mpileaks') == 2 +@pytest.mark.skipif(sys.platform == 'win32', reason="Install hangs on windows") def tests_buildcache_create( install_mockery, mock_fetch, monkeypatch, tmpdir): """"Ensure that buildcache create creates output files""" @@ -97,6 +101,7 @@ def tests_buildcache_create( os.path.join(str(tmpdir), 'build_cache', tarball)) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def tests_buildcache_create_env( install_mockery, mock_fetch, monkeypatch, tmpdir, mutable_mock_env_path): @@ -119,6 +124,7 @@ def tests_buildcache_create_env( os.path.join(str(tmpdir), 'build_cache', tarball)) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_buildcache_create_fails_on_noargs(tmpdir): """Ensure that buildcache create fails when given no args or environment.""" @@ -126,6 +132,7 @@ def test_buildcache_create_fails_on_noargs(tmpdir): buildcache('create', '-d', str(tmpdir), '--unsigned') +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_buildcache_create_fail_on_perm_denied( install_mockery, mock_fetch, monkeypatch, tmpdir): """Ensure that buildcache create fails on permission denied error.""" @@ -139,6 +146,7 @@ def test_buildcache_create_fail_on_perm_denied( tmpdir.chmod(0o700) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_update_key_index(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, mock_fetch, mock_stage, mock_gnupghome): @@ -175,6 +183,7 @@ def test_update_key_index(tmpdir, mutable_mock_env_path, assert 'index.json' in key_dir_list +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_buildcache_sync(mutable_mock_env_path, install_mockery_mutable_config, mock_packages, mock_fetch, mock_stage, tmpdir): """ @@ -251,6 +260,7 @@ def verify_mirror_contents(): verify_mirror_contents() +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_buildcache_create_install(mutable_mock_env_path, install_mockery_mutable_config, mock_packages, mock_fetch, mock_stage, diff --git a/lib/spack/spack/test/cmd/checksum.py b/lib/spack/spack/test/cmd/checksum.py index 18c4d59eb4..3c47f69d48 100644 --- a/lib/spack/spack/test/cmd/checksum.py +++ b/lib/spack/spack/test/cmd/checksum.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import argparse +import sys import pytest @@ -29,6 +30,8 @@ def test_checksum_args(arguments, expected): assert check == expected +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('arguments,expected', [ (['--batch', 'preferred-test'], 'version of preferred-test'), (['--latest', 'preferred-test'], 'Found 1 version'), @@ -40,6 +43,8 @@ def test_checksum(arguments, expected, mock_packages, mock_stage): assert 'version(' in output +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_checksum_interactive( mock_packages, mock_fetch, mock_stage, monkeypatch): def _get_number(*args, **kwargs): diff --git a/lib/spack/spack/test/cmd/ci.py b/lib/spack/spack/test/cmd/ci.py index aad64d9e1a..7fc032db64 100644 --- a/lib/spack/spack/test/cmd/ci.py +++ b/lib/spack/spack/test/cmd/ci.py @@ -7,6 +7,7 @@ import json import os import shutil +import sys import pytest from jsonschema import ValidationError, validate @@ -58,6 +59,7 @@ def set_env_var(key, val): os.environ[key] = val +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_specs_staging(config): """Make sure we achieve the best possible staging for the following spec DAG:: @@ -117,6 +119,7 @@ def test_specs_staging(config): assert (spec_a_label in stages[3]) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ci_generate_with_env(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, project_dir_env, mock_binary_index): @@ -213,6 +216,7 @@ def _validate_needs_graph(yaml_contents, needs_graph, artifacts): break +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_bootstrap_gcc(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, project_dir_env): @@ -275,6 +279,7 @@ def test_ci_generate_bootstrap_gcc(tmpdir, mutable_mock_env_path, _validate_needs_graph(yaml_contents, needs_graph, False) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_bootstrap_artifacts_buildcache(tmpdir, mutable_mock_env_path, install_mockery, @@ -342,6 +347,7 @@ def test_ci_generate_bootstrap_artifacts_buildcache(tmpdir, _validate_needs_graph(yaml_contents, needs_graph, True) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_with_env_missing_section(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, project_dir_env, @@ -368,6 +374,7 @@ def test_ci_generate_with_env_missing_section(tmpdir, mutable_mock_env_path, assert(expect_out in output) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_with_cdash_token(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, project_dir_env, @@ -424,6 +431,7 @@ def test_ci_generate_with_cdash_token(tmpdir, mutable_mock_env_path, assert(filecmp.cmp(orig_file, copy_to_file) is True) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_with_custom_scripts(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, @@ -515,6 +523,7 @@ def test_ci_generate_with_custom_scripts(tmpdir, mutable_mock_env_path, assert(found_it) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_pkg_with_deps(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, project_dir_env): @@ -569,6 +578,7 @@ def test_ci_generate_pkg_with_deps(tmpdir, mutable_mock_env_path, assert('dependency-install' in found) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_for_pr_pipeline(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, @@ -633,6 +643,7 @@ def test_ci_generate_for_pr_pipeline(tmpdir, mutable_mock_env_path, assert(pipeline_vars['SPACK_PIPELINE_TYPE'] == 'spack_pull_request') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_with_external_pkg(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, @@ -678,6 +689,7 @@ def test_ci_generate_with_external_pkg(tmpdir, mutable_mock_env_path, @pytest.mark.xfail(reason='fails intermittently and covered by gitlab ci') +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ci_rebuild(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, mock_gnupghome, mock_fetch, project_dir_env, @@ -837,6 +849,7 @@ def mystrip(s): env_cmd('deactivate') +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ci_nothing_to_rebuild(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, mock_fetch, project_dir_env, mock_binary_index): @@ -911,6 +924,7 @@ def fake_dl_method(spec, *args, **kwargs): env_cmd('deactivate') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_push_mirror_contents(tmpdir, mutable_mock_env_path, install_mockery_mutable_config, mock_packages, @@ -1061,6 +1075,7 @@ def test_push_mirror_contents(tmpdir, mutable_mock_env_path, assert(len(dl_dir_list) == 3) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_push_mirror_contents_exceptions(monkeypatch, capsys): def failing_access(*args, **kwargs): raise Exception('Error: Access Denied') @@ -1078,6 +1093,7 @@ def failing_access(*args, **kwargs): assert expect_msg in std_out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_override_runner_attrs(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, @@ -1223,6 +1239,7 @@ def test_ci_generate_override_runner_attrs(tmpdir, mutable_mock_env_path, assert(the_elt['after_script'][0] == 'post step one') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_with_workarounds(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, @@ -1274,6 +1291,7 @@ def test_ci_generate_with_workarounds(tmpdir, mutable_mock_env_path, assert(found_one is True) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") @pytest.mark.disable_clean_stage_check def test_ci_rebuild_index(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, mock_fetch, @@ -1326,6 +1344,7 @@ def test_ci_rebuild_index(tmpdir, mutable_mock_env_path, validate(index_object, db_idx_schema) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ci_generate_bootstrap_prune_dag( install_mockery_mutable_config, mock_packages, mock_fetch, mock_archive, mutable_config, monkeypatch, tmpdir, @@ -1460,6 +1479,7 @@ def fake_get_mirrors_for_spec(spec=None, full_hash_match=False, _validate_needs_graph(new_yaml_contents, needs_graph, False) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_subcommands_without_mirror(tmpdir, mutable_mock_env_path, mock_packages, install_mockery, project_dir_env, @@ -1499,6 +1519,7 @@ def test_ci_subcommands_without_mirror(tmpdir, mutable_mock_env_path, assert(ex in output) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ensure_only_one_temporary_storage(): """Make sure 'gitlab-ci' section of env does not allow specification of both 'enable-artifacts-buildcache' and 'temporary-storage-url-prefix'.""" @@ -1539,6 +1560,7 @@ def test_ensure_only_one_temporary_storage(): validate(yaml_obj, gitlab_ci_schema) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_ci_generate_temp_storage_url(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, @@ -1595,6 +1617,7 @@ def test_ci_generate_temp_storage_url(tmpdir, mutable_mock_env_path, assert(cleanup_job['stage'] == stages[-2]) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ci_generate_read_broken_specs_url(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, @@ -1654,6 +1677,7 @@ def test_ci_generate_read_broken_specs_url(tmpdir, mutable_mock_env_path, assert(ex not in output) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_ci_reproduce(tmpdir, mutable_mock_env_path, install_mockery, mock_packages, monkeypatch, last_two_git_commits, project_dir_env, mock_binary_index): diff --git a/lib/spack/spack/test/cmd/clean.py b/lib/spack/spack/test/cmd/clean.py index 1fad6a22b9..0dfca81c66 100644 --- a/lib/spack/spack/test/cmd/clean.py +++ b/lib/spack/spack/test/cmd/clean.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import spack.caches @@ -55,6 +57,7 @@ def __call__(self, *args, **kwargs): ('-a', all_effects), ('', []), ]) +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_function_calls(command_line, effects, mock_calls_for_clean): # Call the command with the supplied command line diff --git a/lib/spack/spack/test/cmd/commands.py b/lib/spack/spack/test/cmd/commands.py index 21a719717b..d3abf5cf6c 100644 --- a/lib/spack/spack/test/cmd/commands.py +++ b/lib/spack/spack/test/cmd/commands.py @@ -7,6 +7,7 @@ import os import shutil import subprocess +import sys import pytest @@ -215,6 +216,7 @@ def test_update_completion_arg(tmpdir, monkeypatch): assert "--update-completion" in mock_bashfile.read() +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_updated_completion_scripts(tmpdir): """Make sure our shell tab completion scripts remain up-to-date.""" diff --git a/lib/spack/spack/test/cmd/common/arguments.py b/lib/spack/spack/test/cmd/common/arguments.py index 5f1299a94a..763c6880c0 100644 --- a/lib/spack/spack/test/cmd/common/arguments.py +++ b/lib/spack/spack/test/cmd/common/arguments.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import argparse +import sys import pytest @@ -62,6 +63,8 @@ def test_parse_spec_flags_with_spaces( assert all(x in s.variants for x in expected_variants) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_match_spec_env(mock_packages, mutable_mock_env_path): """ @@ -84,6 +87,8 @@ def test_match_spec_env(mock_packages, mutable_mock_env_path): assert env_spec.concrete +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_multiple_env_match_raises_error(mock_packages, mutable_mock_env_path): e = ev.create('test') @@ -97,6 +102,8 @@ def test_multiple_env_match_raises_error(mock_packages, mutable_mock_env_path): assert 'matches multiple specs' in exc_info.value.message +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_root_and_dep_match_returns_root(mock_packages, mutable_mock_env_path): e = ev.create('test') diff --git a/lib/spack/spack/test/cmd/compiler.py b/lib/spack/spack/test/cmd/compiler.py index 0228610478..0685ed1437 100644 --- a/lib/spack/spack/test/cmd/compiler.py +++ b/lib/spack/spack/test/cmd/compiler.py @@ -51,6 +51,7 @@ def mock_compiler_dir(tmpdir, mock_compiler_version): return str(tmpdir) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.regression('11678,13138') def test_compiler_find_without_paths(no_compilers_yaml, working_env, tmpdir): with tmpdir.as_cwd(): @@ -103,6 +104,7 @@ def test_compiler_remove(mutable_config, mock_packages): assert spack.spec.CompilerSpec("gcc@4.5.0") not in compilers +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_compiler_add( mutable_config, mock_packages, mock_compiler_dir, mock_compiler_version ): @@ -182,6 +184,7 @@ def clangdir(tmpdir): yield tmpdir +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.regression('17590') def test_compiler_find_mixed_suffixes( no_compilers_yaml, working_env, clangdir): @@ -217,6 +220,7 @@ def test_compiler_find_mixed_suffixes( } +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.regression('17590') def test_compiler_find_prefer_no_suffix( no_compilers_yaml, working_env, clangdir): @@ -242,6 +246,7 @@ def test_compiler_find_prefer_no_suffix( assert clang['paths']['cxx'] == str(clangdir.join('clang++')) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_compiler_find_path_order( no_compilers_yaml, working_env, clangdir): """Ensure that we find compilers that come first in the PATH first diff --git a/lib/spack/spack/test/cmd/concretize.py b/lib/spack/spack/test/cmd/concretize.py index d357ccc9dc..c630ebeb68 100644 --- a/lib/spack/spack/test/cmd/concretize.py +++ b/lib/spack/spack/test/cmd/concretize.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys import pytest @@ -18,6 +19,7 @@ concretize = SpackCommand('concretize') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.parametrize('concretization', ['separately', 'together']) def test_concretize_all_test_dependencies(concretization): """Check all test dependencies are concretized.""" @@ -30,6 +32,7 @@ def test_concretize_all_test_dependencies(concretization): assert e.matching_spec('test-dependency') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.parametrize('concretization', ['separately', 'together']) def test_concretize_root_test_dependencies_not_recursive(concretization): """Check that test dependencies are not concretized recursively.""" @@ -42,6 +45,7 @@ def test_concretize_root_test_dependencies_not_recursive(concretization): assert e.matching_spec('test-dependency') is None +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.parametrize('concretization', ['separately', 'together']) def test_concretize_root_test_dependencies_are_concretized(concretization): """Check that root test dependencies are concretized.""" diff --git a/lib/spack/spack/test/cmd/config.py b/lib/spack/spack/test/cmd/config.py index 175fd1c26f..afed72df19 100644 --- a/lib/spack/spack/test/cmd/config.py +++ b/lib/spack/spack/test/cmd/config.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import functools import os +import sys import pytest @@ -239,6 +240,7 @@ def test_config_add_ordered_dict(mutable_empty_config): """ +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_add_invalid_fails(mutable_empty_config): config('add', 'packages:all:variants:+debug') with pytest.raises( @@ -247,6 +249,7 @@ def test_config_add_invalid_fails(mutable_empty_config): config('add', 'packages:all:True') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_add_from_file(mutable_empty_config, tmpdir): contents = """spack: config: @@ -264,6 +267,7 @@ def test_config_add_from_file(mutable_empty_config, tmpdir): """ +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_add_from_file_multiple(mutable_empty_config, tmpdir): contents = """spack: config: @@ -319,6 +323,7 @@ def test_config_add_override_leaf_from_file(mutable_empty_config, tmpdir): """ +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_add_update_dict_from_file(mutable_empty_config, tmpdir): config('add', 'packages:all:compiler:[gcc]') @@ -370,6 +375,7 @@ def test_config_add_invalid_file_fails(tmpdir): config('add', '-f', file) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_remove_value(mutable_empty_config): config('add', 'config:dirty:true') config('remove', 'config:dirty:true') @@ -379,6 +385,7 @@ def test_config_remove_value(mutable_empty_config): """ +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_remove_alias_rm(mutable_empty_config): config('add', 'config:dirty:true') config('rm', 'config:dirty:true') @@ -388,6 +395,7 @@ def test_config_remove_alias_rm(mutable_empty_config): """ +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_remove_dict(mutable_empty_config): config('add', 'config:dirty:true') config('rm', 'config:dirty') @@ -397,6 +405,7 @@ def test_config_remove_dict(mutable_empty_config): """ +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_remove_from_list(mutable_empty_config): config('add', 'config:template_dirs:test1') config('add', 'config:template_dirs:[test2]') @@ -411,6 +420,7 @@ def test_remove_from_list(mutable_empty_config): """ +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_remove_list(mutable_empty_config): config('add', 'config:template_dirs:test1') config('add', 'config:template_dirs:[test2]') @@ -425,6 +435,7 @@ def test_remove_list(mutable_empty_config): """ +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_add_to_env(mutable_empty_config, mutable_mock_env_path): ev.create('test') with ev.read('test'): @@ -438,6 +449,7 @@ def test_config_add_to_env(mutable_empty_config, mutable_mock_env_path): assert expected in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_add_to_env_preserve_comments(mutable_empty_config, mutable_mock_env_path, tmpdir): @@ -470,6 +482,7 @@ def test_config_add_to_env_preserve_comments(mutable_empty_config, assert output == expected +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_remove_from_env(mutable_empty_config, mutable_mock_env_path): env('create', 'test') @@ -487,6 +500,7 @@ def test_config_remove_from_env(mutable_empty_config, mutable_mock_env_path): assert output == expected +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_update_packages(packages_yaml_v015): """Test Spack updating old packages.yaml format for externals to new format. Ensure that data is preserved and converted @@ -500,6 +514,7 @@ def test_config_update_packages(packages_yaml_v015): check_packages_updated(data) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_update_config(config_yaml_v015): config_yaml_v015() config('update', '-y', 'config') @@ -509,6 +524,7 @@ def test_config_update_config(config_yaml_v015): check_config_updated(data) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_update_not_needed(mutable_config): data_before = spack.config.get('repos') config('update', '-y', 'repos') @@ -516,6 +532,7 @@ def test_config_update_not_needed(mutable_config): assert data_before == data_after +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_update_fail_on_permission_issue( packages_yaml_v015, monkeypatch ): @@ -529,6 +546,7 @@ def test_config_update_fail_on_permission_issue( config('update', '-y', 'packages') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_config_revert(packages_yaml_v015): cfg_file = packages_yaml_v015() bkp_file = cfg_file + '.bkp' diff --git a/lib/spack/spack/test/cmd/debug.py b/lib/spack/spack/test/cmd/debug.py index 3aace2077d..1666a8b277 100644 --- a/lib/spack/spack/test/cmd/debug.py +++ b/lib/spack/spack/test/cmd/debug.py @@ -6,6 +6,7 @@ import os import os.path import platform +import sys import pytest @@ -17,6 +18,7 @@ debug = SpackCommand('debug') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.db def test_create_db_tarball(tmpdir, database): with tmpdir.as_cwd(): @@ -46,6 +48,7 @@ def test_create_db_tarball(tmpdir, database): assert spec_suffix in contents +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_report(): out = debug('report') host_platform = spack.platforms.host() diff --git a/lib/spack/spack/test/cmd/dependencies.py b/lib/spack/spack/test/cmd/dependencies.py index 29d55e0269..7c76f031d2 100644 --- a/lib/spack/spack/test/cmd/dependencies.py +++ b/lib/spack/spack/test/cmd/dependencies.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import re +import sys import pytest @@ -20,6 +21,7 @@ mpi_deps = ['fake'] +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_direct_dependencies(mock_packages): out = dependencies('mpileaks') actual = set(re.split(r'\s+', out.strip())) @@ -27,6 +29,7 @@ def test_direct_dependencies(mock_packages): assert expected == actual +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_transitive_dependencies(mock_packages): out = dependencies('--transitive', 'mpileaks') actual = set(re.split(r'\s+', out.strip())) @@ -35,6 +38,7 @@ def test_transitive_dependencies(mock_packages): assert expected == actual +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_transitive_dependencies_with_deptypes(mock_packages): out = dependencies('--transitive', '--deptype=link,run', 'dtbuild1') deps = set(re.split(r'\s+', out.strip())) @@ -49,6 +53,7 @@ def test_transitive_dependencies_with_deptypes(mock_packages): assert set(['dtlink2']) == deps +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.db def test_direct_installed_dependencies(mock_packages, database): with color_when(False): @@ -66,6 +71,7 @@ def test_direct_installed_dependencies(mock_packages, database): assert expected == hashes +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.db def test_transitive_installed_dependencies(mock_packages, database): with color_when(False): diff --git a/lib/spack/spack/test/cmd/dependents.py b/lib/spack/spack/test/cmd/dependents.py index 93c11aff9d..6cee5a22a5 100644 --- a/lib/spack/spack/test/cmd/dependents.py +++ b/lib/spack/spack/test/cmd/dependents.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import re +import sys import pytest @@ -15,6 +16,7 @@ dependents = SpackCommand('dependents') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_immediate_dependents(mock_packages): out = dependents('libelf') actual = set(re.split(r'\s+', out.strip())) @@ -28,6 +30,7 @@ def test_immediate_dependents(mock_packages): ]) +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_transitive_dependents(mock_packages): out = dependents('--transitive', 'libelf') actual = set(re.split(r'\s+', out.strip())) @@ -44,6 +47,7 @@ def test_transitive_dependents(mock_packages): ]) +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.db def test_immediate_installed_dependents(mock_packages, database): with color_when(False): @@ -61,6 +65,7 @@ def test_immediate_installed_dependents(mock_packages, database): assert expected == hashes +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.db def test_transitive_installed_dependents(mock_packages, database): with color_when(False): diff --git a/lib/spack/spack/test/cmd/deprecate.py b/lib/spack/spack/test/cmd/deprecate.py index 4c369f9633..17db777acf 100644 --- a/lib/spack/spack/test/cmd/deprecate.py +++ b/lib/spack/spack/test/cmd/deprecate.py @@ -2,6 +2,9 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) + +import sys + import pytest import spack.store @@ -15,6 +18,7 @@ activate = SpackCommand('activate') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_deprecate(mock_packages, mock_archive, mock_fetch, install_mockery): install('libelf@0.8.13') install('libelf@0.8.10') @@ -30,6 +34,7 @@ def test_deprecate(mock_packages, mock_archive, mock_fetch, install_mockery): assert non_deprecated == spack.store.db.query('libelf@0.8.13') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_deprecate_fails_no_such_package(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that deprecating a spec that is not installed fails. @@ -47,6 +52,7 @@ def test_deprecate_fails_no_such_package(mock_packages, mock_archive, assert "Spec 'libelf@0.8.13' matches no installed packages" in output +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_deprecate_install(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that the ```-i`` option allows us to deprecate in favor of a spec @@ -65,6 +71,7 @@ def test_deprecate_install(mock_packages, mock_archive, mock_fetch, assert non_deprecated[0].satisfies('libelf@0.8.13') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_deprecate_deps(mock_packages, mock_archive, mock_fetch, install_mockery): """Test that the deprecate command deprecates all dependencies properly.""" @@ -89,6 +96,7 @@ def test_deprecate_deps(mock_packages, mock_archive, mock_fetch, assert sorted(deprecated) == sorted(list(old_spec.traverse())) +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_deprecate_fails_active_extensions(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that active extensions and their extendees cannot be @@ -108,6 +116,7 @@ def test_deprecate_fails_active_extensions(mock_packages, mock_archive, assert 'is an active extension of' in output +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_uninstall_deprecated(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that we can still uninstall deprecated packages.""" @@ -124,6 +133,7 @@ def test_uninstall_deprecated(mock_packages, mock_archive, mock_fetch, assert spack.store.db.query() == non_deprecated +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_deprecate_already_deprecated(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that we can re-deprecate a spec to change its deprecator.""" @@ -149,6 +159,7 @@ def test_deprecate_already_deprecated(mock_packages, mock_archive, mock_fetch, assert deprecator == spack.spec.Spec('libelf@0.8.13').concretized() +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that when a deprecator spec is deprecated, its deprecatee specs @@ -179,6 +190,7 @@ def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, assert second_deprecator == final_deprecator +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_concretize_deprecated(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that the concretizer throws an error if we concretize to a diff --git a/lib/spack/spack/test/cmd/dev_build.py b/lib/spack/spack/test/cmd/dev_build.py index 051d068d04..6ce1aca34f 100644 --- a/lib/spack/spack/test/cmd/dev_build.py +++ b/lib/spack/spack/test/cmd/dev_build.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -18,6 +19,7 @@ env = SpackCommand('env') +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_dev_build_basics(tmpdir, mock_packages, install_mockery): spec = spack.spec.Spec('dev-build-test-install@0.0.0 dev_path=%s' % tmpdir) spec.concretize() @@ -37,6 +39,7 @@ def test_dev_build_basics(tmpdir, mock_packages, install_mockery): assert os.path.exists(str(tmpdir)) +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_dev_build_before(tmpdir, mock_packages, install_mockery): spec = spack.spec.Spec('dev-build-test-install@0.0.0 dev_path=%s' % tmpdir) spec.concretize() @@ -54,6 +57,7 @@ def test_dev_build_before(tmpdir, mock_packages, install_mockery): assert not os.path.exists(spec.prefix) +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_dev_build_until(tmpdir, mock_packages, install_mockery): spec = spack.spec.Spec('dev-build-test-install@0.0.0 dev_path=%s' % tmpdir) spec.concretize() @@ -72,6 +76,7 @@ def test_dev_build_until(tmpdir, mock_packages, install_mockery): assert not spack.store.db.query(spec, installed=True) +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_dev_build_until_last_phase(tmpdir, mock_packages, install_mockery): # Test that we ignore the last_phase argument if it is already last spec = spack.spec.Spec('dev-build-test-install@0.0.0 dev_path=%s' % tmpdir) @@ -92,6 +97,7 @@ def test_dev_build_until_last_phase(tmpdir, mock_packages, install_mockery): assert os.path.exists(str(tmpdir)) +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_dev_build_before_until(tmpdir, mock_packages, install_mockery, capsys): spec = spack.spec.Spec('dev-build-test-install@0.0.0 dev_path=%s' % tmpdir) spec.concretize() @@ -133,6 +139,7 @@ def mock_module_noop(*args): pass +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_dev_build_drop_in(tmpdir, mock_packages, monkeypatch, install_mockery, working_env): monkeypatch.setattr(os, 'execvp', print_spack_cc) @@ -145,6 +152,7 @@ def test_dev_build_drop_in(tmpdir, mock_packages, monkeypatch, assert "lib/spack/env" in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_dev_build_fails_already_installed(tmpdir, mock_packages, install_mockery): spec = spack.spec.Spec('dev-build-test-install@0.0.0 dev_path=%s' % tmpdir) @@ -179,6 +187,7 @@ def test_dev_build_fails_no_version(mock_packages): assert 'dev-build spec must have a single, concrete version' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Filename/extension is too long") def test_dev_build_env(tmpdir, mock_packages, install_mockery, mutable_mock_env_path): """Test Spack does dev builds for packages in develop section of env.""" @@ -216,6 +225,7 @@ def test_dev_build_env(tmpdir, mock_packages, install_mockery, assert f.read() == spec.package.replacement_string +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_dev_build_env_version_mismatch(tmpdir, mock_packages, install_mockery, mutable_mock_env_path): """Test Spack constraints concretization by develop specs.""" @@ -249,6 +259,7 @@ def test_dev_build_env_version_mismatch(tmpdir, mock_packages, install_mockery, install() +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs") def test_dev_build_multiple(tmpdir, mock_packages, install_mockery, mutable_mock_env_path, mock_fetch): """Test spack install with multiple developer builds""" @@ -304,6 +315,7 @@ def test_dev_build_multiple(tmpdir, mock_packages, install_mockery, assert f.read() == spec.package.replacement_string +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") def test_dev_build_env_dependency(tmpdir, mock_packages, install_mockery, mock_fetch, mutable_mock_env_path): """ @@ -352,6 +364,7 @@ def test_dev_build_env_dependency(tmpdir, mock_packages, install_mockery, assert spec.satisfies('^dev_path=*') +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") @pytest.mark.parametrize('test_spec', ['dev-build-test-install', 'dependent-of-dev-build']) def test_dev_build_rebuild_on_source_changes( diff --git a/lib/spack/spack/test/cmd/develop.py b/lib/spack/spack/test/cmd/develop.py index 5e9bdd381e..fcbb490cff 100644 --- a/lib/spack/spack/test/cmd/develop.py +++ b/lib/spack/spack/test/cmd/develop.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os import shutil +import sys import pytest @@ -40,6 +41,7 @@ def check_develop(self, env, spec, path=None): else: assert yaml_entry['path'] == path + @pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_develop_no_path_no_clone(self): env('create', 'test') with ev.read('test') as e: @@ -48,18 +50,21 @@ def test_develop_no_path_no_clone(self): develop('--no-clone', 'mpich@1.0') self.check_develop(e, spack.spec.Spec('mpich@1.0')) + @pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_develop_no_clone(self, tmpdir): env('create', 'test') with ev.read('test') as e: develop('--no-clone', '-p', str(tmpdir), 'mpich@1.0') self.check_develop(e, spack.spec.Spec('mpich@1.0'), str(tmpdir)) + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_develop(self): env('create', 'test') with ev.read('test') as e: develop('mpich@1.0') self.check_develop(e, spack.spec.Spec('mpich@1.0')) + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_develop_no_args(self): env('create', 'test') with ev.read('test') as e: @@ -71,6 +76,7 @@ def test_develop_no_args(self): develop() self.check_develop(e, spack.spec.Spec('mpich@1.0')) + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_develop_twice(self): env('create', 'test') with ev.read('test') as e: @@ -85,6 +91,7 @@ def test_develop_twice(self): self.check_develop(e, spack.spec.Spec('mpich@1.0')) assert len(e.dev_specs) == 1 + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_develop_update_path(self, tmpdir): env('create', 'test') with ev.read('test') as e: @@ -93,6 +100,7 @@ def test_develop_update_path(self, tmpdir): self.check_develop(e, spack.spec.Spec('mpich@1.0'), str(tmpdir)) assert len(e.dev_specs) == 1 + @pytest.mark.skipif(sys.platform == 'win32', reason="not implemented on windows") def test_develop_update_spec(self): env('create', 'test') with ev.read('test') as e: diff --git a/lib/spack/spack/test/cmd/diff.py b/lib/spack/spack/test/cmd/diff.py index 039b3dc831..1568f391c4 100644 --- a/lib/spack/spack/test/cmd/diff.py +++ b/lib/spack/spack/test/cmd/diff.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import spack.cmd.diff @@ -43,6 +45,8 @@ def test_diff_cmd(install_mockery, mock_fetch, mock_archive, mock_packages): assert ['hash', 'mpileaks %s' % specB.dag_hash()] in c['b_not_a'] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_load_first(install_mockery, mock_fetch, mock_archive, mock_packages): """Test with and without the --first option""" install_cmd('mpileaks') diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index b1ff4291e9..8d88cfcfbd 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import glob import os +import sys from argparse import Namespace import pytest @@ -41,6 +42,11 @@ uninstall = SpackCommand('uninstall') find = SpackCommand('find') +if sys.platform == 'win32': + sep = 'C:\\' +else: + sep = os.sep + def check_mpileaks_and_deps_in_view(viewdir): """Check that the expected install directories exist.""" @@ -60,6 +66,8 @@ def test_add(): assert Spec('mpileaks') in e.user_specs +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_env_add_virtual(): env('create', 'test') @@ -128,6 +136,8 @@ def test_env_remove(capfd): assert 'bar' not in out +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_concretize(): e = ev.create('test') e.add('mpileaks') @@ -136,6 +146,8 @@ def test_concretize(): assert any(x.name == 'mpileaks' for x in env_specs) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="InstallError:Wrong cmake was in environment") def test_env_uninstalled_specs(install_mockery, mock_fetch): e = ev.create('test') e.add('cmake-client') @@ -149,6 +161,8 @@ def test_env_uninstalled_specs(install_mockery, mock_fetch): assert any(s.name == 'mpileaks' for s in e.uninstalled_specs()) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='InstallError: Wrong cmake was in environment') def test_env_install_all(install_mockery, mock_fetch): e = ev.create('test') e.add('cmake-client') @@ -159,6 +173,8 @@ def test_env_install_all(install_mockery, mock_fetch): assert spec.package.installed +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='InstallError: Wrong cmake was in environment') def test_env_install_single_spec(install_mockery, mock_fetch): env('create', 'test') install = SpackCommand('install') @@ -173,6 +189,7 @@ def test_env_install_single_spec(install_mockery, mock_fetch): assert e.specs_by_hash[e.concretized_order[0]].name == 'cmake-client' +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_env_roots_marked_explicit(install_mockery, mock_fetch): install = SpackCommand('install') install('dependent-install') @@ -194,6 +211,8 @@ def test_env_roots_marked_explicit(install_mockery, mock_fetch): assert len(explicit) == 2 +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='InstallError: Wrong cmake was in environment') def test_env_modifications_error_on_activate( install_mockery, mock_fetch, monkeypatch, capfd): env('create', 'test') @@ -216,6 +235,8 @@ def setup_error(pkg, env): assert "Warning: couldn't get environment settings" in err +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Error: filename or extension is too long') def test_activate_adds_transitive_run_deps_to_path( install_mockery, mock_fetch, monkeypatch): env('create', 'test') @@ -230,6 +251,8 @@ def test_activate_adds_transitive_run_deps_to_path( assert env_variables['DEPENDENCY_ENV_VAR'] == '1' +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='InstallError: Wrong cmake was in environment:') def test_env_install_same_spec_twice(install_mockery, mock_fetch): env('create', 'test') @@ -244,6 +267,8 @@ def test_env_install_same_spec_twice(install_mockery, mock_fetch): assert 'already installed' in out +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_env_definition_symlink(install_mockery, mock_fetch, tmpdir): filepath = str(tmpdir.join('spack.yaml')) filepath_mid = str(tmpdir.join('spack_mid.yaml')) @@ -263,6 +288,8 @@ def test_env_definition_symlink(install_mockery, mock_fetch, tmpdir): assert os.path.islink(filepath_mid) +@pytest.mark.skipif(sys.platform == "win32", + reason='Logging error') def test_env_install_two_specs_same_dep( install_mockery, mock_fetch, tmpdir, capsys): """Test installation of two packages that share a dependency with no @@ -298,6 +325,8 @@ def test_env_install_two_specs_same_dep( assert a, 'Expected a to be installed' +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_remove_after_concretize(): e = ev.create('test') @@ -321,6 +350,8 @@ def test_remove_after_concretize(): assert not any(s.name == 'mpileaks' for s in env_specs) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_remove_command(): env('create', 'test') assert 'test' in env('list') @@ -384,6 +415,8 @@ def test_environment_status(capsys, tmpdir): assert 'in current directory' in env('status') +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows - uses pkgconf') def test_env_status_broken_view( mutable_mock_env_path, mock_archive, mock_fetch, mock_packages, install_mockery, tmpdir @@ -405,6 +438,8 @@ def test_env_status_broken_view( assert 'includes out of date packages or repos' not in output +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows - uses pkgconf') def test_env_activate_broken_view( mutable_mock_env_path, mock_archive, mock_fetch, mock_packages, install_mockery @@ -423,6 +458,8 @@ def test_env_activate_broken_view( env('activate', '--sh', 'test') +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_to_lockfile_dict(): e = ev.create('test') e.add('mpileaks') @@ -435,6 +472,8 @@ def test_to_lockfile_dict(): assert e.specs_by_hash == e_copy.specs_by_hash +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_env_repo(): e = ev.create('test') e.add('mpileaks') @@ -448,6 +487,8 @@ def test_env_repo(): assert package.namespace == 'builtin.mock' +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_user_removed_spec(): """Ensure a user can remove from any position in the spack.yaml file.""" initial_yaml = StringIO("""\ @@ -482,6 +523,8 @@ def test_user_removed_spec(): assert not any(x.name == 'hypre' for x in env_specs) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_init_from_lockfile(tmpdir): """Test that an environment can be instantiated from a lockfile.""" initial_yaml = StringIO("""\ @@ -508,6 +551,8 @@ def test_init_from_lockfile(tmpdir): assert s1 == s2 +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_init_from_yaml(tmpdir): """Test that an environment can be instantiated from a lockfile.""" initial_yaml = StringIO("""\ @@ -531,6 +576,8 @@ def test_init_from_yaml(tmpdir): assert not e2.specs_by_hash +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows - uses pkgconf') @pytest.mark.usefixtures('config') def test_env_view_external_prefix( tmpdir_factory, mutable_database, mock_packages @@ -603,6 +650,8 @@ def test_init_with_file_and_remove(tmpdir): assert 'test' not in out +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_env_with_config(): test_config = """\ env: @@ -622,6 +671,8 @@ def test_env_with_config(): for x in e._get_environment_specs()) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_with_config_bad_include(capfd): env_name = 'test_bad_include' test_config = """\ @@ -641,10 +692,12 @@ def test_with_config_bad_include(capfd): assert 'missing include' in err assert '/no/such/directory' in err - assert 'no/such/file.yaml' in err + assert os.path.join('no', 'such', 'file.yaml') in err assert ev.active_environment() is None +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_env_with_include_config_files_same_basename(): test_config = """\ env: @@ -687,6 +740,8 @@ def test_env_with_include_config_files_same_basename(): assert(environment_specs[1].satisfies('mpileaks@2.2')) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_env_with_included_config_file(): test_config = """\ env: @@ -712,6 +767,8 @@ def test_env_with_included_config_file(): for x in e._get_environment_specs()) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_env_with_included_config_scope(): config_scope_path = os.path.join(ev.root('test'), 'config') test_config = """\ @@ -741,6 +798,8 @@ def test_env_with_included_config_scope(): for x in e._get_environment_specs()) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_env_with_included_config_var_path(): config_var_path = os.path.join('$tempdir', 'included-config.yaml') test_config = """\ @@ -770,6 +829,8 @@ def test_env_with_included_config_var_path(): for x in e._get_environment_specs()) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_env_config_precedence(): test_config = """\ env: @@ -805,6 +866,8 @@ def test_env_config_precedence(): x.satisfies('libelf@0.8.12') for x in e._get_environment_specs()) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_included_config_precedence(): test_config = """\ env: @@ -859,6 +922,8 @@ def test_bad_env_yaml_format(tmpdir): assert "'spacks' was unexpected" in str(e) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_env_loads(install_mockery, mock_fetch): env('create', 'test') @@ -880,6 +945,8 @@ def test_env_loads(install_mockery, mock_fetch): assert 'module load mpileaks' in contents +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") @pytest.mark.disable_clean_stage_check def test_stage(mock_stage, mock_fetch, install_mockery): env('create', 'test') @@ -918,6 +985,8 @@ def test_env_commands_die_with_no_env_arg(): env('status') +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_env_blocks_uninstall(mock_stage, mock_fetch, install_mockery): env('create', 'test') with ev.read('test'): @@ -940,6 +1009,8 @@ def test_roots_display_with_variants(): assert "boost +shared" in out +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_uninstall_removes_from_env(mock_stage, mock_fetch, install_mockery): env('create', 'test') with ev.read('test'): @@ -982,6 +1053,8 @@ def create_v1_lockfile_dict(roots, all_specs): return test_lockfile_dict +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows - uses pkgconf") @pytest.mark.usefixtures('config') def test_read_old_lock_and_write_new(tmpdir): build_only = ('build',) @@ -1013,11 +1086,14 @@ def test_read_old_lock_and_write_new(tmpdir): y.build_hash()]) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows - uses pkgconf") @pytest.mark.usefixtures('config') def test_read_old_lock_creates_backup(tmpdir): """When reading a version-1 lockfile, make sure that a backup of that file is created. """ + mock_repo = MockPackageMultiRepo() y = mock_repo.add_package('y', [], []) @@ -1040,6 +1116,8 @@ def test_read_old_lock_creates_backup(tmpdir): assert y.dag_hash() in lockfile_dict_v1['concrete_specs'] +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows - uses pkgconf") @pytest.mark.usefixtures('config') def test_indirect_build_dep(): """Simple case of X->Y->Z where Y is a build/link dep and Z is a @@ -1075,6 +1153,8 @@ def noop(*args): assert x_env_spec == x_concretized +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows - uses pkgconf") @pytest.mark.usefixtures('config') def test_store_different_build_deps(): r"""Ensure that an environment can store two instances of a build-only @@ -1128,6 +1208,8 @@ def noop(*args): assert x_read['z'] != y_read['z'] +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Fails on windows') def test_env_updates_view_install( tmpdir, mock_stage, mock_fetch, install_mockery): view_dir = tmpdir.join('view') @@ -1139,6 +1221,8 @@ def test_env_updates_view_install( check_mpileaks_and_deps_in_view(view_dir) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Fails on windows') def test_env_view_fails( tmpdir, mock_packages, mock_stage, mock_fetch, install_mockery): view_dir = tmpdir.join('view') @@ -1151,6 +1235,8 @@ def test_env_view_fails( install('--fake') +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_env_without_view_install( tmpdir, mock_stage, mock_fetch, install_mockery): # Test enabling a view after installing specs @@ -1173,6 +1259,8 @@ def test_env_without_view_install( check_mpileaks_and_deps_in_view(view_dir) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_env_config_view_default( tmpdir, mock_stage, mock_fetch, install_mockery): # This config doesn't mention whether a view is enabled @@ -1181,7 +1269,6 @@ def test_env_config_view_default( specs: - mpileaks """ - _env_create('test', StringIO(test_config)) with ev.read('test'): @@ -1193,6 +1280,8 @@ def test_env_config_view_default( assert view.get_spec('mpileaks') +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_env_updates_view_install_package( tmpdir, mock_stage, mock_fetch, install_mockery): view_dir = tmpdir.join('view') @@ -1203,6 +1292,8 @@ def test_env_updates_view_install_package( assert os.path.exists(str(view_dir.join('.spack/mpileaks'))) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_env_updates_view_add_concretize( tmpdir, mock_stage, mock_fetch, install_mockery): view_dir = tmpdir.join('view') @@ -1215,6 +1306,8 @@ def test_env_updates_view_add_concretize( check_mpileaks_and_deps_in_view(view_dir) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_env_updates_view_uninstall( tmpdir, mock_stage, mock_fetch, install_mockery): view_dir = tmpdir.join('view') @@ -1230,6 +1323,8 @@ def test_env_updates_view_uninstall( check_viewdir_removal(view_dir) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_env_updates_view_uninstall_referenced_elsewhere( tmpdir, mock_stage, mock_fetch, install_mockery): view_dir = tmpdir.join('view') @@ -1247,6 +1342,8 @@ def test_env_updates_view_uninstall_referenced_elsewhere( check_viewdir_removal(view_dir) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_env_updates_view_remove_concretize( tmpdir, mock_stage, mock_fetch, install_mockery): view_dir = tmpdir.join('view') @@ -1265,6 +1362,8 @@ def test_env_updates_view_remove_concretize( check_viewdir_removal(view_dir) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_env_updates_view_force_remove( tmpdir, mock_stage, mock_fetch, install_mockery): view_dir = tmpdir.join('view') @@ -1280,6 +1379,8 @@ def test_env_updates_view_force_remove( check_viewdir_removal(view_dir) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_env_activate_view_fails( tmpdir, mock_stage, mock_fetch, install_mockery): """Sanity check on env activate to make sure it requires shell support""" @@ -1354,6 +1455,8 @@ def test_stack_yaml_definitions_as_constraints_on_matrix(tmpdir): assert Spec('callpath^mpich@3.0.3') in test.user_specs +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") @pytest.mark.regression('12095') def test_stack_yaml_definitions_write_reference(tmpdir): filename = str(tmpdir.join('spack.yaml')) @@ -1420,6 +1523,8 @@ def test_stack_yaml_remove_from_list(tmpdir): assert Spec('callpath') in test.user_specs +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_stack_yaml_remove_from_list_force(tmpdir): filename = str(tmpdir.join('spack.yaml')) with open(filename, 'w') as f: @@ -1470,6 +1575,8 @@ def test_stack_yaml_remove_from_matrix_no_effect(tmpdir): assert before == after +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_stack_yaml_force_remove_from_matrix(tmpdir): filename = str(tmpdir.join('spack.yaml')) with open(filename, 'w') as f: @@ -1503,6 +1610,8 @@ def test_stack_yaml_force_remove_from_matrix(tmpdir): assert mpileaks_spec not in after_conc +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_stack_concretize_extraneous_deps(tmpdir, config, mock_packages): # FIXME: The new concretizer doesn't handle yet soft # FIXME: constraints for stacks @@ -1538,6 +1647,8 @@ def test_stack_concretize_extraneous_deps(tmpdir, config, mock_packages): assert concrete.satisfies('^mpi', strict=True) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_stack_concretize_extraneous_variants(tmpdir, config, mock_packages): filename = str(tmpdir.join('spack.yaml')) with open(filename, 'w') as f: @@ -1569,6 +1680,8 @@ def test_stack_concretize_extraneous_variants(tmpdir, config, mock_packages): user.variants['shared'].value) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_stack_concretize_extraneous_variants_with_dash(tmpdir, config, mock_packages): filename = str(tmpdir.join('spack.yaml')) @@ -1617,6 +1730,8 @@ def test_stack_definition_extension(tmpdir): assert Spec('callpath') in test.user_specs +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_stack_definition_conditional_false(tmpdir): filename = str(tmpdir.join('spack.yaml')) with open(filename, 'w') as f: @@ -1774,6 +1889,8 @@ def test_stack_definition_conditional_add_write(tmpdir): assert 'zmpi' not in packages_lists[1]['packages'] +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_stack_combinatorial_view(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): filename = str(tmpdir.join('spack.yaml')) @@ -1806,6 +1923,8 @@ def test_stack_combinatorial_view(tmpdir, mock_fetch, mock_packages, (spec.version, spec.compiler.name))) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_stack_view_select(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): filename = str(tmpdir.join('spack.yaml')) @@ -1844,6 +1963,8 @@ def test_stack_view_select(tmpdir, mock_fetch, mock_packages, (spec.version, spec.compiler.name))) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_stack_view_exclude(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): filename = str(tmpdir.join('spack.yaml')) @@ -1882,6 +2003,8 @@ def test_stack_view_exclude(tmpdir, mock_fetch, mock_packages, (spec.version, spec.compiler.name))) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_stack_view_select_and_exclude(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): filename = str(tmpdir.join('spack.yaml')) @@ -1921,6 +2044,8 @@ def test_stack_view_select_and_exclude(tmpdir, mock_fetch, mock_packages, (spec.version, spec.compiler.name))) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_view_link_roots(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): filename = str(tmpdir.join('spack.yaml')) @@ -1962,6 +2087,8 @@ def test_view_link_roots(tmpdir, mock_fetch, mock_packages, mock_archive, (spec.version, spec.compiler.name))) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_view_link_run(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): yaml = str(tmpdir.join('spack.yaml')) @@ -1993,6 +2120,8 @@ def test_view_link_run(tmpdir, mock_fetch, mock_packages, mock_archive, assert not os.path.exists(os.path.join(viewdir, pkg)) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') @pytest.mark.parametrize('link_type', ['hardlink', 'copy', 'symlink']) def test_view_link_type(link_type, tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): @@ -2022,6 +2151,8 @@ def test_view_link_type(link_type, tmpdir, mock_fetch, mock_packages, mock_archi assert os.path.islink(file_to_test) == (link_type == 'symlink') +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_view_link_all(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): filename = str(tmpdir.join('spack.yaml')) @@ -2062,6 +2193,8 @@ def test_view_link_all(tmpdir, mock_fetch, mock_packages, mock_archive, (spec.version, spec.compiler.name))) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_stack_view_activate_from_default(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): filename = str(tmpdir.join('spack.yaml')) @@ -2093,6 +2226,8 @@ def test_stack_view_activate_from_default(tmpdir, mock_fetch, mock_packages, assert 'FOOBAR=mpileaks' in shell +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_stack_view_no_activate_without_default(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): @@ -2123,6 +2258,8 @@ def test_stack_view_no_activate_without_default(tmpdir, mock_fetch, assert viewdir not in shell +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_stack_view_multiple_views(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): filename = str(tmpdir.join('spack.yaml')) @@ -2225,6 +2362,8 @@ def test_env_activate_default_view_root_unconditional(mutable_mock_env_path): 'export PATH="{0}'.format(viewdir_bin) in out +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_concretize_user_specs_together(): e = ev.create('coconcretization') e.concretization = 'together' @@ -2253,6 +2392,8 @@ def test_concretize_user_specs_together(): assert all('mpich' not in spec for _, spec in e.concretized_specs()) +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_cant_install_single_spec_when_concretizing_together(): e = ev.create('coconcretization') e.concretization = 'together' @@ -2262,6 +2403,8 @@ def test_cant_install_single_spec_when_concretizing_together(): e.install_all() +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_duplicate_packages_raise_when_concretizing_together(): e = ev.create('coconcretization') e.concretization = 'together' @@ -2274,6 +2417,8 @@ def test_duplicate_packages_raise_when_concretizing_together(): e.concretize() +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") def test_env_write_only_non_default(): env('create', 'test') @@ -2284,6 +2429,8 @@ def test_env_write_only_non_default(): assert yaml == ev.default_manifest_yaml +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") @pytest.mark.regression('20526') def test_env_write_only_non_default_nested(tmpdir): # setup an environment file @@ -2318,6 +2465,8 @@ def test_env_write_only_non_default_nested(tmpdir): assert manifest == contents +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") @pytest.fixture def packages_yaml_v015(tmpdir): """Return the path to an existing manifest in the v0.15.x format @@ -2408,6 +2557,8 @@ def test_can_update_attributes_with_override(tmpdir): env('update', '-y', str(abspath.dirname)) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') @pytest.mark.regression('18338') def test_newline_in_commented_sequence_is_not_an_issue(tmpdir): spack_yaml = """ @@ -2443,6 +2594,8 @@ def extract_build_hash(environment): assert libelf_first_hash == libelf_second_hash +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason="Not supported on Windows (yet)") @pytest.mark.regression('18441') def test_lockfile_not_deleted_on_write_error(tmpdir, monkeypatch): raw_yaml = """ @@ -2516,7 +2669,8 @@ def test_rewrite_rel_dev_path_new_dir(tmpdir): env('create', '-d', str(dest_env), str(spack_yaml)) with ev.Environment(str(dest_env)) as e: assert e.dev_specs['mypkg1']['path'] == str(build_folder) - assert e.dev_specs['mypkg2']['path'] == '/some/other/path' + assert e.dev_specs['mypkg2']['path'] == sep + os.path.join('some', + 'other', 'path') def test_rewrite_rel_dev_path_named_env(tmpdir): @@ -2526,7 +2680,8 @@ def test_rewrite_rel_dev_path_named_env(tmpdir): env('create', 'named_env', str(spack_yaml)) with ev.read('named_env') as e: assert e.dev_specs['mypkg1']['path'] == str(build_folder) - assert e.dev_specs['mypkg2']['path'] == '/some/other/path' + assert e.dev_specs['mypkg2']['path'] == sep + os.path.join('some', + 'other', 'path') def test_rewrite_rel_dev_path_original_dir(tmpdir): @@ -2574,6 +2729,8 @@ def test_custom_version_concretize_together(tmpdir): assert any('hdf5@myversion' in spec for _, spec in e.concretized_specs()) +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_modules_relative_to_views(tmpdir, install_mockery, mock_fetch): spack_yaml = """ spack: @@ -2605,6 +2762,8 @@ def test_modules_relative_to_views(tmpdir, install_mockery, mock_fetch): assert spec.prefix not in contents +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_multiple_modules_post_env_hook(tmpdir, install_mockery, mock_fetch): spack_yaml = """ spack: @@ -2707,10 +2866,14 @@ def test_custom_store_in_environment(mutable_config, tmpdir): install_tree: root: /tmp/store """) + if os.name == 'nt': + sep = '\\' + else: + sep = '/' current_store_root = str(spack.store.root) - assert str(current_store_root) != '/tmp/store' + assert str(current_store_root) != sep + os.path.join('tmp', 'store') with spack.environment.Environment(str(tmpdir)): - assert str(spack.store.root) == '/tmp/store' + assert str(spack.store.root) == sep + os.path.join('tmp', 'store') assert str(spack.store.root) == current_store_root diff --git a/lib/spack/spack/test/cmd/extensions.py b/lib/spack/spack/test/cmd/extensions.py index 52f78446ac..14747d0439 100644 --- a/lib/spack/spack/test/cmd/extensions.py +++ b/lib/spack/spack/test/cmd/extensions.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest from spack.main import SpackCommand, SpackCommandError @@ -25,6 +27,7 @@ def python_database(mock_packages, mutable_database): yield +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_extensions(mock_packages, python_database, config, capsys): ext2 = Spec("py-extension2").concretized() diff --git a/lib/spack/spack/test/cmd/external.py b/lib/spack/spack/test/cmd/external.py index f1bcad0c89..3d7554c2eb 100644 --- a/lib/spack/spack/test/cmd/external.py +++ b/lib/spack/spack/test/cmd/external.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os import os.path +import sys import pytest @@ -24,6 +25,7 @@ def _mock_search(path_hints=None): return _factory +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_find_external_single_package(mock_executable, executables_found): pkgs_to_check = [spack.repo.get('cmake')] executables_found({ @@ -38,6 +40,7 @@ def test_find_external_single_package(mock_executable, executables_found): assert single_entry.spec == Spec('cmake@1.foo') +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_find_external_two_instances_same_package(mock_executable, executables_found): pkgs_to_check = [spack.repo.get('cmake')] @@ -92,6 +95,7 @@ def test_get_executables(working_env, mock_executable): external = SpackCommand('external') +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_find_external_cmd(mutable_config, working_env, mock_executable): """Test invoking 'spack external find' with additional package arguments, which restricts the set of packages that Spack looks for. @@ -109,6 +113,7 @@ def test_find_external_cmd(mutable_config, working_env, mock_executable): assert {'spec': 'cmake@1.foo', 'prefix': prefix} in cmake_externals +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_find_external_cmd_not_buildable( mutable_config, working_env, mock_executable): """When the user invokes 'spack external find --not-buildable', the config @@ -122,6 +127,7 @@ def test_find_external_cmd_not_buildable( assert not pkgs_cfg['cmake']['buildable'] +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_find_external_cmd_full_repo( mutable_config, working_env, mock_executable, mutable_mock_repo): """Test invoking 'spack external find --all' with no additional arguments @@ -180,11 +186,13 @@ def test_find_external_merge(mutable_config, mutable_mock_repo): 'prefix': '/x/y2/'} in pkg_externals +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_list_detectable_packages(mutable_config, mutable_mock_repo): external("list") assert external.returncode == 0 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_packages_yaml_format(mock_executable, mutable_config, monkeypatch): # Prepare an environment to detect a fake gcc gcc_exe = mock_executable('gcc', output="echo 4.2.1") @@ -209,6 +217,7 @@ def test_packages_yaml_format(mock_executable, mutable_config, monkeypatch): assert extra_attributes['compilers']['c'] == gcc_exe +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_overriding_prefix(mock_executable, mutable_config, monkeypatch): # Prepare an environment to detect a fake gcc that # override its external prefix @@ -238,6 +247,7 @@ def _determine_variants(cls, exes, version_str): assert externals[0]['prefix'] == '/opt/gcc/bin' +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_new_entries_are_reported_correctly( mock_executable, mutable_config, monkeypatch ): @@ -256,6 +266,7 @@ def test_new_entries_are_reported_correctly( assert 'No new external packages detected' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.parametrize('command_args', [ ('-t', 'build-tools'), ('-t', 'build-tools', 'cmake'), diff --git a/lib/spack/spack/test/cmd/fetch.py b/lib/spack/spack/test/cmd/fetch.py index da56fbd528..59eedc795f 100644 --- a/lib/spack/spack/test/cmd/fetch.py +++ b/lib/spack/spack/test/cmd/fetch.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import spack.environment as ev @@ -14,6 +16,7 @@ ) +@pytest.mark.skipif(sys.platform == 'win32', reason="Hangs on windows") @pytest.mark.disable_clean_stage_check def test_fetch_in_env( tmpdir, mock_archive, mock_stage, mock_fetch, install_mockery @@ -27,6 +30,7 @@ def test_fetch_in_env( SpackCommand("fetch")() +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.disable_clean_stage_check def test_fetch_single_spec( tmpdir, mock_archive, mock_stage, mock_fetch, install_mockery @@ -34,6 +38,7 @@ def test_fetch_single_spec( SpackCommand("fetch")("mpileaks") +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.disable_clean_stage_check def test_fetch_multiple_specs( tmpdir, mock_archive, mock_stage, mock_fetch, install_mockery diff --git a/lib/spack/spack/test/cmd/find.py b/lib/spack/spack/test/cmd/find.py index eb512a15cb..cc2b51590d 100644 --- a/lib/spack/spack/test/cmd/find.py +++ b/lib/spack/spack/test/cmd/find.py @@ -6,6 +6,7 @@ import argparse import json import os +import sys import pytest @@ -48,6 +49,7 @@ def display(x, *args, **kwargs): monkeypatch.setattr(spack.cmd, 'display_specs', display) +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_query_arguments(): query_arguments = spack.cmd.find.query_arguments @@ -85,6 +87,7 @@ def test_query_arguments(): assert q_args['explicit'] is False +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db @pytest.mark.usefixtures('database', 'mock_display') def test_tag1(parser, specs): @@ -97,6 +100,7 @@ def test_tag1(parser, specs): assert 'mpich2' in [x.name for x in specs] +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db @pytest.mark.usefixtures('database', 'mock_display') def test_tag2(parser, specs): @@ -107,6 +111,7 @@ def test_tag2(parser, specs): assert 'mpich' in [x.name for x in specs] +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db @pytest.mark.usefixtures('database', 'mock_display') def test_tag2_tag3(parser, specs): @@ -116,6 +121,7 @@ def test_tag2_tag3(parser, specs): assert len(specs) == 0 +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_namespaces_shown_correctly(database): out = find() @@ -151,6 +157,7 @@ def _check_json_output_deps(spec_list): assert names.count("libelf") == 1 +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_json(database): output = find('--json', 'mpileaks') @@ -158,6 +165,7 @@ def test_find_json(database): _check_json_output(spec_list) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_json_deps(database): output = find('-d', '--json', 'mpileaks') @@ -165,6 +173,7 @@ def test_find_json_deps(database): _check_json_output_deps(spec_list) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_display_json(database, capsys): specs = [Spec(s).concretized() for s in [ @@ -182,6 +191,7 @@ def test_display_json(database, capsys): _check_json_output(spec_list) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_display_json_deps(database, capsys): specs = [Spec(s).concretized() for s in [ @@ -199,6 +209,7 @@ def test_display_json_deps(database, capsys): _check_json_output_deps(spec_list) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_format(database, config): output = find('--format', '{name}-{^mpi.name}', 'mpileaks') @@ -232,6 +243,7 @@ def test_find_format(database, config): assert c in base32_alphabet +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_format_deps(database, config): output = find('-d', '--format', '{name}-{version}', 'mpileaks', '^zmpi') @@ -247,6 +259,7 @@ def test_find_format_deps(database, config): """ +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_format_deps_paths(database, config): output = find('-dp', '--format', '{name}-{version}', 'mpileaks', '^zmpi') @@ -266,6 +279,7 @@ def test_find_format_deps_paths(database, config): """.format(*prefixes) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_very_long(database, config): output = find('-L', '--no-groups', "mpileaks") @@ -281,12 +295,14 @@ def test_find_very_long(database, config): ]) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_show_compiler(database, config): output = find('--no-groups', '--show-full-compiler', "mpileaks") assert "mpileaks@2.3%gcc@4.5.0" in output +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_not_found(database, config, capsys): with capsys.disabled(): @@ -295,6 +311,7 @@ def test_find_not_found(database, config, capsys): assert find.returncode == 1 +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_no_sections(database, config): output = find() @@ -305,12 +322,14 @@ def test_find_no_sections(database, config): assert "==>" not in output +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.db def test_find_command_basic_usage(database): output = find() assert 'mpileaks' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.regression('9875') def test_find_prefix_in_env(mutable_mock_env_path, install_mockery, mock_fetch, mock_packages, mock_archive, config): @@ -324,6 +343,7 @@ def test_find_prefix_in_env(mutable_mock_env_path, install_mockery, mock_fetch, # Would throw error on regression +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_find_loaded(database, working_env): output = find('--loaded', '--group') assert output == '' diff --git a/lib/spack/spack/test/cmd/gc.py b/lib/spack/spack/test/cmd/gc.py index 0b170c2b03..1f3d776658 100644 --- a/lib/spack/spack/test/cmd/gc.py +++ b/lib/spack/spack/test/cmd/gc.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import spack.environment as ev @@ -12,6 +14,7 @@ gc = spack.main.SpackCommand('gc') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.db def test_no_packages_to_remove(config, mutable_database, capsys): with capsys.disabled(): @@ -19,6 +22,7 @@ def test_no_packages_to_remove(config, mutable_database, capsys): assert 'There are no unused specs.' in output +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.db def test_packages_are_removed(config, mutable_database, capsys): s = spack.spec.Spec('simple-inheritance') @@ -29,6 +33,7 @@ def test_packages_are_removed(config, mutable_database, capsys): assert 'Successfully uninstalled cmake' in output +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") @pytest.mark.db def test_gc_with_environment( config, mutable_database, mutable_mock_env_path, capsys diff --git a/lib/spack/spack/test/cmd/gpg.py b/lib/spack/spack/test/cmd/gpg.py index 85aea2d5c8..694e5df353 100644 --- a/lib/spack/spack/test/cmd/gpg.py +++ b/lib/spack/spack/test/cmd/gpg.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -21,6 +22,7 @@ bootstrap = SpackCommand('bootstrap') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") # test gpg command detection @pytest.mark.parametrize('cmd_name,version', [ ('gpg', 'undetectable'), # undetectable version @@ -55,6 +57,7 @@ def test_no_gpg_in_path(tmpdir, mock_gnupghome, monkeypatch, mutable_config): spack.util.gpg.init(force=True) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.maybeslow def test_gpg(tmpdir, mock_gnupghome): # Verify a file with an empty keyring. diff --git a/lib/spack/spack/test/cmd/graph.py b/lib/spack/spack/test/cmd/graph.py index e66403f548..608b8573c1 100644 --- a/lib/spack/spack/test/cmd/graph.py +++ b/lib/spack/spack/test/cmd/graph.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest from spack.main import SpackCommand, SpackCommandError @@ -10,6 +12,7 @@ graph = SpackCommand('graph') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.usefixtures('mock_packages', 'database') def test_graph_ascii(): @@ -17,6 +20,7 @@ def test_graph_ascii(): graph('--ascii', 'dt-diamond') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.usefixtures('mock_packages', 'database') def test_graph_dot(): @@ -24,6 +28,7 @@ def test_graph_dot(): graph('--dot', 'dt-diamond') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.usefixtures('mock_packages', 'database') def test_graph_static(): @@ -31,6 +36,7 @@ def test_graph_static(): graph('--static', 'dt-diamond') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.usefixtures('mock_packages', 'database') def test_graph_installed(): @@ -42,6 +48,7 @@ def test_graph_installed(): graph('--installed', 'dt-diamond') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.usefixtures('mock_packages', 'database') def test_graph_deptype(): @@ -49,6 +56,7 @@ def test_graph_deptype(): graph('--deptype', 'all', 'dt-diamond') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_graph_no_specs(): """Tests spack graph with no arguments""" diff --git a/lib/spack/spack/test/cmd/info.py b/lib/spack/spack/test/cmd/info.py index 9dbe7950d3..dada99d1dd 100644 --- a/lib/spack/spack/test/cmd/info.py +++ b/lib/spack/spack/test/cmd/info.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import argparse +import sys import pytest @@ -36,6 +37,7 @@ def _print(*args): monkeypatch.setattr(spack.cmd.info.color, 'cprint', _print, raising=False) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.parametrize('pkg', [ 'openmpi', 'trilinos', @@ -48,6 +50,7 @@ def test_it_just_runs(pkg): info(pkg) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_info_noversion(mock_packages, info_lines, mock_print): """Check that a mock package with no versions or variants outputs None.""" info('noversion') @@ -80,6 +83,7 @@ def test_is_externally_detectable(pkg_query, expected, parser, info_lines): assert is_externally_detectable == expected +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.parametrize('pkg_query', [ 'hdf5', 'cloverleaf3d', diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index 81be6273b3..e85ed3d967 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -8,6 +8,7 @@ import os import re import shutil +import sys import time import pytest @@ -42,6 +43,7 @@ def noop(*args, **kwargs): monkeypatch.setattr(spack.installer.PackageInstaller, 'install', noop) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_install_package_and_dependency( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -59,6 +61,7 @@ def test_install_package_and_dependency( assert 'errors="0"' in content +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.disable_clean_stage_check def test_install_runtests_notests(monkeypatch, mock_packages, install_mockery): def check(pkg): @@ -67,6 +70,7 @@ def check(pkg): install('-v', 'dttop') +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.disable_clean_stage_check def test_install_runtests_root(monkeypatch, mock_packages, install_mockery): def check(pkg): @@ -76,6 +80,7 @@ def check(pkg): install('--test=root', 'dttop') +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.disable_clean_stage_check def test_install_runtests_all(monkeypatch, mock_packages, install_mockery): def check(pkg): @@ -86,6 +91,7 @@ def check(pkg): install('--run-tests', 'a') +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_install_package_already_installed( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -107,6 +113,7 @@ def test_install_package_already_installed( assert len(skipped) == 2 +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.parametrize('arguments,expected', [ ([], spack.config.get('config:dirty')), # default from config file (['--clean'], False), @@ -119,6 +126,7 @@ def test_install_dirty_flag(arguments, expected): assert args.dirty == expected +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_package_output(tmpdir, capsys, install_mockery, mock_fetch): """ Ensure output printed from pkgs is captured by output redirection. @@ -140,6 +148,7 @@ def test_package_output(tmpdir, capsys, install_mockery, mock_fetch): assert "AFTER INSTALL" in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_install_output_on_build_error(mock_packages, mock_archive, mock_fetch, config, install_mockery, capfd): @@ -154,6 +163,7 @@ def test_install_output_on_build_error(mock_packages, mock_archive, mock_fetch, assert 'Installing build-error' in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_install_output_on_python_error( mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -163,6 +173,7 @@ def test_install_output_on_python_error( assert 'raise InstallError("Expected failure.")' in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_install_with_source( mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -175,6 +186,7 @@ def test_install_with_source( os.path.join(src, 'configure')) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_env_variables( mock_packages, mock_archive, mock_fetch, config, install_mockery ): @@ -184,6 +196,7 @@ def test_install_env_variables( assert os.path.isfile(spec.package.install_env_path) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_show_log_on_error(mock_packages, mock_archive, mock_fetch, config, install_mockery, capfd): @@ -200,6 +213,7 @@ def test_show_log_on_error(mock_packages, mock_archive, mock_fetch, assert 'See build log for details:' in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_overwrite( mock_packages, mock_archive, mock_fetch, config, install_mockery ): @@ -233,6 +247,7 @@ def test_install_overwrite( assert fs.hash_directory(spec.prefix, ignore=ignores) != bad_md5 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_overwrite_not_installed( mock_packages, mock_archive, mock_fetch, config, install_mockery, ): @@ -246,6 +261,7 @@ def test_install_overwrite_not_installed( assert os.path.exists(spec.prefix) +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_install_commit( mock_git_version_info, install_mockery, mock_packages, monkeypatch): """Test installing a git package from a commit. @@ -273,6 +289,7 @@ def test_install_commit( assert content == '[]' # contents are weird for another test +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_install_overwrite_multiple( mock_packages, mock_archive, mock_fetch, config, install_mockery ): @@ -330,6 +347,7 @@ def test_install_overwrite_multiple( assert cm_hash != bad_cmake_md5 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.usefixtures( 'mock_packages', 'mock_archive', 'mock_fetch', 'config', 'install_mockery', ) @@ -339,6 +357,7 @@ def test_install_conflicts(conflict_spec): install(conflict_spec) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.usefixtures( 'mock_packages', 'mock_archive', 'mock_fetch', 'config', 'install_mockery', ) @@ -348,6 +367,7 @@ def test_install_invalid_spec(invalid_spec): install(invalid_spec) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.usefixtures('noop_install', 'mock_packages', 'config') @pytest.mark.parametrize('spec,concretize,error_code', [ (Spec('mpi'), False, 1), @@ -380,6 +400,7 @@ def test_install_from_file(spec, concretize, error_code, tmpdir): assert err_msg in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check @pytest.mark.usefixtures( 'mock_packages', 'mock_archive', 'mock_fetch', 'config', 'install_mockery' @@ -422,6 +443,7 @@ def test_junit_output_with_failures(tmpdir, exc_typename, msg): assert msg in content +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check @pytest.mark.parametrize('exc_typename,expected_exc,msg', [ ('RuntimeError', spack.installer.InstallError, 'something weird happened'), @@ -465,6 +487,7 @@ def just_throw(*args, **kwargs): assert 'error message="{0}"'.format(msg) in content +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.usefixtures('noop_install', 'mock_packages', 'config') @pytest.mark.parametrize('clispecs,filespecs', [ [[], ['mpi']], @@ -489,6 +512,7 @@ def test_install_mix_cli_and_files(clispecs, filespecs, tmpdir): assert install.returncode == 0 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_extra_files_are_archived(mock_packages, mock_archive, mock_fetch, config, install_mockery): s = Spec('archive-files') @@ -508,6 +532,7 @@ def test_extra_files_are_archived(mock_packages, mock_archive, mock_fetch, assert os.path.exists(errors_txt) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_cdash_report_concretization_error(tmpdir, mock_fetch, install_mockery, capfd, conflict_spec): @@ -534,6 +559,7 @@ def test_cdash_report_concretization_error(tmpdir, mock_fetch, install_mockery, assert any(x in content for x in expected_messages) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_cdash_upload_build_error(tmpdir, mock_fetch, install_mockery, capfd): @@ -554,6 +580,7 @@ def test_cdash_upload_build_error(tmpdir, mock_fetch, install_mockery, assert 'configure: error: in /path/to/some/file:' in content +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_cdash_upload_clean_build(tmpdir, mock_fetch, install_mockery, capfd): # capfd interferes with Spack's capturing of e.g., Build.xml output @@ -572,6 +599,7 @@ def test_cdash_upload_clean_build(tmpdir, mock_fetch, install_mockery, capfd): assert '' not in content +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_cdash_upload_extra_params(tmpdir, mock_fetch, install_mockery, capfd): # capfd interferes with Spack's capture of e.g., Build.xml output @@ -594,6 +622,7 @@ def test_cdash_upload_extra_params(tmpdir, mock_fetch, install_mockery, capfd): assert '-my_custom_track' in content +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_cdash_buildstamp_param(tmpdir, mock_fetch, install_mockery, capfd): # capfd interferes with Spack's capture of e.g., Build.xml output @@ -616,6 +645,7 @@ def test_cdash_buildstamp_param(tmpdir, mock_fetch, install_mockery, capfd): assert buildstamp in content +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_cdash_install_from_spec_yaml(tmpdir, mock_fetch, install_mockery, capfd, mock_packages, mock_archive, @@ -654,6 +684,7 @@ def test_cdash_install_from_spec_yaml(tmpdir, mock_fetch, install_mockery, assert 'a@' in install_command +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_build_error_output(tmpdir, mock_fetch, install_mockery, capfd): with capfd.disabled(): @@ -668,6 +699,7 @@ def test_build_error_output(tmpdir, mock_fetch, install_mockery, capfd): assert 'configure: error: cannot run C compiled programs.' in msg +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_build_warning_output(tmpdir, mock_fetch, install_mockery, capfd): with capfd.disabled(): @@ -682,6 +714,7 @@ def test_build_warning_output(tmpdir, mock_fetch, install_mockery, capfd): assert 'foo.c:89: warning: some weird warning!' in msg +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_cache_only_fails(tmpdir, mock_fetch, install_mockery, capfd): # libelf from cache fails to install, which automatically removes the # the libdwarf build task @@ -698,6 +731,7 @@ def test_cache_only_fails(tmpdir, mock_fetch, install_mockery, capfd): assert 'libdwarf' in failure_lock_prefixes +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_only_dependencies(tmpdir, mock_fetch, install_mockery): dep = Spec('dependency-install').concretized() root = Spec('dependent-install').concretized() @@ -708,6 +742,7 @@ def test_install_only_dependencies(tmpdir, mock_fetch, install_mockery): assert not os.path.exists(root.prefix) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_only_package(tmpdir, mock_fetch, install_mockery, capfd): msg = '' with capfd.disabled(): @@ -720,6 +755,7 @@ def test_install_only_package(tmpdir, mock_fetch, install_mockery, capfd): assert '1 uninstalled dependency' in msg +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_deps_then_package(tmpdir, mock_fetch, install_mockery): dep = Spec('dependency-install').concretized() root = Spec('dependent-install').concretized() @@ -732,6 +768,7 @@ def test_install_deps_then_package(tmpdir, mock_fetch, install_mockery): assert os.path.exists(root.prefix) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.regression('12002') def test_install_only_dependencies_in_env(tmpdir, mock_fetch, install_mockery, mutable_mock_env_path): @@ -747,6 +784,7 @@ def test_install_only_dependencies_in_env(tmpdir, mock_fetch, install_mockery, assert not os.path.exists(root.prefix) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.regression('12002') def test_install_only_dependencies_of_all_in_env( tmpdir, mock_fetch, install_mockery, mutable_mock_env_path @@ -767,6 +805,7 @@ def test_install_only_dependencies_of_all_in_env( assert os.path.exists(dep.prefix) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_no_add_in_env(tmpdir, mock_fetch, install_mockery, mutable_mock_env_path): # To test behavior of --no-add option, we create the following environment: @@ -873,6 +912,7 @@ def test_install_no_add_in_env(tmpdir, mock_fetch, install_mockery, assert(not any([s.name == 'bowtie' for s in e.uninstalled_specs()])) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_help_does_not_show_cdash_options(capsys): """ Make sure `spack install --help` does not describe CDash arguments @@ -883,6 +923,7 @@ def test_install_help_does_not_show_cdash_options(capsys): assert 'CDash URL' not in captured.out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_help_cdash(capsys): """Make sure `spack install --help-cdash` describes CDash arguments""" install_cmd = SpackCommand('install') @@ -890,6 +931,7 @@ def test_install_help_cdash(capsys): assert 'CDash URL' in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_cdash_auth_token(tmpdir, mock_fetch, install_mockery, capfd): # capfd interferes with Spack's capturing @@ -904,6 +946,7 @@ def test_cdash_auth_token(tmpdir, mock_fetch, install_mockery, capfd): assert 'Using CDash auth token from environment' in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.disable_clean_stage_check def test_cdash_configure_warning(tmpdir, mock_fetch, install_mockery, capfd): # capfd interferes with Spack's capturing of e.g., Build.xml output @@ -923,6 +966,7 @@ def test_cdash_configure_warning(tmpdir, mock_fetch, install_mockery, capfd): assert 'foo: No such file or directory' in content +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_compiler_bootstrap( install_mockery_mutable_config, mock_packages, mock_fetch, mock_archive, mutable_config, monkeypatch): @@ -935,6 +979,7 @@ def test_compiler_bootstrap( install('a%gcc@2.0') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_compiler_bootstrap_from_binary_mirror( install_mockery_mutable_config, mock_packages, mock_fetch, mock_archive, mutable_config, monkeypatch, tmpdir): @@ -973,6 +1018,7 @@ def test_compiler_bootstrap_from_binary_mirror( install('--no-cache', '--only', 'package', 'b%gcc@10.2.0') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.regression('16221') def test_compiler_bootstrap_already_installed( install_mockery_mutable_config, mock_packages, mock_fetch, @@ -988,6 +1034,7 @@ def test_compiler_bootstrap_already_installed( install('a%gcc@2.0') +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_install_fails_no_args(tmpdir): # ensure no spack.yaml in directory with tmpdir.as_cwd(): @@ -999,6 +1046,7 @@ def test_install_fails_no_args(tmpdir): assert 'using the `spack.yaml` in this directory' not in output +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_install_fails_no_args_suggests_env_activation(tmpdir): # ensure spack.yaml in directory tmpdir.ensure('spack.yaml') @@ -1024,6 +1072,7 @@ def fake_full_hash(spec): return default_full_hash(spec) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_cache_install_full_hash_match( install_mockery_mutable_config, mock_packages, mock_fetch, mock_archive, mutable_config, monkeypatch, tmpdir): @@ -1082,6 +1131,7 @@ def test_cache_install_full_hash_match( shutil.rmtree(mirror_dir.strpath) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_env_with_tests_all(tmpdir, mock_packages, mock_fetch, install_mockery, mutable_mock_env_path): env('create', 'test') @@ -1092,6 +1142,7 @@ def test_install_env_with_tests_all(tmpdir, mock_packages, mock_fetch, assert os.path.exists(test_dep.prefix) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_install_env_with_tests_root(tmpdir, mock_packages, mock_fetch, install_mockery, mutable_mock_env_path): env('create', 'test') diff --git a/lib/spack/spack/test/cmd/is_git_repo.py b/lib/spack/spack/test/cmd/is_git_repo.py index 9b0d29a75e..73135141d9 100644 --- a/lib/spack/spack/test/cmd/is_git_repo.py +++ b/lib/spack/spack/test/cmd/is_git_repo.py @@ -5,6 +5,8 @@ from __future__ import print_function +import os + import pytest from llnl.util.filesystem import mkdirp @@ -42,7 +44,13 @@ def git_tmp_worktree(tmpdir): """Create new worktree in a temporary folder and monkeypatch spack.paths.prefix to point to it. """ - worktree_root = str(tmpdir.join("tmp_worktree")) + if os.name == 'nt': + long_pth = str(tmpdir).split(os.path.sep) + tmp_worktree = os.path.sep.join(long_pth[:-1]) + else: + tmp_worktree = str(tmpdir) + worktree_root = os.path.sep.join([tmp_worktree, "wrktree"]) + mkdirp(worktree_root) git("worktree", "add", "--detach", worktree_root, "HEAD") diff --git a/lib/spack/spack/test/cmd/license.py b/lib/spack/spack/test/cmd/license.py index d296741e02..bd9636c088 100644 --- a/lib/spack/spack/test/cmd/license.py +++ b/lib/spack/spack/test/cmd/license.py @@ -5,6 +5,9 @@ import os.path import re +import sys + +import pytest from llnl.util.filesystem import mkdirp, touch @@ -15,6 +18,7 @@ license = SpackCommand('license') +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_list_files(): files = license('list-files').strip().split('\n') assert all(f.startswith(spack.paths.prefix) for f in files) @@ -22,6 +26,7 @@ def test_list_files(): assert os.path.abspath(__file__) in files +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_verify(tmpdir): source_dir = tmpdir.join('lib', 'spack', 'spack') mkdirp(str(source_dir)) @@ -69,6 +74,7 @@ def test_verify(tmpdir): assert license.returncode == 1 +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_update_copyright_year(tmpdir): source_dir = tmpdir.join('lib', 'spack', 'spack') mkdirp(str(source_dir)) diff --git a/lib/spack/spack/test/cmd/list.py b/lib/spack/spack/test/cmd/list.py index fe86a7f3b7..42253eb354 100644 --- a/lib/spack/spack/test/cmd/list.py +++ b/lib/spack/spack/test/cmd/list.py @@ -3,17 +3,23 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + +import pytest + from spack.main import SpackCommand list = SpackCommand('list') +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_list(): output = list() assert 'cloverleaf3d' in output assert 'hdf5' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_list_filter(mock_packages): output = list('py-*') assert 'py-extension1' in output @@ -30,17 +36,20 @@ def test_list_filter(mock_packages): assert 'mpich' not in output +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_list_search_description(mock_packages): output = list('--search-description', 'one build dependency') assert 'depb' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_list_format_name_only(mock_packages): output = list('--format', 'name_only') assert 'zmpi' in output assert 'hdf5' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_list_format_version_json(mock_packages): output = list('--format', 'version_json') assert '{"name": "zmpi",' in output @@ -49,6 +58,7 @@ def test_list_format_version_json(mock_packages): json.loads(output) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_list_format_html(mock_packages): output = list('--format', 'html') assert '
' in output diff --git a/lib/spack/spack/test/cmd/load.py b/lib/spack/spack/test/cmd/load.py index 0049bb7b53..18c00d7d88 100644 --- a/lib/spack/spack/test/cmd/load.py +++ b/lib/spack/spack/test/cmd/load.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os import re +import sys import pytest @@ -17,6 +18,7 @@ location = SpackCommand('location') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_manpath_trailing_colon(install_mockery, mock_fetch, mock_archive, mock_packages, working_env): """Test that the commands generated by load add the MANPATH prefix @@ -35,6 +37,7 @@ def test_manpath_trailing_colon(install_mockery, mock_fetch, mock_archive, assert any(re.match(r'export MANPATH=.*:/tmp/man:;', ln) for ln in lines) +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_load(install_mockery, mock_fetch, mock_archive, mock_packages): """Test that the commands generated by load add the specified prefix inspections. Also test that Spack records loaded specs by hash in the @@ -65,6 +68,7 @@ def test_load(install_mockery, mock_fetch, mock_archive, mock_packages): assert csh_hash_test in csh_out +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_load_recursive(install_mockery, mock_fetch, mock_archive, mock_packages): """Test that the '-r' option to the load command prepends dependency prefix @@ -93,6 +97,7 @@ def test_load_recursive(install_mockery, mock_fetch, mock_archive, assert csh_hash_test in csh_out +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_load_includes_run_env(install_mockery, mock_fetch, mock_archive, mock_packages): """Tests that environment changes from the package's @@ -107,6 +112,7 @@ def test_load_includes_run_env(install_mockery, mock_fetch, mock_archive, assert 'setenv FOOBAR mpileaks' in csh_out +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_load_first(install_mockery, mock_fetch, mock_archive, mock_packages): """Test with and without the --first option""" install('libelf@0.8.12') @@ -119,6 +125,7 @@ def test_load_first(install_mockery, mock_fetch, mock_archive, mock_packages): load('--sh', '--first', 'libelf') +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_load_fails_no_shell(install_mockery, mock_fetch, mock_archive, mock_packages): """Test that spack load prints an error message without a shell.""" @@ -128,6 +135,7 @@ def test_load_fails_no_shell(install_mockery, mock_fetch, mock_archive, assert "To set up shell support" in out +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_unload(install_mockery, mock_fetch, mock_archive, mock_packages, working_env): """Tests that any variables set in the user environment are undone by the @@ -150,6 +158,7 @@ def test_unload(install_mockery, mock_fetch, mock_archive, mock_packages, assert 'setenv %s garbage' % uenv.spack_loaded_hashes_var in csh_out +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_unload_fails_no_shell(install_mockery, mock_fetch, mock_archive, mock_packages, working_env): """Test that spack unload prints an error message without a shell.""" diff --git a/lib/spack/spack/test/cmd/location.py b/lib/spack/spack/test/cmd/location.py index 954e19e3c4..8d8d4fc5bf 100644 --- a/lib/spack/spack/test/cmd/location.py +++ b/lib/spack/spack/test/cmd/location.py @@ -5,6 +5,7 @@ import os import shutil +import sys import pytest @@ -37,12 +38,14 @@ def mock_spec(): shutil.rmtree(pkg.stage.path) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_location_build_dir(mock_spec): """Tests spack location --build-dir.""" spec, pkg = mock_spec assert location('--build-dir', spec.name).strip() == pkg.stage.source_path +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.regression('22738') def test_location_source_dir(mock_spec): """Tests spack location --source-dir.""" @@ -51,6 +54,7 @@ def test_location_source_dir(mock_spec): assert location(spec.name).strip() == pkg.stage.source_path +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_location_source_dir_missing(): """Tests spack location --source-dir with a missing source directory.""" spec = 'mpileaks' @@ -61,6 +65,7 @@ def test_location_source_dir_missing(): assert out == expected +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.parametrize('options', [([]), (['--source-dir', 'mpileaks']), (['--env', 'missing-env']), @@ -71,6 +76,7 @@ def test_location_cmd_error(options): location(*options) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_location_env_exists(mutable_mock_env_path): """Tests spack location --env for an existing environment.""" e = ev.create("example") @@ -78,6 +84,7 @@ def test_location_env_exists(mutable_mock_env_path): assert location('--env', "example").strip() == e.path +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_location_with_active_env(mutable_mock_env_path): """Tests spack location --env with active env""" e = ev.create("example") @@ -86,6 +93,7 @@ def test_location_with_active_env(mutable_mock_env_path): assert location('--env').strip() == e.path +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_location_env_flag_interference(mutable_mock_env_path, tmpdir): """ Tests that specifying an active environment using `spack -e x location ...` @@ -107,6 +115,7 @@ def test_location_env_flag_interference(mutable_mock_env_path, tmpdir): assert 'first_env' not in location('--packages', global_args=global_args) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_location_env_missing(): """Tests spack location --env.""" missing_env_name = 'missing-env' @@ -115,6 +124,7 @@ def test_location_env_missing(): assert out == error +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_location_install_dir(mock_spec): """Tests spack location --install-dir.""" @@ -122,6 +132,7 @@ def test_location_install_dir(mock_spec): assert location('--install-dir', spec.name).strip() == spec.prefix +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_location_package_dir(mock_spec): """Tests spack location --package-dir.""" @@ -129,6 +140,7 @@ def test_location_package_dir(mock_spec): assert location('--package-dir', spec.name).strip() == pkg.package_dir +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.parametrize('option,expected', [ ('--module-dir', spack.paths.module_path), @@ -139,6 +151,7 @@ def test_location_paths_options(option, expected): assert location(option).strip() == expected +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.parametrize('specs,expected', [ ([], "You must supply a spec."), (['spec1', 'spec2'], "Too many specs. Supply only one.")]) @@ -148,6 +161,7 @@ def test_location_spec_errors(specs, expected): assert location(*specs, fail_on_error=False).strip() == error +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_location_stage_dir(mock_spec): """Tests spack location --stage-dir.""" @@ -155,6 +169,7 @@ def test_location_stage_dir(mock_spec): assert location('--stage-dir', spec.name).strip() == pkg.stage.path +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_location_stages(mock_spec): """Tests spack location --stages.""" diff --git a/lib/spack/spack/test/cmd/mark.py b/lib/spack/spack/test/cmd/mark.py index 84ed657998..a2e902ef96 100644 --- a/lib/spack/spack/test/cmd/mark.py +++ b/lib/spack/spack/test/cmd/mark.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import spack.store @@ -14,18 +16,21 @@ uninstall = SpackCommand('uninstall') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_mark_mode_required(mutable_database): with pytest.raises(SystemExit): mark('-a') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_mark_spec_required(mutable_database): with pytest.raises(SpackCommandError): mark('-i') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_mark_all_explicit(mutable_database): mark('-e', '-a') @@ -34,6 +39,7 @@ def test_mark_all_explicit(mutable_database): assert len(all_specs) == 15 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_mark_all_implicit(mutable_database): mark('-i', '-a') @@ -42,6 +48,7 @@ def test_mark_all_implicit(mutable_database): assert len(all_specs) == 0 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_mark_one_explicit(mutable_database): mark('-e', 'libelf') @@ -51,6 +58,7 @@ def test_mark_one_explicit(mutable_database): assert len(all_specs) == 3 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_mark_one_implicit(mutable_database): mark('-i', 'externaltest') @@ -59,6 +67,7 @@ def test_mark_one_implicit(mutable_database): assert len(all_specs) == 14 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_mark_all_implicit_then_explicit(mutable_database): mark('-i', '-a') diff --git a/lib/spack/spack/test/cmd/mirror.py b/lib/spack/spack/test/cmd/mirror.py index 96c8085b74..c455aad514 100644 --- a/lib/spack/spack/test/cmd/mirror.py +++ b/lib/spack/spack/test/cmd/mirror.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -41,6 +42,8 @@ def tmp_scope(): @pytest.mark.disable_clean_stage_check @pytest.mark.regression('8083') +@pytest.mark.skipif(sys.platform == 'win32', + reason="MirrorCaches only work with file:// URLs") def test_regression_8083(tmpdir, capfd, mock_packages, mock_fetch, config): with capfd.disabled(): output = mirror('create', '-d', str(tmpdir), 'externaltool') @@ -48,6 +51,8 @@ def test_regression_8083(tmpdir, capfd, mock_packages, mock_fetch, config): assert 'as it is an external spec' in output +@pytest.mark.skipif(sys.platform == 'win32', + reason="MirrorCaches only work with file:// URLs") @pytest.mark.regression('12345') def test_mirror_from_env(tmpdir, mock_packages, mock_fetch, config, mutable_mock_env_path): @@ -81,6 +86,8 @@ def source_for_pkg_with_hash(mock_packages, tmpdir): pkg.versions[spack.version.Version('1.0')]['url'] = local_url +@pytest.mark.skipif(sys.platform == 'win32', + reason="MirrorCaches only work with file:// URLs") def test_mirror_skip_unstable(tmpdir_factory, mock_packages, config, source_for_pkg_with_hash): mirror_dir = str(tmpdir_factory.mktemp('mirror-dir')) @@ -106,6 +113,7 @@ def __init__(self, specs=None, all=False, file=None, self.exclude_specs = exclude_specs +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_exclude_specs(mock_packages, config): args = MockMirrorArgs( specs=['mpich'], @@ -121,6 +129,7 @@ def test_exclude_specs(mock_packages, config): assert (not expected_exclude & set(mirror_specs)) +@pytest.mark.skipif(sys.platform == "win32", reason="Test unsupported on Windows") def test_exclude_file(mock_packages, tmpdir, config): exclude_path = os.path.join(str(tmpdir), 'test-exclude.txt') with open(exclude_path, 'w') as exclude_file: @@ -143,6 +152,7 @@ def test_exclude_file(mock_packages, tmpdir, config): assert (not expected_exclude & set(mirror_specs)) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_mirror_crud(tmp_scope, capsys): with capsys.disabled(): mirror('add', '--scope', tmp_scope, 'mirror', 'http://spack.io') @@ -198,6 +208,7 @@ def test_mirror_crud(tmp_scope, capsys): assert 'No mirrors configured' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_mirror_nonexisting(tmp_scope): with pytest.raises(SpackCommandError): mirror('remove', '--scope', tmp_scope, 'not-a-mirror') @@ -207,6 +218,7 @@ def test_mirror_nonexisting(tmp_scope): 'not-a-mirror', 'http://spack.io') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_mirror_name_collision(tmp_scope): mirror('add', '--scope', tmp_scope, 'first', '1') @@ -214,6 +226,7 @@ def test_mirror_name_collision(tmp_scope): mirror('add', '--scope', tmp_scope, 'first', '1') +@pytest.mark.skipif(sys.platform == 'win32', reason="hangs on windows") def test_mirror_destroy(install_mockery_mutable_config, mock_packages, mock_fetch, mock_archive, mutable_config, monkeypatch, tmpdir): diff --git a/lib/spack/spack/test/cmd/module.py b/lib/spack/spack/test/cmd/module.py index 7a2604ead1..cf5a0dbc8c 100644 --- a/lib/spack/spack/test/cmd/module.py +++ b/lib/spack/spack/test/cmd/module.py @@ -5,6 +5,7 @@ import os.path import re +import sys import pytest @@ -59,12 +60,14 @@ def module_type(request): # TODO : this requires having a separate directory for test modules # TODO : add tests for loads and find to check the prompt format +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_exit_with_failure(database, module_type, failure_args): with pytest.raises(spack.main.SpackCommandError): module(module_type, *failure_args) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_remove_and_add(database, module_type): """Tests adding and removing a tcl module file.""" @@ -88,6 +91,7 @@ def test_remove_and_add(database, module_type): assert os.path.exists(item) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.parametrize('cli_args', [ ['libelf'], @@ -102,6 +106,7 @@ def test_find(database, cli_args, module_type): module(module_type, *(['find'] + cli_args)) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.usefixtures('database') @pytest.mark.regression('2215') @@ -121,6 +126,7 @@ def test_find_fails_on_multiple_matches(): assert 'matches multiple packages' in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.usefixtures('database') @pytest.mark.regression('2570') @@ -131,6 +137,7 @@ def test_find_fails_on_non_existing_packages(): assert 'matches no package' in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.usefixtures('database') def test_find_recursive(): @@ -144,6 +151,7 @@ def test_find_recursive(): assert len(out.split()) > 1 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_find_recursive_blacklisted(database, module_configuration): module_configuration('blacklist') @@ -152,6 +160,7 @@ def test_find_recursive_blacklisted(database, module_configuration): module('lmod', 'find', '-r', 'mpileaks ^mpich') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_loads_recursive_blacklisted(database, module_configuration): module_configuration('blacklist') @@ -176,6 +185,7 @@ def test_loads_recursive_blacklisted(database, module_configuration): writer_cls = spack.modules.lmod.LmodModulefileWriter +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_setdefault_command( mutable_database, mutable_config diff --git a/lib/spack/spack/test/cmd/pkg.py b/lib/spack/spack/test/cmd/pkg.py index a297893d8e..1924fbccb8 100644 --- a/lib/spack/spack/test/cmd/pkg.py +++ b/lib/spack/spack/test/cmd/pkg.py @@ -7,6 +7,7 @@ import re import shutil +import sys import pytest @@ -104,6 +105,7 @@ def split(output): pkg = spack.main.SpackCommand('pkg') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_packages_path(): assert (spack.cmd.pkg.packages_path() == spack.repo.path.get_repo('builtin').packages_path) @@ -190,6 +192,7 @@ def test_pkg_removed(mock_pkg_git_repo): assert out == ['pkg-c'] +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_pkg_changed(mock_pkg_git_repo): out = split(pkg('changed', 'HEAD^^', 'HEAD^')) assert out == [] diff --git a/lib/spack/spack/test/cmd/providers.py b/lib/spack/spack/test/cmd/providers.py index 190af0451a..cc6b3068ed 100644 --- a/lib/spack/spack/test/cmd/providers.py +++ b/lib/spack/spack/test/cmd/providers.py @@ -4,6 +4,8 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest from spack.main import SpackCommand @@ -11,6 +13,7 @@ providers = SpackCommand('providers') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.parametrize('pkg', [ ('mpi',), ('mpi@2',), @@ -21,6 +24,7 @@ def test_it_just_runs(pkg): providers(*pkg) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.parametrize('vpkg,provider_list', [ (('mpi',), ['intel-mpi', 'intel-parallel-studio', diff --git a/lib/spack/spack/test/cmd/reindex.py b/lib/spack/spack/test/cmd/reindex.py index e24cd08606..e2049b6671 100644 --- a/lib/spack/spack/test/cmd/reindex.py +++ b/lib/spack/spack/test/cmd/reindex.py @@ -3,6 +3,9 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys + +import pytest import spack.store from spack.main import SpackCommand @@ -12,6 +15,7 @@ reindex = SpackCommand('reindex') +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_reindex_basic(mock_packages, mock_archive, mock_fetch, install_mockery): install('libelf@0.8.13') @@ -24,6 +28,7 @@ def test_reindex_basic(mock_packages, mock_archive, mock_fetch, assert spack.store.db.query() == all_installed +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_reindex_db_deleted(mock_packages, mock_archive, mock_fetch, install_mockery): install('libelf@0.8.13') @@ -37,6 +42,7 @@ def test_reindex_db_deleted(mock_packages, mock_archive, mock_fetch, assert spack.store.db.query() == all_installed +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_reindex_with_deprecated_packages(mock_packages, mock_archive, mock_fetch, install_mockery): install('libelf@0.8.13') diff --git a/lib/spack/spack/test/cmd/resource.py b/lib/spack/spack/test/cmd/resource.py index c4633593a1..87b4ed8a06 100644 --- a/lib/spack/spack/test/cmd/resource.py +++ b/lib/spack/spack/test/cmd/resource.py @@ -2,6 +2,9 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + +import pytest from spack.main import SpackCommand @@ -22,6 +25,7 @@ ] +@pytest.mark.skipif(sys.platform == 'win32', reason="Hashes do not match") def test_resource_list(mock_packages, capfd): with capfd.disabled(): out = resource('list') @@ -39,6 +43,7 @@ def test_resource_list(mock_packages, capfd): assert 'patched by: builtin.mock.patch-a-dependency' in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Hashes do not match") def test_resource_list_only_hashes(mock_packages, capfd): with capfd.disabled(): out = resource('list', '--only-hashes') @@ -47,6 +52,7 @@ def test_resource_list_only_hashes(mock_packages, capfd): assert h in out +@pytest.mark.skipif(sys.platform == 'win32', reason="Hashes do not match") def test_resource_show(mock_packages, capfd): with capfd.disabled(): out = resource('show', 'c45c1564f70def3fc1a6e22139f62cb21cd190cc3a7dbe6f4120fa59ce33dcb8') diff --git a/lib/spack/spack/test/cmd/stage.py b/lib/spack/spack/test/cmd/stage.py index 3119fb393c..74a6881f6a 100644 --- a/lib/spack/spack/test/cmd/stage.py +++ b/lib/spack/spack/test/cmd/stage.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -18,6 +19,7 @@ pytestmark = pytest.mark.usefixtures('install_mockery', 'mock_packages') +@pytest.mark.skipif(sys.platform == 'win32', reason="not implemented on windows") def test_stage_spec(monkeypatch): """Verify that staging specs works.""" @@ -46,6 +48,7 @@ def fake_stage(pkg, mirror_only=False): return expected_path +@pytest.mark.skipif(sys.platform == 'win32', reason="PermissionError") def test_stage_path(check_stage_path): """Verify that --path only works with single specs.""" stage('--path={0}'.format(check_stage_path), 'trivial-install-test-package') @@ -59,6 +62,7 @@ def test_stage_path_errors_multiple_specs(check_stage_path): 'mpileaks') +@pytest.mark.skipif(sys.platform == 'win32', reason="not implemented on windows") def test_stage_with_env_outside_env(mutable_mock_env_path, monkeypatch): """Verify that stage concretizes specs not in environment instead of erroring.""" @@ -76,6 +80,7 @@ def fake_stage(pkg, mirror_only=False): stage('trivial-install-test-package') +@pytest.mark.skipif(sys.platform == 'win32', reason="not implemented on windows") def test_stage_with_env_inside_env(mutable_mock_env_path, monkeypatch): """Verify that stage filters specs in environment instead of reconcretizing.""" @@ -93,6 +98,7 @@ def fake_stage(pkg, mirror_only=False): stage('mpileaks') +@pytest.mark.skipif(sys.platform == 'win32', reason="not implemented on windows") def test_stage_full_env(mutable_mock_env_path, monkeypatch): """Verify that stage filters specs in environment.""" diff --git a/lib/spack/spack/test/cmd/style.py b/lib/spack/spack/test/cmd/style.py index 49fb169a4d..ec450da535 100644 --- a/lib/spack/spack/test/cmd/style.py +++ b/lib/spack/spack/test/cmd/style.py @@ -5,6 +5,7 @@ import filecmp import os +import posixpath import shutil import sys @@ -86,7 +87,13 @@ def flake8_package_with_errors(scope="function"): def test_changed_files(flake8_package): # changed_files returns file paths relative to the root # directory of Spack. Convert to absolute file paths. - files = [os.path.join(spack.paths.prefix, path) for path in changed_files()] + files = [ + os.path.join(spack.paths.prefix, os.path.normpath(path)) + for path in changed_files() + ] + + if sys.platform == "win32": + files = [f.replace("\\", "/") for f in files] # There will likely be other files that have changed # when these tests are run @@ -114,10 +121,13 @@ def test_changed_no_base(tmpdir, capfd): def test_changed_files_all_files(flake8_package): # it's hard to guarantee "all files", so do some sanity checks. files = set([ - os.path.join(spack.paths.prefix, path) + os.path.join(spack.paths.prefix, os.path.normpath(path)) for path in changed_files(all_files=True) ]) + if sys.platform == "win32": + files = [f.replace("\\", "/") for f in files] + # spack has a lot of files -- check that we're in the right ballpark assert len(files) > 6000 @@ -126,13 +136,13 @@ def test_changed_files_all_files(flake8_package): assert zlib.module.__file__ in files # a core spack file - assert os.path.join(spack.paths.module_path, "spec.py") in files + assert posixpath.join(spack.paths.module_path, "spec.py") in files # a mock package assert flake8_package in files # this test - assert __file__ in files + assert __file__.replace("\\", "/") in files # ensure externals are excluded assert not any(f.startswith(spack.paths.external_path) for f in files) diff --git a/lib/spack/spack/test/cmd/test.py b/lib/spack/spack/test/cmd/test.py index aad8389a03..ff0dbad16b 100644 --- a/lib/spack/spack/test/cmd/test.py +++ b/lib/spack/spack/test/cmd/test.py @@ -5,6 +5,7 @@ import argparse import os +import sys import pytest @@ -18,6 +19,8 @@ spack_test = SpackCommand('test') +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_test_package_not_installed( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery_mutable_config, mock_test_stage): @@ -39,6 +42,8 @@ def test_test_dirty_flag(arguments, expected): assert args.dirty == expected +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_test_dup_alias( mock_test_stage, mock_packages, mock_archive, mock_fetch, install_mockery_mutable_config, capfd): @@ -57,6 +62,8 @@ def test_test_dup_alias( assert "already exists" in out +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_test_output(mock_test_stage, mock_packages, mock_archive, mock_fetch, install_mockery_mutable_config): """Ensure output printed from pkgs is captured by output redirection.""" @@ -82,6 +89,8 @@ def test_test_output(mock_test_stage, mock_packages, mock_archive, mock_fetch, assert "FAILED" not in output +@pytest.mark.skipif(sys.platform == "win32", + reason='FetchError: All fetchers failed') def test_test_output_on_error( mock_packages, mock_archive, mock_fetch, install_mockery_mutable_config, capfd, mock_test_stage @@ -95,6 +104,8 @@ def test_test_output_on_error( assert "Command exited with status 1" in out +@pytest.mark.skipif(sys.platform == "win32", + reason='FetchError: All fetchers failed') def test_test_output_on_failure( mock_packages, mock_archive, mock_fetch, install_mockery_mutable_config, capfd, mock_test_stage @@ -107,6 +118,8 @@ def test_test_output_on_failure( assert "TestFailure" in out +@pytest.mark.skipif(sys.platform == "win32", + reason='FetchError: All fetchers failed') def test_show_log_on_error( mock_packages, mock_archive, mock_fetch, install_mockery_mutable_config, capfd, mock_test_stage @@ -120,6 +133,8 @@ def test_show_log_on_error( assert mock_test_stage in out +@pytest.mark.skipif(sys.platform == "win32", + reason='FetchError: All fetchers failed') @pytest.mark.usefixtures( 'mock_packages', 'mock_archive', 'mock_fetch', 'install_mockery_mutable_config' @@ -153,6 +168,8 @@ def test_junit_output_with_failures(tmpdir, mock_test_stage, pkg_name, msgs): assert msg in content +@pytest.mark.skipif(sys.platform == "win32", + reason='FetchError: All fetchers failed') def test_cdash_output_test_error( tmpdir, mock_fetch, install_mockery_mutable_config, mock_packages, mock_archive, mock_test_stage, capfd): @@ -172,6 +189,8 @@ def test_cdash_output_test_error( assert 'FAILED: Command exited with status 1' in content +@pytest.mark.skipif(sys.platform == "win32", + reason='FetchError: All fetchers failed') def test_cdash_upload_clean_test( tmpdir, mock_fetch, install_mockery_mutable_config, mock_packages, mock_archive, mock_test_stage): @@ -217,6 +236,8 @@ def test_test_list_all(mock_packages): ]) +@pytest.mark.skipif(sys.platform == "win32", + reason='FetchError: All fetchers failed') def test_test_list( mock_packages, mock_archive, mock_fetch, install_mockery_mutable_config ): @@ -226,6 +247,18 @@ def test_test_list( assert pkg_with_tests in output +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") +def test_has_test_method_fails(capsys): + with pytest.raises(SystemExit): + has_test_method('printing-package') + + captured = capsys.readouterr()[1] + assert 'is not a class' in captured + + +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_hash_change(mock_test_stage, mock_packages, mock_archive, mock_fetch, install_mockery_mutable_config): """Ensure output printed from pkgs is captured by output redirection.""" diff --git a/lib/spack/spack/test/cmd/undevelop.py b/lib/spack/spack/test/cmd/undevelop.py index d4fdfa5375..9182a1e45b 100644 --- a/lib/spack/spack/test/cmd/undevelop.py +++ b/lib/spack/spack/test/cmd/undevelop.py @@ -3,6 +3,10 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + +import pytest + import spack.environment as ev import spack.spec from spack.main import SpackCommand @@ -12,6 +16,8 @@ concretize = SpackCommand('concretize') +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_undevelop(tmpdir, config, mock_packages, mutable_mock_env_path): # setup environment envdir = tmpdir.mkdir('env') @@ -39,6 +45,8 @@ def test_undevelop(tmpdir, config, mock_packages, mutable_mock_env_path): assert not after.satisfies('dev_path=*') +@pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') def test_undevelop_nonexistent(tmpdir, config, mock_packages, mutable_mock_env_path): # setup environment envdir = tmpdir.mkdir('env') diff --git a/lib/spack/spack/test/cmd/uninstall.py b/lib/spack/spack/test/cmd/uninstall.py index 857f1ae35d..fe813aaba4 100644 --- a/lib/spack/spack/test/cmd/uninstall.py +++ b/lib/spack/spack/test/cmd/uninstall.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import llnl.util.tty as tty @@ -24,6 +26,7 @@ def __init__(self, packages, all=False, force=False, dependents=False): self.yes_to_all = True +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_multiple_matches(mutable_database): """Test unable to uninstall when multiple matches.""" @@ -31,6 +34,7 @@ def test_multiple_matches(mutable_database): uninstall('-y', 'mpileaks') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_installed_dependents(mutable_database): """Test can't uninstall when there are installed dependents.""" @@ -38,6 +42,7 @@ def test_installed_dependents(mutable_database): uninstall('-y', 'libelf') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_recursive_uninstall(mutable_database): """Test recursive uninstall.""" @@ -55,6 +60,7 @@ def test_recursive_uninstall(mutable_database): assert len(mpi_specs) == 3 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.regression('3690') @pytest.mark.parametrize('constraint,expected_number_of_specs', [ @@ -69,6 +75,7 @@ def test_uninstall_spec_with_multiple_roots( assert len(all_specs) == expected_number_of_specs +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.parametrize('constraint,expected_number_of_specs', [ ('dyninst', 14), ('libelf', 14) @@ -82,6 +89,7 @@ def test_force_uninstall_spec_with_ref_count_not_zero( assert len(all_specs) == expected_number_of_specs +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db def test_force_uninstall_and_reinstall_by_hash(mutable_database): """Test forced uninstall and reinstall of old specs.""" @@ -161,6 +169,7 @@ def db_specs(): assert len(mpi_specs) == 3 +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.db @pytest.mark.regression('15773') def test_in_memory_consistency_when_uninstalling( diff --git a/lib/spack/spack/test/cmd/url.py b/lib/spack/spack/test/cmd/url.py index 1e4c0d391a..301185a6f7 100644 --- a/lib/spack/spack/test/cmd/url.py +++ b/lib/spack/spack/test/cmd/url.py @@ -124,6 +124,10 @@ def test_url_summary(mock_packages): assert out_correct_versions == correct_versions +@pytest.mark.skipif( + sys.platform.startswith("win"), + reason="Unsupported on Windows for now" +) def test_url_stats(capfd, mock_packages): with capfd.disabled(): output = url('stats') diff --git a/lib/spack/spack/test/cmd/verify.py b/lib/spack/spack/test/cmd/verify.py index 80838c21e8..84dece61a7 100644 --- a/lib/spack/spack/test/cmd/verify.py +++ b/lib/spack/spack/test/cmd/verify.py @@ -5,6 +5,9 @@ """Tests for the `spack verify` command""" import os +import sys + +import pytest import llnl.util.filesystem as fs @@ -18,6 +21,7 @@ install = SpackCommand('install') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_single_file_verify_cmd(tmpdir): # Test the verify command interface to verifying a single file. filedir = os.path.join(str(tmpdir), 'a', 'b', 'c', 'd') @@ -64,6 +68,7 @@ def test_single_file_verify_cmd(tmpdir): assert sorted(errors) == sorted(expected) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_single_spec_verify_cmd(tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): # Test the verify command interface to verify a single spec diff --git a/lib/spack/spack/test/cmd/versions.py b/lib/spack/spack/test/cmd/versions.py index d931a3fe9b..7d66f16b14 100644 --- a/lib/spack/spack/test/cmd/versions.py +++ b/lib/spack/spack/test/cmd/versions.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest from spack.main import SpackCommand @@ -11,6 +13,7 @@ versions = SpackCommand('versions') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_safe_only_versions(): """Only test the safe versions of a package. (Using the deprecated command line argument) @@ -18,12 +21,14 @@ def test_safe_only_versions(): versions('--safe-only', 'zlib') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_safe_versions(): """Only test the safe versions of a package.""" versions('--safe', 'zlib') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.maybeslow def test_remote_versions(): """Test a package for which remote versions should be available.""" @@ -31,6 +36,7 @@ def test_remote_versions(): versions('zlib') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.maybeslow def test_remote_versions_only(): """Test a package for which remote versions should be available.""" @@ -38,6 +44,7 @@ def test_remote_versions_only(): versions('--remote', 'zlib') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.usefixtures('mock_packages') def test_new_versions_only(monkeypatch): """Test a package for which new versions should be available.""" @@ -66,6 +73,7 @@ def mock_fetch_remote_versions(*args, **kwargs): assert(v.strip(' \n\t') == "99.99.99\n 3.2.1") +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.maybeslow def test_no_versions(): """Test a package for which no remote versions are available.""" @@ -73,6 +81,7 @@ def test_no_versions(): versions('converge') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.maybeslow def test_no_unchecksummed_versions(): """Test a package for which no unchecksummed versions are available.""" @@ -80,6 +89,7 @@ def test_no_unchecksummed_versions(): versions('bzip2') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.maybeslow def test_versions_no_url(): """Test a package with versions but without a ``url`` attribute.""" @@ -87,6 +97,7 @@ def test_versions_no_url(): versions('graphviz') +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.maybeslow def test_no_versions_no_url(): """Test a package without versions or a ``url`` attribute.""" diff --git a/lib/spack/spack/test/cmd/view.py b/lib/spack/spack/test/cmd/view.py index bdc44ffa2c..a3d40493fe 100644 --- a/lib/spack/spack/test/cmd/view.py +++ b/lib/spack/spack/test/cmd/view.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os.path +import sys import pytest @@ -25,6 +26,7 @@ def create_projection_file(tmpdir, projection): return projection_file +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.parametrize('cmd', ['hardlink', 'symlink', 'hard', 'add', 'copy', 'relocate']) def test_view_link_type( @@ -41,6 +43,7 @@ def test_view_link_type( assert os.path.islink(package_prefix) == is_link_cmd +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.parametrize('add_cmd', ['hardlink', 'symlink', 'hard', 'add', 'copy', 'relocate']) def test_view_link_type_remove( @@ -56,6 +59,7 @@ def test_view_link_type_remove( assert not os.path.exists(bindir) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") @pytest.mark.parametrize('cmd', ['hardlink', 'symlink', 'hard', 'add', 'copy', 'relocate']) def test_view_projections( @@ -81,6 +85,7 @@ def test_view_projections( assert os.path.islink(package_prefix) == is_symlink_cmd +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_multiple_projections( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -103,6 +108,7 @@ def test_view_multiple_projections( assert os.path.exists(extendee_prefix) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_multiple_projections_all_first( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -125,6 +131,7 @@ def test_view_multiple_projections_all_first( assert os.path.exists(extendee_prefix) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_external( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -134,6 +141,7 @@ def test_view_external( assert 'Skipping external package: externaltool' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_extension( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -160,6 +168,7 @@ def test_view_extension( assert os.path.exists(os.path.join(viewpath, 'bin', 'extension1')) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_extension_projection( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -193,6 +202,7 @@ def test_view_extension_projection( 'bin', 'extension1')) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_extension_remove( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -212,6 +222,7 @@ def test_view_extension_remove( assert not os.path.exists(os.path.join(viewpath, 'bin', 'extension1')) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_extension_conflict( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -224,6 +235,7 @@ def test_view_extension_conflict( assert 'Package conflict detected' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_extension_conflict_ignored( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -237,6 +249,7 @@ def test_view_extension_conflict_ignored( assert fin.read() == '1.0' +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_extension_global_activation( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -266,6 +279,7 @@ def test_view_extension_global_activation( assert not os.path.exists(os.path.join(viewpath, 'bin', 'extension2')) +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_extendee_with_global_activations( tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery): @@ -279,6 +293,7 @@ def test_view_extendee_with_global_activations( assert 'Error: Globally activated extensions cannot be used' in output +@pytest.mark.skipif(sys.platform == 'win32', reason="Error on Win") def test_view_fails_with_missing_projections_file(tmpdir): viewpath = str(tmpdir.mkdir('view')) projection_file = os.path.join(str(tmpdir), 'nonexistent') diff --git a/lib/spack/spack/test/compilers/basics.py b/lib/spack/spack/test/compilers/basics.py index bb46f00974..d17655122c 100644 --- a/lib/spack/spack/test/compilers/basics.py +++ b/lib/spack/spack/test/compilers/basics.py @@ -212,6 +212,8 @@ def call_compiler(exe, *args, **kwargs): return no_flag_output +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('exe,flagname', [ ('cxx', ''), ('cxx', 'cxxflags'), @@ -265,6 +267,8 @@ def test_get_compiler_link_paths_no_verbose_flag(): assert dirs == [] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.enable_compiler_link_paths def test_get_compiler_link_paths_load_env(working_env, monkeypatch, tmpdir): gcc = str(tmpdir.join('gcc')) @@ -697,6 +701,8 @@ def test_raising_if_compiler_target_is_over_specific(config): spack.compilers.get_compilers(cfg, 'gcc@9.0.1', arch_spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_compiler_get_real_version(working_env, monkeypatch, tmpdir): # Test variables test_version = '2.2.2' @@ -806,6 +812,8 @@ def _call(*args, **kwargs): assert 'SPACK_TEST_CMP_ON' not in os.environ +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_compiler_flags_use_real_version(working_env, monkeypatch, tmpdir): # Create compiler gcc = str(tmpdir.join('gcc')) @@ -841,6 +849,8 @@ def test_compiler_flags_use_real_version(working_env, monkeypatch, tmpdir): assert flag == '-std=c++0x' +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_apple_clang_setup_environment(mock_executable, monkeypatch): """Test a code path that is taken only if the package uses Xcode on MacOS. @@ -902,6 +912,8 @@ def _listdir(path): assert env.env_modifications[2].name == 'DEVELOPER_DIR' +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('xcode_select_output', [ '', '/Library/Developer/CommandLineTools' ]) diff --git a/lib/spack/spack/test/compilers/detection.py b/lib/spack/spack/test/compilers/detection.py index 6915b894c3..9f79ed1cb6 100644 --- a/lib/spack/spack/test/compilers/detection.py +++ b/lib/spack/spack/test/compilers/detection.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) """Test detection of compiler version""" import os +import sys import pytest @@ -320,6 +321,8 @@ def test_xl_version_detection(version_str, expected_version): assert version == expected_version +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('compiler,version', [ ('gcc', '8.1.0'), ('gcc', '1.0.0-foo'), diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index a5eecd6f8c..fd28f77a6a 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -166,6 +166,8 @@ def change(self, context): return _changing_pkg +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") # This must use the mutable_config fixture because the test # adjusting_default_target_based_on_compiler uses the current_host fixture, # which changes the config. @@ -367,6 +369,8 @@ def test_concretize_two_virtuals_with_dual_provider_and_a_conflict( with pytest.raises(spack.error.SpackError): s.concretize() + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_no_matching_compiler_specs(self, mock_low_high_config): # only relevant when not building compilers as needed with spack.concretize.enable_compiler_existence_check(): @@ -429,6 +433,8 @@ def test_compiler_inheritance(self, compiler_str): assert spec['libdwarf'].compiler.satisfies(compiler_str) assert spec['libelf'].compiler.satisfies(compiler_str) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_external_package(self): spec = Spec('externaltool%gcc') spec.concretize() @@ -436,6 +442,8 @@ def test_external_package(self): assert 'externalprereq' not in spec assert spec['externaltool'].compiler.satisfies('gcc') + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_external_package_module(self): # No tcl modules on darwin/linux machines # TODO: improved way to check for this. @@ -457,6 +465,8 @@ def test_nobuild_package(self): with pytest.raises(spack.error.SpecError): spec.concretize() + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_external_and_virtual(self): spec = Spec('externaltest') spec.concretize() @@ -704,6 +714,8 @@ def test_noversion_pkg(self, spec): with pytest.raises(spack.error.SpackError): Spec(spec).concretized() + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") # Include targets to prevent regression on 20537 @pytest.mark.parametrize('spec, best_achievable', [ ('mpileaks%gcc@4.4.7 ^dyninst@10.2.1 target=x86_64:', 'core2'), @@ -722,6 +734,8 @@ def test_adjusting_default_target_based_on_compiler( s = Spec(spec).concretized() assert str(s.architecture.target) == str(expected) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('8735,14730') def test_compiler_version_matches_any_entry_in_compilers_yaml(self): # Ensure that a concrete compiler with different compiler version @@ -1112,6 +1126,8 @@ def test_custom_compiler_version(self): s = Spec('a %gcc@foo os=redhat6').concretized() assert '%gcc@foo' in s + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_all_patches_applied(self): uuidpatch = 'a60a42b73e03f207433c5579de207c6ed61d58e4d12dd3b5142eb525728d89ea' localpatch = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' @@ -1149,6 +1165,8 @@ def test_external_package_versions(self, spec_str, is_external, expected): assert s.external == is_external assert s.satisfies(expected) + @pytest.mark.skipif(sys.platform == "win32", + reason='Not supported on Windows (yet)') @pytest.mark.regression('20292') @pytest.mark.parametrize('context', [ {'add_variant': True, 'delete_variant': False}, diff --git a/lib/spack/spack/test/concretize_preferences.py b/lib/spack/spack/test/concretize_preferences.py index 7bcfc75f7d..4f31e18d66 100644 --- a/lib/spack/spack/test/concretize_preferences.py +++ b/lib/spack/spack/test/concretize_preferences.py @@ -3,7 +3,9 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import os import stat +import sys import pytest @@ -70,6 +72,8 @@ def assert_variant_values(spec, **variants): assert concrete.variants[variant].value == value +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('concretize_scope', 'mock_packages') class TestConcretizePreferences(object): @pytest.mark.parametrize('package_name,variant_value,expected_results', [ @@ -230,7 +234,7 @@ def test_external_mpi(self): # ensure that once config is in place, external is used spec = Spec('mpi') spec.concretize() - assert spec['mpich'].external_path == '/dummy/path' + assert spec['mpich'].external_path == os.sep + os.path.join('dummy', 'path') def test_external_module(self, monkeypatch): """Test that packages can find externals specified by module diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py index e7a21fe1dd..1ab9c48eaa 100644 --- a/lib/spack/spack/test/config.py +++ b/lib/spack/spack/test/config.py @@ -6,12 +6,13 @@ import collections import getpass import os +import sys import tempfile import pytest from six import StringIO -from llnl.util.filesystem import mkdirp, touch +from llnl.util.filesystem import getuid, mkdirp, touch import spack.config import spack.environment as ev @@ -333,6 +334,8 @@ def __init__(self, path): self.path = path +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_substitute_config_variables(mock_low_high_config, monkeypatch): prefix = spack.paths.prefix.lstrip('/') @@ -436,6 +439,8 @@ def test_merge_with_defaults(mock_low_high_config, write_config_file): assert cfg['baz']['version'] == ['c'] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_substitute_user(mock_low_high_config): user = getpass.getuser() assert '/foo/bar/' + user + '/baz' == spack_path.canonicalize_path( @@ -443,6 +448,17 @@ def test_substitute_user(mock_low_high_config): ) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") +def test_substitute_user_config(mock_low_high_config): + user_config_path = spack.paths.user_config_path + assert user_config_path + '/baz' == spack_path.canonicalize_path( + '$user_cache_path/baz' + ) + + +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_substitute_user_cache(mock_low_high_config): user_cache_path = spack.paths.user_cache_path assert user_cache_path + '/baz' == spack_path.canonicalize_path( @@ -450,6 +466,8 @@ def test_substitute_user_cache(mock_low_high_config): ) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_substitute_tempdir(mock_low_high_config): tempdir = tempfile.gettempdir() assert tempdir == spack_path.canonicalize_path('$tempdir') @@ -466,6 +484,8 @@ def test_substitute_tempdir(mock_low_high_config): '/path', os.path.sep.join(reps))[:MAX_PADDED_LEN] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('config_settings,expected', [ ([], [None, None, None]), ([['config:install_tree:root', '/path']], ['/path', None, None]), @@ -816,7 +836,9 @@ def test_bad_config_section(mock_low_high_config): spack.config.get('foobar') -@pytest.mark.skipif(os.getuid() == 0, reason='user is root') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") +@pytest.mark.skipif(getuid() == 0, reason='user is root') def test_bad_command_line_scopes(tmpdir, mock_low_high_config): cfg = spack.config.Configuration() diff --git a/lib/spack/spack/test/config_values.py b/lib/spack/spack/test/config_values.py index 7df17173a5..e1c736768c 100644 --- a/lib/spack/spack/test/config_values.py +++ b/lib/spack/spack/test/config_values.py @@ -2,12 +2,16 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import spack.spec import spack.store +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('hash_length', [1, 2, 3, 4, 5, 9]) @pytest.mark.usefixtures('mock_packages') def test_set_install_hash_length(hash_length, mutable_config, tmpdir): @@ -24,7 +28,9 @@ def test_set_install_hash_length(hash_length, mutable_config, tmpdir): assert len(hash_str) == hash_length -@pytest.mark.usefixtures('mock_packages') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") +@pytest.mark.use_fixtures('mock_packages') def test_set_install_hash_length_upper_case(mutable_config, tmpdir): mutable_config.set('config:install_hash_length', 5) mutable_config.set( diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 45f034df26..97399190b6 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -13,6 +13,7 @@ import os.path import re import shutil +import sys import tempfile import xml.etree.ElementTree from typing import Dict # novm @@ -375,7 +376,7 @@ def check_for_leftover_stage_files(request, mock_stage, ignore_stage_files): stage_files = os.listdir(stage_path) files_in_stage = set(stage_files) - ignore_stage_files except OSError as err: - if err.errno == errno.ENOENT: + if err.errno == errno.ENOENT or err.errno == errno.EINVAL: pass else: raise @@ -591,7 +592,11 @@ def configuration_dir(tmpdir_factory, linux_os): tmpdir.ensure('user', dir=True) # Slightly modify config.yaml and compilers.yaml - solver = os.environ.get('SPACK_TEST_SOLVER', 'clingo') + if os.name == 'nt': + solver = 'original' + else: + solver = os.environ.get('SPACK_TEST_SOLVER', 'clingo') + config_yaml = test_config.join('config.yaml') modules_root = tmpdir_factory.mktemp('share') tcl_root = modules_root.ensure('modules', dir=True) @@ -1032,10 +1037,14 @@ def mock_archive(request, tmpdir_factory): ['url', 'path', 'archive_file', 'expanded_archive_basedir']) archive_file = str(tmpdir.join(archive_name)) + if sys.platform == 'win32': + url = ('file:///' + archive_file) + else: + url = ('file://' + archive_file) # Return the url yield Archive( - url=('file://' + archive_file), + url=url, archive_file=archive_file, path=str(repodir), expanded_archive_basedir=spack.stage._source_path_subdir) diff --git a/lib/spack/spack/test/container/cli.py b/lib/spack/spack/test/container/cli.py index 6eb40b61e5..4199aa51b7 100644 --- a/lib/spack/spack/test/container/cli.py +++ b/lib/spack/spack/test/container/cli.py @@ -8,6 +8,7 @@ import spack.container.images import spack.main +import spack.platforms containerize = spack.main.SpackCommand('containerize') @@ -26,6 +27,8 @@ def test_listing_possible_os(): assert expected_os in output +@pytest.mark.skipif(str(spack.platforms.host()) == "windows", + reason="test unsupported on Windows") @pytest.mark.maybeslow @pytest.mark.requires_executables('git') def test_bootstrap_phase(minimal_configuration, config_dumper, capsys): diff --git a/lib/spack/spack/test/database.py b/lib/spack/spack/test/database.py index 89359d2a44..0f471c6a8b 100644 --- a/lib/spack/spack/test/database.py +++ b/lib/spack/spack/test/database.py @@ -12,6 +12,7 @@ import json import os import shutil +import sys import pytest @@ -61,6 +62,8 @@ def upstream_and_downstream_db(tmpdir_factory, gen_mock_layout): downstream_db, downstream_layout +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_installed_upstream(upstream_and_downstream_db): upstream_write_db, upstream_db, upstream_layout,\ @@ -104,6 +107,8 @@ def test_installed_upstream(upstream_and_downstream_db): downstream_db._check_ref_counts() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_removed_upstream_dep(upstream_and_downstream_db): upstream_write_db, upstream_db, upstream_layout,\ @@ -135,6 +140,8 @@ def test_removed_upstream_dep(upstream_and_downstream_db): new_downstream._read() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_add_to_upstream_after_downstream(upstream_and_downstream_db): """An upstream DB can add a package after it is installed in the downstream @@ -172,6 +179,8 @@ def test_add_to_upstream_after_downstream(upstream_and_downstream_db): spack.store.db = orig_db +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config', 'temporary_store') def test_cannot_write_upstream(tmpdir_factory, gen_mock_layout): roots = [str(tmpdir_factory.mktemp(x)) for x in ['a', 'b']] @@ -197,6 +206,8 @@ def test_cannot_write_upstream(tmpdir_factory, gen_mock_layout): upstream_dbs[0].add(spec, layouts[1]) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config', 'temporary_store') def test_recursive_upstream_dbs(tmpdir_factory, gen_mock_layout): roots = [str(tmpdir_factory.mktemp(x)) for x in ['a', 'b', 'c']] @@ -371,6 +382,8 @@ def _mock_remove(spec): spec.package.do_uninstall(spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_default_queries(database): # Testing a package whose name *doesn't* start with 'lib' # to ensure the library has 'lib' prepended to the name @@ -411,6 +424,8 @@ def test_default_queries(database): assert os.path.exists(command.path) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_005_db_exists(database): """Make sure db cache file exists after creating.""" index_file = os.path.join(database.root, '.spack-db', 'index.json') @@ -423,6 +438,8 @@ def test_005_db_exists(database): validate(index_object, schema) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_010_all_install_sanity(database): """Ensure that the install layout reflects what we think it does.""" all_specs = spack.store.layout.all_specs() @@ -458,6 +475,8 @@ def test_010_all_install_sanity(database): ) == 1 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_015_write_and_read(mutable_database): # write and read DB with spack.store.db.write_transaction(): @@ -472,6 +491,8 @@ def test_015_write_and_read(mutable_database): assert new_rec.installed == rec.installed +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_017_write_and_read_without_uuid(mutable_database, monkeypatch): monkeypatch.setattr(spack.database, '_use_uuid', False) # write and read DB @@ -487,17 +508,23 @@ def test_017_write_and_read_without_uuid(mutable_database, monkeypatch): assert new_rec.installed == rec.installed +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_020_db_sanity(database): """Make sure query() returns what's actually in the db.""" _check_db_sanity(database) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_025_reindex(mutable_database): """Make sure reindex works and ref counts are valid.""" spack.store.store.reindex() _check_db_sanity(mutable_database) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_026_reindex_after_deprecate(mutable_database): """Make sure reindex works and ref counts are valid after deprecation.""" mpich = mutable_database.query_one('mpich') @@ -519,6 +546,8 @@ def __call__(self): _mock_remove('mpileaks ^zmpi') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_030_db_sanity_from_another_process(mutable_database): spack_process = spack.subprocess_context.SpackTestProcess(ReadModify()) p = spack_process.create() @@ -530,11 +559,15 @@ def test_030_db_sanity_from_another_process(mutable_database): assert len(mutable_database.query('mpileaks ^zmpi')) == 0 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_040_ref_counts(database): """Ensure that we got ref counts right when we read the DB.""" database._check_ref_counts() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_041_ref_counts_deprecate(mutable_database): """Ensure that we have appropriate ref counts after deprecating""" mpich = mutable_database.query_one('mpich') @@ -544,6 +577,8 @@ def test_041_ref_counts_deprecate(mutable_database): mutable_database._check_ref_counts() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_050_basic_query(database): """Ensure querying database is consistent with what is installed.""" # query everything @@ -580,14 +615,20 @@ def test_050_basic_query(database): assert len(database.query(end_date=datetime.datetime.max)) == total_specs +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_060_remove_and_add_root_package(mutable_database): _check_remove_and_add_package(mutable_database, 'mpileaks ^mpich') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_070_remove_and_add_dependency_package(mutable_database): _check_remove_and_add_package(mutable_database, 'dyninst') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_080_root_ref_counts(mutable_database): rec = mutable_database.get_record('mpileaks ^mpich') @@ -612,6 +653,8 @@ def test_080_root_ref_counts(mutable_database): assert mutable_database.get_record('mpich').ref_count == 2 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_090_non_root_ref_counts(mutable_database): mutable_database.get_record('mpileaks ^mpich') mutable_database.get_record('callpath ^mpich') @@ -641,6 +684,8 @@ def test_090_non_root_ref_counts(mutable_database): assert mpich_rec.ref_count == 0 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_100_no_write_with_exception_on_remove(database): def fail_while_writing(): with database.write_transaction(): @@ -658,6 +703,8 @@ def fail_while_writing(): assert len(database.query('mpileaks ^zmpi', installed=any)) == 1 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_110_no_write_with_exception_on_install(database): def fail_while_writing(): with database.write_transaction(): @@ -675,6 +722,8 @@ def fail_while_writing(): assert database.query('cmake', installed=any) == [] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_115_reindex_with_packages_not_in_repo(mutable_database): # Dont add any package definitions to this repository, the idea is that # packages should not have to be defined in the repository once they @@ -684,6 +733,8 @@ def test_115_reindex_with_packages_not_in_repo(mutable_database): _check_db_sanity(mutable_database) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_external_entries_in_db(mutable_database): rec = mutable_database.get_record('mpileaks ^zmpi') assert rec.spec.external_path is None @@ -701,6 +752,8 @@ def test_external_entries_in_db(mutable_database): assert rec.explicit is True +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('8036') def test_regression_issue_8036(mutable_database, usr_folder_exists): # The test ensures that the external package prefix is treated as @@ -716,6 +769,8 @@ def test_regression_issue_8036(mutable_database, usr_folder_exists): assert s.package.installed +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('11118') def test_old_external_entries_prefix(mutable_database): with open(spack.store.db._index_path, 'r') as f: @@ -741,6 +796,8 @@ def test_old_external_entries_prefix(mutable_database): assert record.spec.prefix == record.spec.external_path +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_uninstall_by_spec(mutable_database): with mutable_database.write_transaction(): for spec in mutable_database.query(): @@ -751,6 +808,8 @@ def test_uninstall_by_spec(mutable_database): assert len(mutable_database.query()) == 0 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_query_unused_specs(mutable_database): # This spec installs a fake cmake as a build only dependency s = spack.spec.Spec('simple-inheritance') @@ -762,6 +821,8 @@ def test_query_unused_specs(mutable_database): assert unused[0].name == 'cmake' +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('10019') def test_query_spec_with_conditional_dependency(mutable_database): # The issue is triggered by having dependencies that are @@ -774,6 +835,8 @@ def test_query_spec_with_conditional_dependency(mutable_database): assert not results +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('10019') def test_query_spec_with_non_conditional_virtual_dependency(database): # Ensure the same issue doesn't come up for virtual @@ -782,6 +845,8 @@ def test_query_spec_with_non_conditional_virtual_dependency(database): assert len(results) == 1 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_failed_spec_path_error(database): """Ensure spec not concrete check is covered.""" s = spack.spec.Spec('a') @@ -789,6 +854,8 @@ def test_failed_spec_path_error(database): spack.store.db._failed_spec_path(s) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_clear_failure_keep(mutable_database, monkeypatch, capfd): """Add test coverage for clear_failure operation when to be retained.""" @@ -804,6 +871,8 @@ def _is(db, spec): assert 'Retaining failure marking' in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_clear_failure_forced(mutable_database, monkeypatch, capfd): """Add test coverage for clear_failure operation when force.""" @@ -822,6 +891,8 @@ def _is(db, spec): assert 'Unable to remove failure marking' in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_mark_failed(mutable_database, monkeypatch, tmpdir, capsys): """Add coverage to mark_failed.""" @@ -843,6 +914,8 @@ def _raise_exc(lock): del spack.store.db._prefix_failures[s.prefix] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_prefix_failed(mutable_database, monkeypatch): """Add coverage to prefix_failed operation.""" @@ -867,6 +940,8 @@ def _is(db, spec): assert spack.store.db.prefix_failed(s) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_prefix_read_lock_error(mutable_database, monkeypatch): """Cover the prefix read lock exception.""" def _raise(db, spec): @@ -882,6 +957,8 @@ def _raise(db, spec): assert False +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_prefix_write_lock_error(mutable_database, monkeypatch): """Cover the prefix write lock exception.""" def _raise(db, spec): diff --git a/lib/spack/spack/test/directory_layout.py b/lib/spack/spack/test/directory_layout.py index f7c7a6dad0..11bf7ed34a 100644 --- a/lib/spack/spack/test/directory_layout.py +++ b/lib/spack/spack/test/directory_layout.py @@ -8,6 +8,7 @@ """ import os import os.path +import sys import pytest @@ -23,6 +24,8 @@ max_packages = 10 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_yaml_directory_layout_parameters(tmpdir, config): """This tests the various parameters that can be used to configure the install location """ @@ -78,6 +81,8 @@ def test_yaml_directory_layout_parameters(tmpdir, config): projections=projections_package7) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_read_and_write_spec(temporary_store, config, mock_packages): """This goes through each package in spack and creates a directory for it. It then ensures that the spec for the directory's @@ -203,6 +208,8 @@ def test_handle_unknown_package(temporary_store, config, mock_packages): assert spec.dag_hash() == spec_from_file.dag_hash() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_find(temporary_store, config, mock_packages): """Test that finding specs within an install layout works.""" layout = temporary_store.layout @@ -226,6 +233,8 @@ def test_find(temporary_store, config, mock_packages): assert found_specs[name].eq_dag(spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_yaml_directory_layout_build_path(tmpdir, config): """This tests build path method.""" spec = Spec('python') diff --git a/lib/spack/spack/test/env.py b/lib/spack/spack/test/env.py index f68ffd3175..fc4cf031a8 100644 --- a/lib/spack/spack/test/env.py +++ b/lib/spack/spack/test/env.py @@ -11,6 +11,8 @@ import spack.spec +@pytest.mark.skipif(str(spack.platforms.host()) == 'windows', + reason='Not supported on Windows (yet)') def test_hash_change_no_rehash_concrete(tmpdir, mock_packages, config): # create an environment env_path = tmpdir.mkdir('env_dir').strpath diff --git a/lib/spack/spack/test/environment_modifications.py b/lib/spack/spack/test/environment_modifications.py index 44c38a99ae..93e904a378 100644 --- a/lib/spack/spack/test/environment_modifications.py +++ b/lib/spack/spack/test/environment_modifications.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -162,6 +163,8 @@ def test_unset(env): os.environ['UNSET_ME'] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_filter_system_paths(miscellaneous_paths): """Tests that the filtering of system paths works as expected.""" filtered = filter_system_paths(miscellaneous_paths) @@ -175,6 +178,8 @@ def test_filter_system_paths(miscellaneous_paths): assert filtered == expected +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_set_path(env): """Tests setting paths in an environment variable.""" @@ -190,6 +195,8 @@ def test_set_path(env): assert 'foo;bar;baz' == os.environ['B'] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_path_manipulation(env): """Tests manipulating list of paths in the environment.""" @@ -254,6 +261,8 @@ def test_extend(env): assert x is y +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('prepare_environment_for_tests') def test_source_files(files_to_be_sourced): """Tests the construction of a list of environment modifications that are @@ -321,6 +330,8 @@ def test_preserve_environment(prepare_environment_for_tests): assert os.environ['PATH_LIST'] == '/path/second:/path/third' +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('files,expected,deleted', [ # Sets two variables ((os.path.join(datadir, 'sourceme_first.sh'),), @@ -406,6 +417,8 @@ def test_sanitize_regex(env, blacklist, whitelist, expected, deleted): assert all(x not in after for x in deleted) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('12085') @pytest.mark.parametrize('before,after,search_list', [ # Set environment variables @@ -445,6 +458,8 @@ def test_from_environment_diff(before, after, search_list): assert item in mod +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('15775') def test_blacklist_lmod_variables(): # Construct the list of environment modifications diff --git a/lib/spack/spack/test/git_fetch.py b/lib/spack/spack/test/git_fetch.py index 6e8993978c..671d2db298 100644 --- a/lib/spack/spack/test/git_fetch.py +++ b/lib/spack/spack/test/git_fetch.py @@ -6,6 +6,7 @@ import copy import os import shutil +import sys import pytest @@ -82,6 +83,8 @@ def test_bad_git(tmpdir, mock_bad_git): fetcher.fetch() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize("type_of_test", ['master', 'branch', 'tag', 'commit']) @pytest.mark.parametrize("secure", [True, False]) def test_fetch(type_of_test, @@ -137,6 +140,8 @@ def test_fetch(type_of_test, assert h('HEAD') == h(t.revision) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize("type_of_test", ['branch', 'commit']) def test_debug_fetch( mock_packages, type_of_test, mock_git_repository, config, monkeypatch @@ -177,6 +182,8 @@ def test_needs_stage(): fetcher.fetch() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize("get_full_repo", [True, False]) def test_get_full_repo(get_full_repo, git_version, mock_git_repository, config, mutable_mock_repo, monkeypatch): @@ -222,6 +229,8 @@ def test_get_full_repo(get_full_repo, git_version, mock_git_repository, assert(ncommits == 1) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.disable_clean_stage_check @pytest.mark.parametrize("submodules", [True, False]) def test_gitsubmodule(submodules, mock_git_repository, config, @@ -251,6 +260,8 @@ def test_gitsubmodule(submodules, mock_git_repository, config, assert not os.path.isfile(file_path) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.disable_clean_stage_check def test_gitsubmodules_delete( mock_git_repository, config, mutable_mock_repo, monkeypatch diff --git a/lib/spack/spack/test/graph.py b/lib/spack/spack/test/graph.py index c836c9905a..185f1375a2 100644 --- a/lib/spack/spack/test/graph.py +++ b/lib/spack/spack/test/graph.py @@ -48,6 +48,8 @@ def test_static_graph_mpileaks(config, mock_packages): assert ' "dyninst" -> "libelf"\n' in dot +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_dynamic_dot_graph_mpileaks(mock_packages, config): """Test dynamically graphing the mpileaks package.""" s = spack.spec.Spec('mpileaks').concretized() diff --git a/lib/spack/spack/test/hg_fetch.py b/lib/spack/spack/test/hg_fetch.py index 5b2a41875f..befb30b4d2 100644 --- a/lib/spack/spack/test/hg_fetch.py +++ b/lib/spack/spack/test/hg_fetch.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -21,6 +22,8 @@ not which('hg'), reason='requires mercurial to be installed') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize("type_of_test", ['default', 'rev0']) @pytest.mark.parametrize("secure", [True, False]) def test_fetch( diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py index 85865be0a3..9465b5ec0e 100644 --- a/lib/spack/spack/test/install.py +++ b/lib/spack/spack/test/install.py @@ -5,6 +5,7 @@ import os import shutil +import sys import pytest @@ -31,6 +32,8 @@ def find_nothing(*args): 'Repo package access is disabled for test') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_and_uninstall(install_mockery, mock_fetch, monkeypatch): # Get a basic concrete spec for the trivial install package. spec = Spec('trivial-install-test-package') @@ -97,6 +100,8 @@ def __getattr__(self, attr): return getattr(self.wrapped_stage, attr) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_partial_install_delete_prefix_and_stage(install_mockery, mock_fetch): spec = Spec('canfail').concretized() pkg = spack.repo.get(spec) @@ -126,6 +131,8 @@ def test_partial_install_delete_prefix_and_stage(install_mockery, mock_fetch): pkg.remove_prefix = instance_rm_prefix +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.disable_clean_stage_check def test_failing_overwrite_install_should_keep_previous_installation( mock_fetch, install_mockery @@ -151,6 +158,8 @@ def test_failing_overwrite_install_should_keep_previous_installation( assert os.path.exists(spec.prefix) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_dont_add_patches_to_installed_package( install_mockery, mock_fetch, monkeypatch ): @@ -171,6 +180,8 @@ def test_dont_add_patches_to_installed_package( assert dependent['dependency-install'] == dependency +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_installed_dependency_request_conflicts( install_mockery, mock_fetch, mutable_mock_repo): dependency = Spec('dependency-install') @@ -184,6 +195,8 @@ def test_installed_dependency_request_conflicts( dependent.concretize() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_dependency_symlinks_pkg( install_mockery, mock_fetch, mutable_mock_repo): """Test dependency flattening/symlinks mock package.""" @@ -197,6 +210,8 @@ def test_install_dependency_symlinks_pkg( assert os.path.isdir(dependency_dir) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_times( install_mockery, mock_fetch, mutable_mock_repo): """Test install times added.""" @@ -223,6 +238,8 @@ def test_install_times( assert abs(total - times['total']['seconds']) < 5 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_flatten_deps( install_mockery, mock_fetch, mutable_mock_repo): """Explicitly test the flattening code for coverage purposes.""" @@ -272,6 +289,8 @@ def _install_upstream(*specs): return _install_upstream +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_installed_upstream_external(install_upstream, mock_fetch): """Check that when a dependency package is recorded as installed in an upstream database that it is not reinstalled. @@ -291,6 +310,8 @@ def test_installed_upstream_external(install_upstream, mock_fetch): assert os.path.exists(dependent.prefix) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_installed_upstream(install_upstream, mock_fetch): """Check that when a dependency package is recorded as installed in an upstream database that it is not reinstalled. @@ -311,6 +332,8 @@ def test_installed_upstream(install_upstream, mock_fetch): assert os.path.exists(dependent.prefix) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.disable_clean_stage_check def test_partial_install_keep_prefix(install_mockery, mock_fetch, monkeypatch): spec = Spec('canfail').concretized() @@ -337,6 +360,8 @@ def test_partial_install_keep_prefix(install_mockery, mock_fetch, monkeypatch): assert not pkg.stage.test_destroyed +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_second_install_no_overwrite_first(install_mockery, mock_fetch, monkeypatch): spec = Spec('canfail').concretized() pkg = spack.repo.get(spec) @@ -351,6 +376,8 @@ def test_second_install_no_overwrite_first(install_mockery, mock_fetch, monkeypa pkg.do_install() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_prefix_collision_fails(config, mock_fetch, mock_packages, tmpdir): """ Test that different specs with coinciding install prefixes will fail @@ -368,12 +395,16 @@ def test_install_prefix_collision_fails(config, mock_fetch, mock_packages, tmpdi pkg_b.do_install() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Package ninja not found") def test_store(install_mockery, mock_fetch): spec = Spec('cmake-client').concretized() pkg = spec.package pkg.do_install() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.disable_clean_stage_check def test_failing_build(install_mockery, mock_fetch, capfd): spec = Spec('failing-build').concretized() @@ -388,6 +419,8 @@ class MockInstallError(spack.error.SpackError): pass +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_uninstall_by_spec_errors(mutable_database): """Test exceptional cases with the uninstall command.""" @@ -403,6 +436,8 @@ def test_uninstall_by_spec_errors(mutable_database): PackageBase.uninstall_by_spec(rec.spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.disable_clean_stage_check def test_nosource_pkg_install( install_mockery, mock_fetch, mock_packages, capfd): @@ -417,6 +452,8 @@ def test_nosource_pkg_install( assert "Missing a source id for nosource" in out[1] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_nosource_pkg_install_post_install( install_mockery, mock_fetch, mock_packages): """Test install phases with the nosource package with post-install.""" @@ -435,6 +472,8 @@ def test_nosource_pkg_install_post_install( assert os.path.isfile(post_install_txt) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_pkg_build_paths(install_mockery): # Get a basic concrete spec for the trivial install package. spec = Spec('trivial-install-test-package').concretized() @@ -468,6 +507,8 @@ def test_pkg_build_paths(install_mockery): shutil.rmtree(log_dir) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_pkg_install_paths(install_mockery): # Get a basic concrete spec for the trivial install package. spec = Spec('trivial-install-test-package').concretized() @@ -504,6 +545,8 @@ def test_pkg_install_paths(install_mockery): shutil.rmtree(log_dir) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_log_install_without_build_files(install_mockery): """Test the installer log function when no build files are present.""" # Get a basic concrete spec for the trivial install package. @@ -514,6 +557,8 @@ def test_log_install_without_build_files(install_mockery): spack.installer.log(spec.package) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_log_install_with_build_files(install_mockery, monkeypatch): """Test the installer's log function when have build files.""" config_log = 'config.log' diff --git a/lib/spack/spack/test/installer.py b/lib/spack/spack/test/installer.py index 37d1de78b0..1684aec447 100644 --- a/lib/spack/spack/test/installer.py +++ b/lib/spack/spack/test/installer.py @@ -5,6 +5,7 @@ import os import shutil +import sys import py import pytest @@ -118,6 +119,8 @@ def test_hms(sec, result): assert inst._hms(sec) == result +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_get_dependent_ids(install_mockery, mock_packages): # Concretize the parent package, which handle dependency too spec = spack.spec.Spec('a') @@ -151,6 +154,8 @@ def test_install_msg(monkeypatch): assert inst.install_msg(name, pid) == expected +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_from_cache_errors(install_mockery, capsys): """Test to ensure cover _install_from_cache errors.""" spec = spack.spec.Spec('trivial-install-test-package') @@ -171,6 +176,8 @@ def test_install_from_cache_errors(install_mockery, capsys): assert not spec.package.installed_from_binary_cache +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_from_cache_ok(install_mockery, monkeypatch): """Test to ensure cover _install_from_cache to the return.""" spec = spack.spec.Spec('trivial-install-test-package') @@ -181,6 +188,8 @@ def test_install_from_cache_ok(install_mockery, monkeypatch): assert inst._install_from_cache(spec.package, True, True, False) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_process_external_package_module(install_mockery, monkeypatch, capfd): """Test to simply cover the external module message path.""" spec = spack.spec.Spec('trivial-install-test-package') @@ -209,6 +218,8 @@ def test_process_binary_cache_tarball_none(install_mockery, monkeypatch, assert 'exists in binary cache but' in capfd.readouterr()[0] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_process_binary_cache_tarball_tar(install_mockery, monkeypatch, capfd): """Tests of _process_binary_cache_tarball with a tar file.""" def _spec(spec, preferred_mirrors=None): @@ -229,6 +240,8 @@ def _spec(spec, preferred_mirrors=None): assert 'from binary cache' in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_try_install_from_binary_cache(install_mockery, mock_packages, monkeypatch): """Test return false when no match exists in the mirror""" @@ -238,6 +251,8 @@ def test_try_install_from_binary_cache(install_mockery, mock_packages, assert(not result) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_installer_repr(install_mockery): const_arg = installer_args(['trivial-install-test-package'], {}) installer = create_installer(const_arg) @@ -248,6 +263,8 @@ def test_installer_repr(install_mockery): assert "failed=" in irep +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_installer_str(install_mockery): const_arg = installer_args(['trivial-install-test-package'], {}) installer = create_installer(const_arg) @@ -281,6 +298,8 @@ def test_check_last_phase_error(install_mockery): assert pkg.last_phase in err +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_installer_ensure_ready_errors(install_mockery): const_arg = installer_args(['trivial-install-test-package'], {}) installer = create_installer(const_arg) @@ -310,6 +329,8 @@ def test_installer_ensure_ready_errors(install_mockery): installer._ensure_install_ready(spec.package) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_ensure_locked_err(install_mockery, monkeypatch, tmpdir, capsys): """Test _ensure_locked when a non-lock exception is raised.""" mock_err_msg = 'Mock exception error' @@ -331,6 +352,8 @@ def _raise(lock, timeout): assert mock_err_msg in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_ensure_locked_have(install_mockery, tmpdir, capsys): """Test _ensure_locked when already have lock.""" const_arg = installer_args(['trivial-install-test-package'], {}) @@ -367,6 +390,8 @@ def test_ensure_locked_have(install_mockery, tmpdir, capsys): assert installer._ensure_locked(lock_type, spec.package) == tpl +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('lock_type,reads,writes', [ ('read', 1, 0), ('write', 0, 1)]) @@ -384,6 +409,8 @@ def test_ensure_locked_new_lock( assert lock._writes == writes +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_ensure_locked_new_warn(install_mockery, monkeypatch, tmpdir, capsys): orig_pl = spack.database.Database.prefix_lock @@ -414,6 +441,8 @@ def test_package_id_err(install_mockery): inst.package_id(pkg) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_package_id_ok(install_mockery): spec = spack.spec.Spec('trivial-install-test-package') spec.concretize() @@ -422,6 +451,8 @@ def test_package_id_ok(install_mockery): assert pkg.name in inst.package_id(pkg) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_fake_install(install_mockery): spec = spack.spec.Spec('trivial-install-test-package') spec.concretize() @@ -432,6 +463,8 @@ def test_fake_install(install_mockery): assert os.path.isdir(pkg.prefix.lib) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_packages_needed_to_bootstrap_compiler_none(install_mockery): spec = spack.spec.Spec('trivial-install-test-package') spec.concretize() @@ -442,6 +475,8 @@ def test_packages_needed_to_bootstrap_compiler_none(install_mockery): assert not packages +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_packages_needed_to_bootstrap_compiler_packages(install_mockery, monkeypatch): spec = spack.spec.Spec('trivial-install-test-package') @@ -461,6 +496,8 @@ def _conc_spec(compiler): assert packages +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_dump_packages_deps_ok(install_mockery, tmpdir, mock_packages): """Test happy path for dump_packages with dependencies.""" @@ -473,6 +510,8 @@ def test_dump_packages_deps_ok(install_mockery, tmpdir, mock_packages): assert os.path.isfile(dest_pkg) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_dump_packages_deps_errs(install_mockery, tmpdir, monkeypatch, capsys): """Test error paths for dump_packages with dependencies.""" orig_bpp = spack.store.layout.build_packages_path @@ -592,6 +631,8 @@ def test_combine_phase_logs(tmpdir): assert "Output from %s\n" % log_file in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_check_deps_status_install_failure(install_mockery, monkeypatch): const_arg = installer_args(['a'], {}) installer = create_installer(const_arg) @@ -604,6 +645,8 @@ def test_check_deps_status_install_failure(install_mockery, monkeypatch): installer._check_deps_status(request) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_check_deps_status_write_locked(install_mockery, monkeypatch): const_arg = installer_args(['a'], {}) installer = create_installer(const_arg) @@ -616,6 +659,8 @@ def test_check_deps_status_write_locked(install_mockery, monkeypatch): installer._check_deps_status(request) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_check_deps_status_external(install_mockery, monkeypatch): const_arg = installer_args(['a'], {}) installer = create_installer(const_arg) @@ -627,6 +672,8 @@ def test_check_deps_status_external(install_mockery, monkeypatch): assert list(installer.installed)[0].startswith('b') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_check_deps_status_upstream(install_mockery, monkeypatch): const_arg = installer_args(['a'], {}) installer = create_installer(const_arg) @@ -638,6 +685,8 @@ def test_check_deps_status_upstream(install_mockery, monkeypatch): assert list(installer.installed)[0].startswith('b') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_add_bootstrap_compilers(install_mockery, monkeypatch): from collections import defaultdict @@ -660,6 +709,8 @@ def _pkgs(compiler, architecture, pkgs): assert task.compiler +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_prepare_for_install_on_installed(install_mockery, monkeypatch): """Test of _prepare_for_install's early return for installed task path.""" const_arg = installer_args(['dependent-install'], {}) @@ -674,6 +725,8 @@ def test_prepare_for_install_on_installed(install_mockery, monkeypatch): installer._prepare_for_install(task) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_installer_init_requests(install_mockery): """Test of installer initial requests.""" spec_name = 'dependent-install' @@ -687,6 +740,8 @@ def test_installer_init_requests(install_mockery): assert request.pkg.name == spec_name +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_task_use_cache(install_mockery, monkeypatch): const_arg = installer_args(['trivial-install-test-package'], {}) installer = create_installer(const_arg) @@ -698,6 +753,8 @@ def test_install_task_use_cache(install_mockery, monkeypatch): assert request.pkg_id in installer.installed +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_task_add_compiler(install_mockery, monkeypatch, capfd): config_msg = 'mock add_compilers_to_config' @@ -722,6 +779,8 @@ def _add(_compilers): assert config_msg in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_release_lock_write_n_exception(install_mockery, tmpdir, capsys): """Test _release_lock for supposed write lock with exception.""" const_arg = installer_args(['trivial-install-test-package'], {}) @@ -739,6 +798,8 @@ def test_release_lock_write_n_exception(install_mockery, tmpdir, capsys): assert msg in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('installed', [True, False]) def test_push_task_skip_processed(install_mockery, installed): """Test to ensure skip re-queueing a processed package.""" @@ -758,6 +819,8 @@ def test_push_task_skip_processed(install_mockery, installed): assert len(list(installer.build_tasks)) == 0 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_requeue_task(install_mockery, capfd): """Test to ensure cover _requeue_task.""" const_arg = installer_args(['a'], {}) @@ -782,6 +845,8 @@ def test_requeue_task(install_mockery, capfd): assert ' in progress by another process' in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_cleanup_all_tasks(install_mockery, monkeypatch): """Test to ensure cover _cleanup_all_tasks.""" def _mktask(pkg): @@ -806,6 +871,8 @@ def _rmtask(installer, pkg_id): assert len(installer.build_tasks) == 1 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_setup_install_dir_grp(install_mockery, monkeypatch, capfd): """Test _setup_install_dir's group change.""" mock_group = 'mockgroup' @@ -836,6 +903,8 @@ def _chgrp(path, group): assert expected_msg in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_cleanup_failed_err(install_mockery, tmpdir, monkeypatch, capsys): """Test _cleanup_failed exception path.""" msg = 'Fake release_write exception' @@ -858,6 +927,8 @@ def _raise_except(lock): assert msg in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_update_failed_no_dependent_task(install_mockery): """Test _update_failed with missing dependent build tasks.""" const_arg = installer_args(['dependent-install'], {}) @@ -870,6 +941,8 @@ def test_update_failed_no_dependent_task(install_mockery): assert installer.failed[task.pkg_id] is None +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_uninstalled_deps(install_mockery, monkeypatch, capsys): """Test install with uninstalled dependencies.""" const_arg = installer_args(['dependent-install'], {}) @@ -888,6 +961,8 @@ def test_install_uninstalled_deps(install_mockery, monkeypatch, capsys): assert 'Detected uninstalled dependencies for' in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_failed(install_mockery, monkeypatch, capsys): """Test install with failed install.""" const_arg = installer_args(['b'], {}) @@ -904,6 +979,8 @@ def test_install_failed(install_mockery, monkeypatch, capsys): assert 'failed to install' in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_failed_not_fast(install_mockery, monkeypatch, capsys): """Test install with failed install.""" const_arg = installer_args(['a'], {'fail_fast': False}) @@ -920,6 +997,8 @@ def test_install_failed_not_fast(install_mockery, monkeypatch, capsys): assert 'Skipping build of a' in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_fail_on_interrupt(install_mockery, monkeypatch): """Test ctrl-c interrupted install.""" spec_name = 'a' @@ -944,6 +1023,8 @@ def _interrupt(installer, task, **kwargs): assert spec_name not in installer.installed +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_fail_single(install_mockery, monkeypatch): """Test expected results for failure of single package.""" spec_name = 'a' @@ -971,6 +1052,8 @@ def _install(installer, task, **kwargs): assert spec_name not in installer.installed +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_fail_multi(install_mockery, monkeypatch): """Test expected results for failure of multiple packages.""" spec_name = 'c' @@ -998,6 +1081,8 @@ def _install(installer, task, **kwargs): assert spec_name not in installer.installed +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_fail_fast_on_detect(install_mockery, monkeypatch, capsys): """Test fail_fast install when an install failure is detected.""" const_arg = installer_args(['b'], {'fail_fast': False}) @@ -1029,6 +1114,8 @@ def _test_install_fail_fast_on_except_patch(installer, **kwargs): raise RuntimeError('mock patch failure') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_fail_fast_on_except(install_mockery, monkeypatch, capsys): """Test fail_fast install when an install failure results from an error.""" const_arg = installer_args(['a'], {'fail_fast': True}) @@ -1051,6 +1138,8 @@ def test_install_fail_fast_on_except(install_mockery, monkeypatch, capsys): assert 'Skipping build of a' in out +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_lock_failures(install_mockery, monkeypatch, capfd): """Cover basic install lock failure handling in a single pass.""" def _requeued(installer, task): @@ -1074,6 +1163,8 @@ def _requeued(installer, task): assert exp in ln +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_lock_installed_requeue(install_mockery, monkeypatch, capfd): """Cover basic install handling for installed package.""" const_arg = installer_args(['b'], {}) @@ -1109,6 +1200,8 @@ def _requeued(installer, task): assert exp in ln +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_read_locked_requeue(install_mockery, monkeypatch, capfd): """Cover basic read lock handling for uninstalled package with requeue.""" orig_fn = inst.PackageInstaller._ensure_locked @@ -1147,6 +1240,8 @@ def _requeued(installer, task): assert exp in ln +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_skip_patch(install_mockery, mock_fetch): """Test the path skip_patch install path.""" spec_name = 'b' diff --git a/lib/spack/spack/test/link_paths.py b/lib/spack/spack/test/link_paths.py index 6af3af2ba6..8167472af5 100644 --- a/lib/spack/spack/test/link_paths.py +++ b/lib/spack/spack/test/link_paths.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -38,6 +39,8 @@ def check_link_paths(filename, paths): assert actual == expected +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_icc16_link_paths(): check_link_paths('icc-16.0.3.txt', [ '/usr/tce/packages/intel/intel-16.0.3/compilers_and_libraries_2016.3.210/linux/compiler/lib/intel64_lin', # noqa @@ -45,6 +48,8 @@ def test_icc16_link_paths(): '/usr/tce/packages/gcc/gcc-4.9.3/lib64']) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_pgi_link_paths(): check_link_paths('pgcc-16.3.txt', [ '/usr/tce/packages/pgi/pgi-16.3/linux86-64/16.3/lib']) @@ -58,6 +63,8 @@ def test_clang4_link_paths(): check_link_paths('clang-4.0.1.txt', []) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_xl_link_paths(): check_link_paths('xl-13.1.5.txt', [ '/opt/ibm/xlsmp/4.1.5/lib', @@ -65,6 +72,8 @@ def test_xl_link_paths(): '/opt/ibm/xlC/13.1.5/lib']) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_cce_link_paths(): check_link_paths('cce-8.6.5.txt', [ '/opt/gcc/6.1.0/snos/lib64', @@ -85,11 +94,15 @@ def test_cce_link_paths(): '/opt/cray/pe/cce/8.6.5/binutils/x86_64/x86_64-unknown-linux-gnu/lib']) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_clang_apple_ld_link_paths(): check_link_paths('clang-9.0.0-apple-ld.txt', [ '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib']) # noqa +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_nag_mixed_gcc_gnu_ld_link_paths(): # This is a test of a mixed NAG/GCC toolchain, i.e. 'cxx' is set to g++ and # is used for the rpath detection. The reference compiler output is a @@ -101,6 +114,8 @@ def test_nag_mixed_gcc_gnu_ld_link_paths(): '/scratch/local1/spack/opt/spack/gcc-6.3.0-haswell/gcc-6.5.0-4sdjgrs/lib']) # noqa +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_nag_link_paths(): # This is a test of a NAG-only toolchain, i.e. 'cc' and 'cxx' are empty, # and therefore 'fc' is used for the rpath detection). The reference @@ -112,6 +127,8 @@ def test_nag_link_paths(): '/scratch/local1/spack/opt/spack/gcc-6.3.0-haswell/gcc-6.5.0-4sdjgrs/lib']) # noqa +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_obscure_parsing_rules(): check_link_paths('obscure-parsing-rules.txt', [ '/first/path', diff --git a/lib/spack/spack/test/llnl/util/file_list.py b/lib/spack/spack/test/llnl/util/file_list.py index a7cb1f0b43..f121f91ccf 100644 --- a/lib/spack/spack/test/llnl/util/file_list.py +++ b/lib/spack/spack/test/llnl/util/file_list.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import fnmatch -import os +import posixpath import pytest import six @@ -198,7 +198,7 @@ def test_add(self, header_list): #: Directory where the data for the test below is stored -search_dir = os.path.join(spack.paths.test_path, 'data', 'directory_search') +search_dir = posixpath.join(spack.paths.test_path, 'data', 'directory_search') @pytest.mark.parametrize('search_fn,search_list,root,kwargs', [ @@ -229,12 +229,12 @@ def test_add(self, header_list): (find_headers, ['a', 'c'], search_dir, {'recursive': True}), (find_libraries, ['liba', 'libd'], - os.path.join(search_dir, 'b'), + posixpath.join(search_dir, 'b'), {'recursive': False} ), (find_headers, ['b', 'd'], - os.path.join(search_dir, 'b'), + posixpath.join(search_dir, 'b'), {'recursive': False} ), ]) @@ -270,14 +270,14 @@ def test_searching_order(search_fn, search_list, root, kwargs): @pytest.mark.parametrize('root,search_list,kwargs,expected', [ (search_dir, '*/*bar.tx?', {'recursive': False}, [ - os.path.join(search_dir, 'a/foobar.txt'), - os.path.join(search_dir, 'b/bar.txp'), - os.path.join(search_dir, 'c/bar.txt'), + posixpath.join(search_dir, posixpath.join('a', 'foobar.txt')), + posixpath.join(search_dir, posixpath.join('b', 'bar.txp')), + posixpath.join(search_dir, posixpath.join('c', 'bar.txt')), ]), (search_dir, '*/*bar.tx?', {'recursive': True}, [ - os.path.join(search_dir, 'a/foobar.txt'), - os.path.join(search_dir, 'b/bar.txp'), - os.path.join(search_dir, 'c/bar.txt'), + posixpath.join(search_dir, posixpath.join('a', 'foobar.txt')), + posixpath.join(search_dir, posixpath.join('b', 'bar.txp')), + posixpath.join(search_dir, posixpath.join('c', 'bar.txt')), ]) ]) def test_find_with_globbing(root, search_list, kwargs, expected): diff --git a/lib/spack/spack/test/llnl/util/filesystem.py b/lib/spack/spack/test/llnl/util/filesystem.py index eb1df192b8..aad95a1183 100644 --- a/lib/spack/spack/test/llnl/util/filesystem.py +++ b/lib/spack/spack/test/llnl/util/filesystem.py @@ -149,6 +149,7 @@ def test_multiple_src_file_dest(self, stage): fs.install('source/a/*/*', 'dest/1') +@pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") class TestCopyTree: """Tests for ``filesystem.copy_tree``""" @@ -237,6 +238,7 @@ def test_parent_dir(self, stage): fs.copy_tree('source', 'source/sub/directory') +@pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") class TestInstallTree: """Tests for ``filesystem.install_tree``""" @@ -365,6 +367,12 @@ def test_recursive_search_of_headers_from_prefix( prefix = str(installation_dir_with_headers) header_list = fs.find_all_headers(prefix) + include_dirs = header_list.directories + + if sys.platform == "win32": + header_list = [header.replace("/", "\\") for header in header_list] + include_dirs = [dir.replace("/", "\\") for dir in include_dirs] + # Check that the header files we expect are all listed assert os.path.join(prefix, 'include', 'ex3.h') in header_list assert os.path.join(prefix, 'include', 'boost', 'ex3.h') in header_list @@ -372,20 +380,32 @@ def test_recursive_search_of_headers_from_prefix( assert os.path.join(prefix, 'path', 'to', 'subdir', 'ex2.h') in header_list # Check that when computing directories we exclude /include/boost - include_dirs = header_list.directories assert os.path.join(prefix, 'include') in include_dirs assert os.path.join(prefix, 'include', 'boost') not in include_dirs assert os.path.join(prefix, 'path', 'to') in include_dirs assert os.path.join(prefix, 'path', 'to', 'subdir') in include_dirs -@pytest.mark.parametrize('list_of_headers,expected_directories', [ - (['/pfx/include/foo.h', '/pfx/include/subdir/foo.h'], ['/pfx/include']), - (['/pfx/include/foo.h', '/pfx/subdir/foo.h'], - ['/pfx/include', '/pfx/subdir']), - (['/pfx/include/subdir/foo.h', '/pfx/subdir/foo.h'], - ['/pfx/include', '/pfx/subdir']) -]) +if sys.platform == "win32": + # TODO: Test \\s + dir_list = [ + (['C:/pfx/include/foo.h', 'C:/pfx/include/subdir/foo.h'], ['C:/pfx/include']), + (['C:/pfx/include/foo.h', 'C:/pfx/subdir/foo.h'], + ['C:/pfx/include', 'C:/pfx/subdir']), + (['C:/pfx/include/subdir/foo.h', 'C:/pfx/subdir/foo.h'], + ['C:/pfx/include', 'C:/pfx/subdir']) + ] +else: + dir_list = [ + (['/pfx/include/foo.h', '/pfx/include/subdir/foo.h'], ['/pfx/include']), + (['/pfx/include/foo.h', '/pfx/subdir/foo.h'], + ['/pfx/include', '/pfx/subdir']), + (['/pfx/include/subdir/foo.h', '/pfx/subdir/foo.h'], + ['/pfx/include', '/pfx/subdir']) + ] + + +@pytest.mark.parametrize('list_of_headers,expected_directories', dir_list) def test_computation_of_header_directories( list_of_headers, expected_directories ): @@ -394,23 +414,32 @@ def test_computation_of_header_directories( def test_headers_directory_setter(): + if sys.platform == "win32": + # TODO: Test with \\'s + root = "C:/pfx/include/subdir" + else: + root = "/pfx/include/subdir" hl = fs.HeaderList( - ['/pfx/include/subdir/foo.h', '/pfx/include/subdir/bar.h'] + [root + '/foo.h', root + '/bar.h'] ) # Set directories using a list - hl.directories = ['/pfx/include/subdir'] - assert hl.directories == ['/pfx/include/subdir'] + hl.directories = [root] + assert hl.directories == [root] # If it's a single directory it's fine to not wrap it into a list # when setting the property - hl.directories = '/pfx/include/subdir' - assert hl.directories == ['/pfx/include/subdir'] + hl.directories = root + assert hl.directories == [root] # Paths are normalized, so it doesn't matter how many backslashes etc. # are present in the original directory being used - hl.directories = '/pfx/include//subdir/' - assert hl.directories == ['/pfx/include/subdir'] + if sys.platform == "win32": + # TODO: Test with \\'s + hl.directories = "C:/pfx/include//subdir" + else: + hl.directories = '/pfx/include//subdir/' + assert hl.directories == [root] # Setting an empty list is allowed and returns an empty list hl.directories = [] @@ -421,26 +450,53 @@ def test_headers_directory_setter(): assert hl.directories == [] -@pytest.mark.parametrize('path,entry,expected', [ - ('/tmp/user/root', None, - (['/tmp', '/tmp/user', '/tmp/user/root'], '', [])), - ('/tmp/user/root', 'tmp', ([], '/tmp', ['/tmp/user', '/tmp/user/root'])), - ('/tmp/user/root', 'user', (['/tmp'], '/tmp/user', ['/tmp/user/root'])), - ('/tmp/user/root', 'root', (['/tmp', '/tmp/user'], '/tmp/user/root', [])), - ('relative/path', None, (['relative', 'relative/path'], '', [])), - ('relative/path', 'relative', ([], 'relative', ['relative/path'])), - ('relative/path', 'path', (['relative'], 'relative/path', [])) -]) +if sys.platform == "win32": + # TODO: Test \\s + paths = [ + ('C:/user/root', None, + (['C:/', 'C:/user', 'C:/user/root'], '', [])), + ('C:/user/root', 'C:/', ([], 'C:/', ['C:/user', 'C:/user/root'])), + ('C:/user/root', 'user', (['C:/'], 'C:/user', ['C:/user/root'])), + ('C:/user/root', 'root', (['C:/', 'C:/user'], 'C:/user/root', [])), + ('relative/path', None, (['relative', 'relative/path'], '', [])), + ('relative/path', 'relative', ([], 'relative', ['relative/path'])), + ('relative/path', 'path', (['relative'], 'relative/path', [])) + ] +else: + paths = [ + ('/tmp/user/root', None, + (['/tmp', '/tmp/user', '/tmp/user/root'], '', [])), + ('/tmp/user/root', 'tmp', ([], '/tmp', ['/tmp/user', '/tmp/user/root'])), + ('/tmp/user/root', 'user', (['/tmp'], '/tmp/user', ['/tmp/user/root'])), + ('/tmp/user/root', 'root', (['/tmp', '/tmp/user'], '/tmp/user/root', [])), + ('relative/path', None, (['relative', 'relative/path'], '', [])), + ('relative/path', 'relative', ([], 'relative', ['relative/path'])), + ('relative/path', 'path', (['relative'], 'relative/path', [])) + ] + + +@pytest.mark.parametrize('path,entry,expected', paths) def test_partition_path(path, entry, expected): assert fs.partition_path(path, entry) == expected -@pytest.mark.parametrize('path,expected', [ - ('', []), - ('/tmp/user/dir', ['/tmp', '/tmp/user', '/tmp/user/dir']), - ('./some/sub/dir', ['./some', './some/sub', './some/sub/dir']), - ('another/sub/dir', ['another', 'another/sub', 'another/sub/dir']) -]) +if sys.platform == "win32": + path_list = [ + ('', []), + ('C:\\user\\dir', ['C:/', 'C:/user', 'C:/user/dir']), + ('./some/sub/dir', ['./some', './some/sub', './some/sub/dir']), + ('another/sub/dir', ['another', 'another/sub', 'another/sub/dir']) + ] +else: + path_list = [ + ('', []), + ('/tmp/user/dir', ['/tmp', '/tmp/user', '/tmp/user/dir']), + ('./some/sub/dir', ['./some', './some/sub', './some/sub/dir']), + ('another/sub/dir', ['another', 'another/sub', 'another/sub/dir']) + ] + + +@pytest.mark.parametrize('path,expected', path_list) def test_prefixes(path, expected): assert fs.prefixes(path) == expected diff --git a/lib/spack/spack/test/llnl/util/link_tree.py b/lib/spack/spack/test/llnl/util/link_tree.py index 0b5bfb3b0c..e62cc06503 100644 --- a/lib/spack/spack/test/llnl/util/link_tree.py +++ b/lib/spack/spack/test/llnl/util/link_tree.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -52,6 +53,8 @@ def check_dir(filename): assert os.path.isdir(filename) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_merge_to_new_directory(stage, link_tree): with working_dir(stage.path): link_tree.merge('dest') @@ -77,6 +80,8 @@ def test_merge_to_new_directory(stage, link_tree): assert not os.path.exists('dest') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_merge_to_new_directory_relative(stage, link_tree): with working_dir(stage.path): link_tree.merge('dest', relative=True) @@ -102,6 +107,8 @@ def test_merge_to_new_directory_relative(stage, link_tree): assert not os.path.exists('dest') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_merge_to_existing_directory(stage, link_tree): with working_dir(stage.path): @@ -135,6 +142,8 @@ def test_merge_to_existing_directory(stage, link_tree): assert not os.path.isfile('dest/c/d/e/7') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_merge_with_empty_directories(stage, link_tree): with working_dir(stage.path): mkdirp('dest/f/g') @@ -155,6 +164,8 @@ def test_merge_with_empty_directories(stage, link_tree): assert os.path.isdir('dest/f/g') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_ignore(stage, link_tree): with working_dir(stage.path): touchp('source/.spec') diff --git a/lib/spack/spack/test/llnl/util/lock.py b/lib/spack/spack/test/llnl/util/lock.py index a2c54e3968..b2e3695454 100644 --- a/lib/spack/spack/test/llnl/util/lock.py +++ b/lib/spack/spack/test/llnl/util/lock.py @@ -44,16 +44,17 @@ """ import collections import errno -import fcntl import getpass import glob import os import shutil import socket +import stat import tempfile import traceback from contextlib import contextmanager from multiprocessing import Process, Queue +from sys import platform as _platform import pytest @@ -61,6 +62,17 @@ import llnl.util.multiproc as mp from llnl.util.filesystem import getuid, touch +if _platform == "win32": + import pywintypes + import win32con + import win32file + LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK + LOCK_SH = 0 + LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY + __overlapped = pywintypes.OVERLAPPED() +else: + import fcntl + # # This test can be run with MPI. MPI is "enabled" if we can import # mpi4py and the number of total MPI processes is greater than 1. @@ -112,14 +124,25 @@ def make_readable(*paths): + # TODO: From os.chmod doc: + # "Note Although Windows supports chmod(), you can only + # set the file's read-only flag with it (via the stat.S_IWRITE and + # stat.S_IREAD constants or a corresponding integer value). All other + # bits are ignored." for path in paths: - mode = 0o555 if os.path.isdir(path) else 0o444 + if (_platform != 'win32'): + mode = 0o555 if os.path.isdir(path) else 0o444 + else: + mode = stat.S_IREAD os.chmod(path, mode) def make_writable(*paths): for path in paths: - mode = 0o755 if os.path.isdir(path) else 0o744 + if (_platform != 'win32'): + mode = 0o755 if os.path.isdir(path) else 0o744 + else: + mode = stat.S_IWRITE os.chmod(path, mode) @@ -377,6 +400,8 @@ def test_write_lock_timeout_on_write_ranges(lock_path): TimeoutWrite(lock_path, 0, 1)) +@pytest.mark.skipif(_platform == 'win32', + reason='locking ranges not supported on windows') def test_write_lock_timeout_on_write_ranges_2(lock_path): multiproc_test( AcquireWrite(lock_path, 0, 64), @@ -385,6 +410,8 @@ def test_write_lock_timeout_on_write_ranges_2(lock_path): TimeoutWrite(lock_path, 63, 1)) +@pytest.mark.skipif(_platform == 'win32', + reason='locking ranges not supported on windows') def test_write_lock_timeout_on_write_ranges_3(lock_path): multiproc_test( AcquireWrite(lock_path, 0, 1), @@ -394,6 +421,8 @@ def test_write_lock_timeout_on_write_ranges_3(lock_path): TimeoutWrite(lock_path)) +@pytest.mark.skipif(_platform == 'win32', + reason='locking ranges not supported on windows') def test_write_lock_timeout_on_write_ranges_4(lock_path): multiproc_test( AcquireWrite(lock_path, 0, 1), @@ -444,6 +473,8 @@ def test_read_lock_timeout_on_write_ranges_2(lock_path): TimeoutRead(lock_path, 0, 1)) +@pytest.mark.skipif(_platform == 'win32', + reason='locking ranges not supported on windows') def test_read_lock_timeout_on_write_ranges_3(lock_path): """two write locks, overlapping read locks""" multiproc_test( @@ -489,6 +520,8 @@ def test_write_lock_timeout_on_read_ranges_2(lock_path): TimeoutWrite(lock_path, 0, 1)) +@pytest.mark.skipif(_platform == 'win32', + reason='locking ranges not supported on windows') def test_write_lock_timeout_on_read_ranges_3(lock_path): multiproc_test( AcquireRead(lock_path, 0, 1), @@ -547,6 +580,8 @@ def test_write_lock_timeout_with_multiple_readers_3_2(lock_path): TimeoutWrite(lock_path)) +@pytest.mark.skipif(_platform == 'win32', + reason='locking ranges not supported on windows') def test_write_lock_timeout_with_multiple_readers_2_1_ranges(lock_path): multiproc_test( AcquireRead(lock_path, 0, 10), @@ -554,6 +589,8 @@ def test_write_lock_timeout_with_multiple_readers_2_1_ranges(lock_path): TimeoutWrite(lock_path, 5, 5)) +@pytest.mark.skipif(_platform == 'win32', + reason='locking ranges not supported on windows') def test_write_lock_timeout_with_multiple_readers_2_3_ranges(lock_path): multiproc_test( AcquireRead(lock_path, 0, 10), @@ -608,7 +645,7 @@ def test_read_lock_read_only_dir_writable_lockfile(lock_dir, lock_path): pass -@pytest.mark.skipif(os.getuid() == 0, reason='user is root') +@pytest.mark.skipif(_platform == 'win32' or getuid() == 0, reason='user is root') def test_read_lock_no_lockfile(lock_dir, lock_path): """read-only directory, no lockfile (so can't create).""" with read_only(lock_dir): @@ -623,6 +660,8 @@ def test_read_lock_no_lockfile(lock_dir, lock_path): pass +@pytest.mark.skipif(_platform == 'win32', + reason='not supported on windows') def test_upgrade_read_to_write(private_lock_path): """Test that a read lock can be upgraded to a write lock. @@ -670,15 +709,18 @@ def test_upgrade_read_to_write_fails_with_readonly_file(private_lock_path): lock = lk.Lock(private_lock_path) assert lock._reads == 0 assert lock._writes == 0 + assert lock._current_lock is None lock.acquire_read() assert lock._reads == 1 assert lock._writes == 0 assert lock._file.mode == 'r' + assert lock._current_lock == lock.LOCK_SH - # upgrade to writ here + # upgrade to write here with pytest.raises(lk.LockROFileError): lock.acquire_write() + lk.file_tracker.release_fh(lock.path) class ComplexAcquireAndRelease(object): @@ -1254,6 +1296,8 @@ def p2(self, barrier, q1, q2): barrier.wait() # ---------------------------------------- 4 +@pytest.mark.skipif(_platform == 'win32', + reason='debug output not supported on windows') def test_lock_debug_output(lock_path): test_debug = LockDebugOutput(lock_path) q1, q2 = Queue(), Queue() @@ -1326,6 +1370,8 @@ def test_downgrade_write_fails(tmpdir): [(errno.EACCES, "Fake EACCES error"), (errno.EAGAIN, "Fake EAGAIN error"), (errno.ENOENT, "Fake ENOENT error")]) +@pytest.mark.skipif(_platform == 'win32', + reason='not supported on windows') def test_poll_lock_exception(tmpdir, monkeypatch, err_num, err_msg): """Test poll lock exception handling.""" def _lockf(fd, cmd, len, start, whence): @@ -1336,14 +1382,23 @@ def _lockf(fd, cmd, len, start, whence): lock = lk.Lock(lockfile) touch(lockfile) + if _platform == 'win32': + monkeypatch.setattr(win32file, 'LockFileEx', _lockf) - monkeypatch.setattr(fcntl, 'lockf', _lockf) + if err_num in [errno.EAGAIN, errno.EACCES]: + assert not lock._poll_lock(win32con.LOCKFILE_EXCLUSIVE_LOCK) + else: + with pytest.raises(IOError, match=err_msg): + lock._poll_lock(win32con.LOCKFILE_EXCLUSIVE_LOCK) - if err_num in [errno.EAGAIN, errno.EACCES]: - assert not lock._poll_lock(fcntl.LOCK_EX) else: - with pytest.raises(IOError, match=err_msg): - lock._poll_lock(fcntl.LOCK_EX) + monkeypatch.setattr(fcntl, 'lockf', _lockf) + + if err_num in [errno.EAGAIN, errno.EACCES]: + assert not lock._poll_lock(fcntl.LOCK_EX) + else: + with pytest.raises(IOError, match=err_msg): + lock._poll_lock(fcntl.LOCK_EX) def test_upgrade_read_okay(tmpdir): diff --git a/lib/spack/spack/test/llnl/util/tty/log.py b/lib/spack/spack/test/llnl/util/tty/log.py index 8d44c1f577..bd6c0ebcfe 100644 --- a/lib/spack/spack/test/llnl/util/tty/log.py +++ b/lib/spack/spack/test/llnl/util/tty/log.py @@ -32,6 +32,12 @@ pass +@contextlib.contextmanager +def nullcontext(): + yield + + +@pytest.mark.skipif(sys.platform == 'win32', reason="echo not implemented on windows") def test_log_python_output_with_echo(capfd, tmpdir): with tmpdir.as_cwd(): with log.log_output('foo.txt', echo=True): @@ -45,6 +51,7 @@ def test_log_python_output_with_echo(capfd, tmpdir): assert capfd.readouterr()[0] == 'logged\n' +@pytest.mark.skipif(sys.platform == 'win32', reason="echo not implemented on windows") def test_log_python_output_without_echo(capfd, tmpdir): with tmpdir.as_cwd(): with log.log_output('foo.txt'): @@ -58,6 +65,7 @@ def test_log_python_output_without_echo(capfd, tmpdir): assert capfd.readouterr()[0] == '' +@pytest.mark.skipif(sys.platform == 'win32', reason="echo not implemented on windows") def test_log_python_output_with_invalid_utf8(capfd, tmpdir): with tmpdir.as_cwd(): with log.log_output('foo.txt'): @@ -76,6 +84,7 @@ def test_log_python_output_with_invalid_utf8(capfd, tmpdir): assert capfd.readouterr()[0] == '' +@pytest.mark.skipif(sys.platform == 'win32', reason="echo not implemented on windows") def test_log_python_output_and_echo_output(capfd, tmpdir): with tmpdir.as_cwd(): # echo two lines @@ -96,6 +105,8 @@ def _log_filter_fn(string): return string.replace("foo", "bar") +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_log_output_with_filter(capfd, tmpdir): with tmpdir.as_cwd(): with log.log_output('foo.txt', filter_fn=_log_filter_fn): @@ -125,7 +136,7 @@ def test_log_output_with_filter(capfd, tmpdir): assert capfd.readouterr()[0] == 'bar blah\nblah bar\nbar bar\n' -@pytest.mark.skipif(not which('echo'), reason="needs echo command") +@pytest.mark.skipif(not which('echo') or os.name == 'nt', reason="needs echo command") def test_log_subproc_and_echo_output_no_capfd(capfd, tmpdir): echo = which('echo') @@ -143,7 +154,7 @@ def test_log_subproc_and_echo_output_no_capfd(capfd, tmpdir): assert f.read() == 'echo\nlogged\n' -@pytest.mark.skipif(not which('echo'), reason="needs echo command") +@pytest.mark.skipif(not which('echo') or os.name == 'nt', reason="needs echo command") def test_log_subproc_and_echo_output_capfd(capfd, tmpdir): echo = which('echo') diff --git a/lib/spack/spack/test/main.py b/lib/spack/spack/test/main.py index 1a7a069e15..225d862759 100644 --- a/lib/spack/spack/test/main.py +++ b/lib/spack/spack/test/main.py @@ -4,6 +4,9 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys + +import pytest import llnl.util.filesystem as fs @@ -23,6 +26,8 @@ def test_get_version_no_match_git(tmpdir, working_env): assert spack.spack_version == get_version() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_get_version_match_git(tmpdir, working_env): git = str(tmpdir.join("git")) with open(git, "w") as f: diff --git a/lib/spack/spack/test/make_executable.py b/lib/spack/spack/test/make_executable.py index 4b40574ab0..84f0374bcc 100644 --- a/lib/spack/spack/test/make_executable.py +++ b/lib/spack/spack/test/make_executable.py @@ -10,13 +10,18 @@ """ import os import shutil +import sys import tempfile import unittest +import pytest + from spack.build_environment import MakeExecutable from spack.util.environment import path_put_first +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") class MakeExecutableTest(unittest.TestCase): def setUp(self): diff --git a/lib/spack/spack/test/mirror.py b/lib/spack/spack/test/mirror.py index d8684d13b9..7d03161c02 100644 --- a/lib/spack/spack/test/mirror.py +++ b/lib/spack/spack/test/mirror.py @@ -5,6 +5,7 @@ import filecmp import os +import sys import pytest @@ -103,12 +104,16 @@ def check_mirror(): assert all(left in exclude for left in dcmp.left_only) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_url_mirror(mock_archive): set_up_package('trivial-install-test-package', mock_archive, 'url') check_mirror() repos.clear() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.skipif( not which('git'), reason='requires git to be installed') def test_git_mirror(mock_git_repository): @@ -117,6 +122,8 @@ def test_git_mirror(mock_git_repository): repos.clear() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.skipif( not which('svn') or not which('svnadmin'), reason='requires subversion to be installed') @@ -126,6 +133,8 @@ def test_svn_mirror(mock_svn_repository): repos.clear() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.skipif( not which('hg'), reason='requires mercurial to be installed') def test_hg_mirror(mock_hg_repository): @@ -134,6 +143,8 @@ def test_hg_mirror(mock_hg_repository): repos.clear() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.skipif( not all([which('svn'), which('hg'), which('git')]), reason='requires subversion, git, and mercurial to be installed') @@ -151,6 +162,8 @@ def test_all_mirror( repos.clear() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( "mirror", [ @@ -167,6 +180,8 @@ def test_roundtrip_mirror(mirror): assert spack.mirror.Mirror.from_json(mirror_json) == mirror +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( "invalid_yaml", [ @@ -181,6 +196,8 @@ def test_invalid_yaml_mirror(invalid_yaml): assert invalid_yaml in exc_msg +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( "invalid_json, error_message", [ @@ -195,6 +212,8 @@ def test_invalid_json_mirror(invalid_json, error_message): assert error_message in exc_msg +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( "mirror_collection", [ @@ -217,6 +236,8 @@ def test_roundtrip_mirror_collection(mirror_collection): mirror_collection) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( "invalid_yaml", [ @@ -231,6 +252,8 @@ def test_invalid_yaml_mirror_collection(invalid_yaml): assert invalid_yaml in exc_msg +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( "invalid_json, error_message", [ @@ -245,12 +268,16 @@ def test_invalid_json_mirror_collection(invalid_json, error_message): assert error_message in exc_msg +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_mirror_archive_paths_no_version(mock_packages, config, mock_archive): spec = Spec('trivial-install-test-package@nonexistingversion') fetcher = spack.fetch_strategy.URLFetchStrategy(mock_archive.url) spack.mirror.mirror_archive_paths(fetcher, 'per-package-ref', spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_mirror_with_url_patches(mock_packages, config, monkeypatch): spec = Spec('patch-several-dependencies') spec.concretize() @@ -303,6 +330,8 @@ def archive(dst): pass +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('14067') def test_mirror_cache_symlinks(tmpdir): """Confirm that the cosmetic symlink created in the mirror cache (which may diff --git a/lib/spack/spack/test/module_parsing.py b/lib/spack/spack/test/module_parsing.py index cf6508ca70..d20f6a2b95 100644 --- a/lib/spack/spack/test/module_parsing.py +++ b/lib/spack/spack/test/module_parsing.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -23,6 +24,8 @@ 'prepend-path PATH /path/to/bin'] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_module_function_change_env(tmpdir, working_env): src_file = str(tmpdir.join('src_me')) with open(src_file, 'w') as f: @@ -35,6 +38,8 @@ def test_module_function_change_env(tmpdir, working_env): assert os.environ['NOT_AFFECTED'] == "NOT_AFFECTED" +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_module_function_no_change(tmpdir): src_file = str(tmpdir.join('src_me')) with open(src_file, 'w') as f: diff --git a/lib/spack/spack/test/modules/common.py b/lib/spack/spack/test/modules/common.py index 133258e9cc..12efc8c9e2 100644 --- a/lib/spack/spack/test/modules/common.py +++ b/lib/spack/spack/test/modules/common.py @@ -78,6 +78,7 @@ def mock_package_perms(monkeypatch): yield perms +@pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_modules_written_with_proper_permissions(mock_module_filename, mock_package_perms, mock_packages, config): @@ -92,6 +93,8 @@ def test_modules_written_with_proper_permissions(mock_module_filename, mock_module_filename).st_mode == mock_package_perms +@pytest.mark.skipif(str(spack.platforms.host()) == "windows", + reason="test unsupported on Windows") @pytest.mark.parametrize('module_type', ['tcl', 'lmod']) def test_modules_default_symlink( module_type, mock_packages, mock_module_filename, mock_module_defaults, config @@ -217,6 +220,7 @@ def test_get_module_upstream(): spack.modules.common.upstream_module_index = old_index +@pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_load_installed_package_not_in_repo(install_mockery, mock_fetch, monkeypatch): # Get a basic concrete spec for the trivial install package. diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py index a29d8ac2ac..e82c9b8b9d 100644 --- a/lib/spack/spack/test/modules/lmod.py +++ b/lib/spack/spack/test/modules/lmod.py @@ -2,7 +2,9 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import os import re +import sys import pytest @@ -42,6 +44,7 @@ def provider(request): @pytest.mark.usefixtures('config', 'mock_packages',) class TestLmod(object): + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_file_layout( self, compiler, provider, factory, module_configuration ): @@ -79,6 +82,7 @@ def test_file_layout( else: assert repetitions == 1 + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_simple_case(self, modulefile_content, module_configuration): """Tests the generation of a simple TCL module file.""" @@ -90,6 +94,7 @@ def test_simple_case(self, modulefile_content, module_configuration): assert 'whatis([[Version : 3.0.4]])' in content assert 'family("mpi")' in content + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_autoload_direct(self, modulefile_content, module_configuration): """Tests the automatic loading of direct dependencies.""" @@ -98,6 +103,7 @@ def test_autoload_direct(self, modulefile_content, module_configuration): assert len([x for x in content if 'depends_on(' in x]) == 2 + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_autoload_all(self, modulefile_content, module_configuration): """Tests the automatic loading of all dependencies.""" @@ -106,6 +112,7 @@ def test_autoload_all(self, modulefile_content, module_configuration): assert len([x for x in content if 'depends_on(' in x]) == 5 + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_alter_environment(self, modulefile_content, module_configuration): """Tests modifications to run-time environment.""" @@ -128,6 +135,7 @@ def test_alter_environment(self, modulefile_content, module_configuration): assert len([x for x in content if 'setenv("FOO", "foo")' in x]) == 0 assert len([x for x in content if 'unsetenv("BAR")' in x]) == 0 + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_prepend_path_separator(self, modulefile_content, module_configuration): """Tests modifications to run-time environment.""" @@ -141,6 +149,7 @@ def test_prepend_path_separator(self, modulefile_content, elif re.match(r'[a-z]+_path\("SEMICOLON"', line): assert line.endswith('"bar", ";")') + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_blacklist(self, modulefile_content, module_configuration): """Tests blacklisting the generation of selected modules.""" @@ -149,6 +158,7 @@ def test_blacklist(self, modulefile_content, module_configuration): assert len([x for x in content if 'depends_on(' in x]) == 1 + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_no_hash(self, factory, module_configuration): """Makes sure that virtual providers (in the hierarchy) always include a hash. Make sure that the module file for the spec @@ -173,6 +183,7 @@ def test_no_hash(self, factory, module_configuration): assert path.endswith(mpileaks_element) + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_no_core_compilers(self, factory, module_configuration): """Ensures that missing 'core_compilers' in the configuration file raises the right exception. @@ -192,6 +203,7 @@ def test_no_core_compilers(self, factory, module_configuration): with pytest.raises(spack.modules.lmod.CoreCompilersNotFoundError): module.write() + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_non_virtual_in_hierarchy(self, factory, module_configuration): """Ensures that if a non-virtual is in hierarchy, an exception will be raised. @@ -202,6 +214,7 @@ def test_non_virtual_in_hierarchy(self, factory, module_configuration): with pytest.raises(spack.modules.lmod.NonVirtualInHierarchyError): module.write() + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_override_template_in_package( self, modulefile_content, module_configuration ): @@ -212,6 +225,7 @@ def test_override_template_in_package( assert 'Override successful!' in content + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_override_template_in_modules_yaml( self, modulefile_content, module_configuration ): @@ -224,6 +238,7 @@ def test_override_template_in_modules_yaml( content = modulefile_content('mpileaks target=x86_64') assert 'Override even better!' in content + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.usefixtures('config') def test_external_configure_args( self, factory @@ -234,6 +249,7 @@ def test_external_configure_args( assert 'unknown' in writer.context.configure_options + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_guess_core_compilers( self, factory, module_configuration, monkeypatch ): @@ -257,6 +273,7 @@ def no_op_set(*args, **kwargs): writer, _ = factory(mpileaks_spec_string) assert writer.conf.core_compilers + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.parametrize('spec_str', [ 'mpileaks target=nocona', 'mpileaks target=core2', @@ -273,6 +290,7 @@ def test_only_generic_microarchitectures_in_root( if spec.target.family != spec.target: assert str(spec.target) not in writer.layout.arch_dirname + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_projections_specific(self, factory, module_configuration): """Tests reading the correct naming scheme.""" @@ -291,6 +309,7 @@ def test_projections_specific(self, factory, module_configuration): projection = writer.spec.format(writer.conf.projections['mpileaks']) assert projection in writer.layout.use_name + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_projections_all(self, factory, module_configuration): """Tests reading the correct naming scheme.""" @@ -309,6 +328,7 @@ def test_projections_all(self, factory, module_configuration): projection = writer.spec.format(writer.conf.projections['all']) assert projection in writer.layout.use_name + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_config_backwards_compat(self, mutable_config): settings = { 'enable': ['lmod'], @@ -326,6 +346,7 @@ def test_config_backwards_compat(self, mutable_config): assert old_format == new_format assert old_format == settings['lmod'] + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_modules_relative_to_view( self, tmpdir, modulefile_content, module_configuration, install_mockery, mock_fetch diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py index 7f94dabc60..db8b7e1335 100644 --- a/lib/spack/spack/test/modules/tcl.py +++ b/lib/spack/spack/test/modules/tcl.py @@ -3,6 +3,9 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import os +import sys + import pytest import spack.modules.common @@ -20,6 +23,7 @@ @pytest.mark.usefixtures('config', 'mock_packages') class TestTcl(object): + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_simple_case(self, modulefile_content, module_configuration): """Tests the generation of a simple TCL module file.""" @@ -28,6 +32,7 @@ def test_simple_case(self, modulefile_content, module_configuration): assert 'module-whatis "mpich @3.0.4"' in content + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_autoload_direct(self, modulefile_content, module_configuration): """Tests the automatic loading of direct dependencies.""" @@ -51,6 +56,7 @@ def test_autoload_direct(self, modulefile_content, module_configuration): messages = [x for x in content if 'puts stderr "Autoloading' in x] assert len(messages) == 0 + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_autoload_all(self, modulefile_content, module_configuration): """Tests the automatic loading of all dependencies.""" @@ -74,6 +80,7 @@ def test_autoload_all(self, modulefile_content, module_configuration): messages = [x for x in content if 'puts stderr "Autoloading' in x] assert len(messages) == 2 + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_prerequisites_direct( self, modulefile_content, module_configuration ): @@ -84,6 +91,7 @@ def test_prerequisites_direct( assert len([x for x in content if 'prereq' in x]) == 2 + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_prerequisites_all(self, modulefile_content, module_configuration): """Tests asking all dependencies as prerequisites.""" @@ -92,6 +100,7 @@ def test_prerequisites_all(self, modulefile_content, module_configuration): assert len([x for x in content if 'prereq' in x]) == 5 + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") def test_alter_environment(self, modulefile_content, module_configuration): """Tests modifications to run-time environment.""" @@ -124,6 +133,7 @@ def test_alter_environment(self, modulefile_content, module_configuration): assert len([x for x in content if 'module load foo/bar' in x]) == 1 assert len([x for x in content if 'setenv LIBDWARF_ROOT' in x]) == 1 + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_blacklist(self, modulefile_content, module_configuration): """Tests blacklisting the generation of selected modules.""" @@ -144,6 +154,7 @@ def test_blacklist(self, modulefile_content, module_configuration): assert len([x for x in content if 'is-loaded' in x]) == 1 assert len([x for x in content if 'module load ' in x]) == 1 + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_naming_scheme_compat(self, factory, module_configuration): """Tests backwards compatibility for naming_scheme key""" module_configuration('naming_scheme') @@ -158,6 +169,7 @@ def test_naming_scheme_compat(self, factory, module_configuration): projection = writer.spec.format(writer.conf.projections['all']) assert projection in writer.layout.use_name + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_projections_specific(self, factory, module_configuration): """Tests reading the correct naming scheme.""" @@ -176,6 +188,7 @@ def test_projections_specific(self, factory, module_configuration): projection = writer.spec.format(writer.conf.projections['mpileaks']) assert projection in writer.layout.use_name + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_projections_all(self, factory, module_configuration): """Tests reading the correct naming scheme.""" @@ -194,6 +207,7 @@ def test_projections_all(self, factory, module_configuration): projection = writer.spec.format(writer.conf.projections['all']) assert projection in writer.layout.use_name + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_invalid_naming_scheme(self, factory, module_configuration): """Tests the evaluation of an invalid naming scheme.""" @@ -205,6 +219,7 @@ def test_invalid_naming_scheme(self, factory, module_configuration): with pytest.raises(RuntimeError): writer.layout.use_name + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_invalid_token_in_env_name(self, factory, module_configuration): """Tests setting environment variables with an invalid name.""" @@ -214,6 +229,7 @@ def test_invalid_token_in_env_name(self, factory, module_configuration): with pytest.raises(RuntimeError): writer.write() + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_conflicts(self, modulefile_content, module_configuration): """Tests adding conflicts to the module.""" @@ -231,6 +247,7 @@ def test_conflicts(self, modulefile_content, module_configuration): with pytest.raises(SystemExit): modulefile_content('mpileaks') + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_module_index( self, module_configuration, factory, tmpdir_factory): @@ -265,6 +282,7 @@ def test_module_index( assert len(index) == 1 assert index[s3.dag_hash()].use_name == w3.layout.use_name + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_suffixes(self, module_configuration, factory): """Tests adding suffixes to module file name.""" module_configuration('suffix') @@ -280,6 +298,7 @@ def test_suffixes(self, module_configuration, factory): writer, spec = factory('mpileaks~debug+opt target=x86_64') assert 'baz-foo-bar' in writer.layout.use_name + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_setup_environment(self, modulefile_content, module_configuration): """Tests the internal set-up of run-time environment.""" @@ -300,6 +319,7 @@ def test_setup_environment(self, modulefile_content, module_configuration): [x for x in content if 'setenv FOOBAR "callpath"' in x] ) == 1 + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_override_config(self, module_configuration, factory): """Tests overriding some sections of the configuration file.""" module_configuration('override_config') @@ -314,6 +334,7 @@ def test_override_config(self, module_configuration, factory): assert 'mpich' not in writer.layout.use_name assert 'static' not in writer.layout.use_name + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_override_template_in_package( self, modulefile_content, module_configuration ): @@ -324,6 +345,7 @@ def test_override_template_in_package( assert 'Override successful!' in content + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_override_template_in_modules_yaml( self, modulefile_content, module_configuration ): @@ -336,6 +358,7 @@ def test_override_template_in_modules_yaml( content = modulefile_content('mpileaks target=x86_64') assert 'Override even better!' in content + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_extend_context( self, modulefile_content, module_configuration ): @@ -348,6 +371,7 @@ def test_extend_context( short_description = 'module-whatis "This package updates the context for TCL modulefiles."' # NOQA: ignore=E501 assert short_description in content + @pytest.mark.skipif(os.name == 'nt', reason="Skip test on Windows") @pytest.mark.regression('4400') @pytest.mark.db def test_blacklist_implicits( @@ -369,6 +393,7 @@ def test_blacklist_implicits( writer = writer_cls(item, 'default') assert writer.conf.blacklisted + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") @pytest.mark.regression('9624') @pytest.mark.db def test_autoload_with_constraints( @@ -386,6 +411,7 @@ def test_autoload_with_constraints( content = modulefile_content('mpileaks ^mpich') assert len([x for x in content if 'is-loaded' in x]) == 0 + @pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_config_backwards_compat(self, mutable_config): settings = { 'enable': ['tcl'], diff --git a/lib/spack/spack/test/monitor.py b/lib/spack/spack/test/monitor.py index d51341cac0..7ea7a0ddac 100644 --- a/lib/spack/spack/test/monitor.py +++ b/lib/spack/spack/test/monitor.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -135,6 +136,8 @@ def test_spack_monitor_without_auth(mock_monitor_request): get_client(host="hostname") +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_spack_monitor_build_env(mock_monitor_request, install_mockery_mutable_config): monitor = get_client(host="hostname") assert hasattr(monitor, "build_environment") diff --git a/lib/spack/spack/test/optional_deps.py b/lib/spack/spack/test/optional_deps.py index 84c3f2df43..313903d272 100644 --- a/lib/spack/spack/test/optional_deps.py +++ b/lib/spack/spack/test/optional_deps.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest from spack.spec import Spec @@ -96,6 +98,8 @@ def test_normalize(spec_and_expected, config, mock_packages): assert spec.eq_dag(expected, deptypes=False) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_default_variant(config, mock_packages): spec = Spec('optional-dep-test-3') spec.concretize() diff --git a/lib/spack/spack/test/packages.py b/lib/spack/spack/test/packages.py index 05d72ab0a1..da8efce326 100644 --- a/lib/spack/spack/test/packages.py +++ b/lib/spack/spack/test/packages.py @@ -3,7 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import os.path +import posixpath +import sys import pytest @@ -28,7 +29,7 @@ def test_package_name(self): def test_package_filename(self): repo = spack.repo.Repo(mock_packages_path) filename = repo.filename_for_package_name('mpich') - assert filename == os.path.join( + assert filename == posixpath.join( mock_packages_path, 'packages', 'mpich', @@ -38,7 +39,7 @@ def test_package_filename(self): def test_nonexisting_package_filename(self): repo = spack.repo.Repo(mock_packages_path) filename = repo.filename_for_package_name('some-nonexisting-package') - assert filename == os.path.join( + assert filename == posixpath.join( mock_packages_path, 'packages', 'some-nonexisting-package', @@ -63,6 +64,8 @@ def test_import_package_as(self): import spack.pkg.builtin.mock.mpich as mp # noqa from spack.pkg.builtin import mock # noqa + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_inheritance_of_diretives(self): p = spack.repo.get('simple-inheritance') @@ -88,12 +91,16 @@ def test_inheritance_of_diretives(self): assert '~openblas' in s assert 'mpi' in s + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('11844') def test_inheritance_of_patches(self): s = Spec('patch-inheritance') # Will error if inheritor package cannot find inherited patch files s.concretize() + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_dependency_extensions(self): s = Spec('extension2') s.concretize() @@ -118,6 +125,8 @@ def test_import_namespace_container_modules(self): from spack.pkg.builtin import mock # noqa +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('2737') def test_urls_for_versions(mock_packages, config): """Version directive without a 'url' argument should use default url.""" @@ -142,6 +151,8 @@ def test_url_for_version_with_no_urls(mock_packages, config): pkg.url_for_version('1.1') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_url_for_version_with_only_overrides(mock_packages, config): spec = Spec('url-only-override') spec.concretize() @@ -160,6 +171,8 @@ def test_url_for_version_with_only_overrides(mock_packages, config): assert pkg.url_for_version('0.7.0') == 'http://c.example.com/url_override-0.7.0.tar.gz' +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_url_for_version_with_only_overrides_with_gaps(mock_packages, config): spec = Spec('url-only-override-with-gaps') spec.concretize() @@ -327,6 +340,8 @@ def test_git_url_top_level_conflicts(mock_packages, config): spack.fetch_strategy.for_package_version(pkg, '1.3') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_rpath_args(mutable_database): """Test a package's rpath_args property.""" diff --git a/lib/spack/spack/test/packaging.py b/lib/spack/spack/test/packaging.py index 9d745d09db..b23df6e30d 100644 --- a/lib/spack/spack/test/packaging.py +++ b/lib/spack/spack/test/packaging.py @@ -12,6 +12,7 @@ import re import shutil import stat +import sys import pytest @@ -47,6 +48,8 @@ def fake_fetchify(url, pkg): pkg.fetcher = fetcher +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('install_mockery', 'mock_gnupghome') def test_buildcache(mock_archive, tmpdir): # tweak patchelf to only do a download @@ -189,6 +192,8 @@ def test_buildcache(mock_archive, tmpdir): bindist._cached_specs = set() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('install_mockery') def test_relocate_text(tmpdir): spec = Spec('trivial-install-test-package') @@ -212,6 +217,8 @@ def test_relocate_text(tmpdir): bindist._cached_specs = set() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_relocate_links(tmpdir): with tmpdir.as_cwd(): old_layout_root = os.path.join( @@ -253,6 +260,8 @@ def test_needs_relocation(): assert needs_binary_relocation('application', 'x-mach-binary') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_replace_paths(tmpdir): with tmpdir.as_cwd(): suffix = 'dylib' if platform.system().lower() == 'darwin' else 'so' @@ -462,6 +471,8 @@ def test_replace_paths(tmpdir): } +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_macho_make_paths(): out = macho_make_paths_relative('/Users/Shared/spack/pkgC/lib/libC.dylib', '/Users/Shared/spack', diff --git a/lib/spack/spack/test/patch.py b/lib/spack/spack/test/patch.py index 05de40f88d..1eaec4e7b9 100644 --- a/lib/spack/spack/test/patch.py +++ b/lib/spack/spack/test/patch.py @@ -6,6 +6,7 @@ import collections import filecmp import os +import sys import pytest @@ -44,6 +45,8 @@ def mock_patch_stage(tmpdir_factory, monkeypatch): data_path = os.path.join(spack.paths.test_path, 'data', 'patch') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('filename, sha256, archive_sha256', [ # compressed patch -- needs sha256 and archive_256 (os.path.join(data_path, 'foo.tgz'), @@ -89,6 +92,8 @@ def test_url_patch(mock_patch_stage, filename, sha256, archive_sha256): assert filecmp.cmp('foo.txt', 'foo-expected.txt') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_patch_in_spec(mock_packages, config): """Test whether patches in a package appear in the spec.""" spec = Spec('patch') @@ -107,6 +112,8 @@ def test_patch_in_spec(mock_packages, config): tuple(spec.variants['patches']._patches_in_order_of_appearance)) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_patch_mixed_versions_subset_constraint(mock_packages, config): """If we have a package with mixed x.y and x.y.z versions, make sure that a patch applied to a version range of x.y.z versions is not applied to @@ -121,6 +128,8 @@ def test_patch_mixed_versions_subset_constraint(mock_packages, config): assert biz_sha256 not in spec2.variants['patches'].value +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_patch_order(mock_packages, config): spec = Spec('dep-diamond-patch-top') spec.concretize() @@ -168,6 +177,8 @@ def test_nested_directives(mock_packages): assert len(fake_dep.patches[Spec()]) == 2 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_patched_dependency( mock_packages, config, install_mockery, mock_fetch): """Test whether patched dependencies work.""" @@ -195,6 +206,8 @@ def test_patched_dependency( assert 'Patched!' in mf.read() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_multiple_patched_dependencies(mock_packages, config): """Test whether multiple patched dependencies work.""" spec = Spec('patch-several-dependencies') @@ -213,6 +226,8 @@ def test_multiple_patched_dependencies(mock_packages, config): (url2_sha256, url1_sha256) == spec['fake'].variants['patches'].value) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_conditional_patched_dependencies(mock_packages, config): """Test whether conditional patched dependencies work.""" spec = Spec('patch-several-dependencies @1.0') @@ -294,6 +309,8 @@ def get_patch(spec, ending): assert url2_patch.archive_sha256 == url2_archive_sha256 +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_conditional_patched_deps_with_conditions(mock_packages, config): """Test whether conditional patched dependencies with conditions work.""" spec = Spec('patch-several-dependencies @1.0 ^libdwarf@20111030') @@ -309,6 +326,8 @@ def test_conditional_patched_deps_with_conditions(mock_packages, config): spec.package.package_dir) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_write_and_read_sub_dags_with_patched_deps(mock_packages, config): """Test whether patched dependencies are still correct after writing and reading a sub-DAG of a concretized Spec. diff --git a/lib/spack/spack/test/permissions.py b/lib/spack/spack/test/permissions.py index f570e5234f..01787922ae 100644 --- a/lib/spack/spack/test/permissions.py +++ b/lib/spack/spack/test/permissions.py @@ -5,6 +5,7 @@ import os import stat +import sys import pytest @@ -13,6 +14,8 @@ from spack.util.file_permissions import InvalidPermissionsError, set_permissions +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_chmod_real_entries_ignores_suid_sgid(tmpdir): path = str(tmpdir.join('file').ensure()) mode = stat.S_ISUID | stat.S_ISGID | stat.S_ISVTX @@ -25,6 +28,8 @@ def test_chmod_real_entries_ignores_suid_sgid(tmpdir): assert os.stat(path).st_mode == mode | perms & ~stat.S_IXUSR +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_chmod_rejects_group_writable_suid(tmpdir): path = str(tmpdir.join('file').ensure()) mode = stat.S_ISUID @@ -35,6 +40,8 @@ def test_chmod_rejects_group_writable_suid(tmpdir): set_permissions(path, perms) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_chmod_rejects_world_writable_suid(tmpdir): path = str(tmpdir.join('file').ensure()) mode = stat.S_ISUID @@ -45,6 +52,8 @@ def test_chmod_rejects_world_writable_suid(tmpdir): set_permissions(path, perms) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_chmod_rejects_world_writable_sgid(tmpdir): path = str(tmpdir.join('file').ensure()) mode = stat.S_ISGID diff --git a/lib/spack/spack/test/relocate.py b/lib/spack/spack/test/relocate.py index 4ef9ae4bb3..9b95e0d2f9 100644 --- a/lib/spack/spack/test/relocate.py +++ b/lib/spack/spack/test/relocate.py @@ -6,6 +6,7 @@ import os.path import re import shutil +import sys import pytest @@ -224,6 +225,8 @@ def test_file_is_relocatable_errors(tmpdir): assert 'is not an absolute path' in str(exc_info.value) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('patchelf_behavior,expected', [ ('echo ', []), ('echo /opt/foo/lib:/opt/foo/lib64', ['/opt/foo/lib', '/opt/foo/lib64']), @@ -241,7 +244,8 @@ def test_existing_rpaths(patchelf_behavior, expected, mock_patchelf): @pytest.mark.parametrize('start_path,path_root,paths,expected', [ ('/usr/bin/test', '/usr', ['/usr/lib', '/usr/lib64', '/opt/local/lib'], - ['$ORIGIN/../lib', '$ORIGIN/../lib64', '/opt/local/lib']) + [os.path.join('$ORIGIN', '..', 'lib'), os.path.join('$ORIGIN', '..', 'lib64'), + '/opt/local/lib']) ]) def test_make_relative_paths(start_path, path_root, paths, expected): relatives = spack.relocate._make_relative(start_path, path_root, paths) @@ -253,7 +257,8 @@ def test_make_relative_paths(start_path, path_root, paths, expected): # and then normalized ('/usr/bin/test', ['$ORIGIN/../lib', '$ORIGIN/../lib64', '/opt/local/lib'], - ['/usr/lib', '/usr/lib64', '/opt/local/lib']), + [os.sep + os.path.join('usr', 'lib'), os.sep + os.path.join('usr', 'lib64'), + '/opt/local/lib']), # Relative path without $ORIGIN ('/usr/bin/test', ['../local/lib'], ['../local/lib']), ]) @@ -264,6 +269,8 @@ def test_normalize_relative_paths(start_path, relative_paths, expected): assert normalized == expected +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_set_elf_rpaths(mock_patchelf): # Try to relocate a mock version of patchelf and check # the call made to patchelf itself @@ -277,6 +284,8 @@ def test_set_elf_rpaths(mock_patchelf): assert patchelf in output +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_set_elf_rpaths_warning(mock_patchelf): # Mock a failing patchelf command and ensure it warns users patchelf = mock_patchelf('exit 1') diff --git a/lib/spack/spack/test/sbang.py b/lib/spack/spack/test/sbang.py index 4488d8845a..9218c80d3d 100644 --- a/lib/spack/spack/test/sbang.py +++ b/lib/spack/spack/test/sbang.py @@ -55,7 +55,7 @@ @pytest.fixture # type: ignore[no-redef] def sbang_line(): - yield '#!/bin/sh %s/bin/sbang\n' % spack.store.layout.root + yield '#!/bin/sh {0}{1}bin{1}sbang\n'.format(spack.store.layout.root, os.sep) class ScriptDirectory(object): @@ -181,6 +181,8 @@ def script_dir(sbang_line): sdir.destroy() +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('shebang,interpreter', [ (b'#!/path/to/interpreter argument\n', b'/path/to/interpreter'), (b'#! /path/to/interpreter truncated-argum', b'/path/to/interpreter'), @@ -251,6 +253,8 @@ def test_shebang_handling(script_dir, sbang_line): assert f.readline() == last_line +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_shebang_handles_non_writable_files(script_dir, sbang_line): # make a file non-writable st = os.stat(script_dir.long_shebang) @@ -336,10 +340,14 @@ def run_test_install_sbang(group): check_sbang_installation(group) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_group_sbang(install_mockery, configure_group_perms): run_test_install_sbang(True) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_install_user_sbang(install_mockery, configure_user_perms): run_test_install_sbang(False) diff --git a/lib/spack/spack/test/spec_dag.py b/lib/spack/spack/test/spec_dag.py index 046ff7aad2..a14855069d 100644 --- a/lib/spack/spack/test/spec_dag.py +++ b/lib/spack/spack/test/spec_dag.py @@ -5,6 +5,8 @@ """ These tests check Spec DAG operations using dummy packages. """ +import sys + import pytest import spack.error @@ -52,6 +54,8 @@ def _mock(pkg_name, spec, deptypes=all_deptypes): return _mock +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_test_deptype(): """Ensure that test-only dependencies are only included for specified @@ -83,6 +87,8 @@ def test_test_deptype(): assert ('z' not in spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_installed_deps(): """Preinstall a package P with a constrained build dependency D, then @@ -131,6 +137,8 @@ def test_installed_deps(): assert a_spec['e'].version == spack.version.Version('2') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_specify_preinstalled_dep(): """Specify the use of a preinstalled package during concretization with a @@ -156,6 +164,8 @@ def test_specify_preinstalled_dep(): assert set(x.name for x in a_spec.traverse()) == set(['a', 'b', 'c']) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') @pytest.mark.parametrize('spec_str,expr_str,expected', [ ('x ^y@2', 'y@2', True), @@ -194,6 +204,8 @@ def test_conditional_dep_with_user_constraints(spec_str, expr_str, expected): assert result is expected, '{0} in {1}'.format(expr_str, spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('mutable_mock_repo', 'config') class TestSpecDag(object): def test_conflicting_package_constraints(self, set_dependency): diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py index fe8e07a54f..0c948c046c 100644 --- a/lib/spack/spack/test/spec_semantics.py +++ b/lib/spack/spack/test/spec_semantics.py @@ -314,6 +314,8 @@ def test_satisfies_multi_value_variant(self): check_satisfies('multivalue-variant foo="bar,baz"', 'foo="bar"') + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_satisfies_single_valued_variant(self): """Tests that the case reported in https://github.com/spack/spack/pull/2386#issuecomment-282147639 @@ -337,6 +339,8 @@ def test_satisfies_single_valued_variant(self): # Check that conditional dependencies are treated correctly assert '^b' in a + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_unsatisfied_single_valued_variant(self): a = Spec('a foobar=baz') a.concretize() @@ -346,11 +350,15 @@ def test_unsatisfied_single_valued_variant(self): mv.concretize() assert 'a@1.0' not in mv + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_indirect_unsatisfied_single_valued_variant(self): spec = Spec('singlevalue-variant-dependent') spec.concretize() assert 'a@1.0' not in spec + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_unsatisfiable_multi_value_variant(self): # Semantics for a multi-valued variant is different @@ -483,6 +491,8 @@ def test_unsatisfiable_compiler_flag(self): # 'mpich' is concrete: check_unsatisfiable('mpich', 'mpich cppflags="-O3"', True) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_copy_satisfies_transitive(self): spec = Spec('dttop') spec.concretize() @@ -496,6 +506,8 @@ def test_unsatisfiable_compiler_flag_mismatch(self): check_unsatisfiable( 'mpich cppflags="-O3"', 'mpich cppflags="-O2"') + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_satisfies_virtual(self): # Don't use check_satisfies: it checks constrain() too, and # you can't constrain a non-virtual by a virtual. @@ -503,6 +515,8 @@ def test_satisfies_virtual(self): assert Spec('mpich2').satisfies(Spec('mpi')) assert Spec('zmpi').satisfies(Spec('mpi')) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_satisfies_virtual_dep_with_virtual_constraint(self): """Ensure we can satisfy virtual constraints when there are multiple vdep providers in the specs.""" @@ -519,6 +533,8 @@ def test_satisfies_virtual_dep_with_virtual_constraint(self): 'netlib-lapack ^netlib-blas' ) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_satisfies_same_spec_with_different_hash(self): """Ensure that concrete specs are matched *exactly* by hash.""" s1 = Spec('mpileaks').concretized() @@ -564,6 +580,8 @@ def test_spec_contains_deps(self): assert 'libelf' in s assert 'mpi' in s + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_virtual_index(self): s = Spec('callpath') @@ -758,6 +776,8 @@ def test_exceptional_paths_for_constructor(self): with pytest.raises(ValueError): Spec('libelf foo') + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_spec_formatting(self): spec = Spec("multivalue-variant cflags=-O2") spec.concretize() @@ -830,6 +850,8 @@ def test_spec_formatting(self): actual = spec.format(named_str) assert expected == actual + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_spec_formatting_escapes(self): spec = Spec('multivalue-variant cflags=-O2') spec.concretize() @@ -862,6 +884,8 @@ def test_spec_formatting_escapes(self): with pytest.raises(SpecFormatStringError): spec.format(fmt_str) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_spec_deprecated_formatting(self): spec = Spec("libelf cflags=-O2") spec.concretize() @@ -905,6 +929,8 @@ def test_spec_deprecated_formatting(self): actual = spec.format(named_str) assert str(expected) == actual + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('9908') def test_spec_flags_maintain_order(self): # Spack was assembling flags in a manner that could result in @@ -971,6 +997,8 @@ def test_abstract_spec_prefix_error(self): with pytest.raises(SpecError): spec.prefix + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_forwarding_of_architecture_attributes(self): spec = Spec('libelf target=x86_64').concretized() @@ -991,6 +1019,8 @@ def test_forwarding_of_architecture_attributes(self): assert 'avx512' not in spec.target assert spec.target < 'broadwell' + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('transitive', [True, False]) def test_splice(self, transitive): # Tests the new splice function in Spec using a somewhat simple case @@ -1026,6 +1056,8 @@ def test_splice(self, transitive): # Finally, the spec should know it's been spliced: assert out.spliced + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('transitive', [True, False]) def test_splice_with_cached_hashes(self, transitive): spec = Spec('splice-t') @@ -1056,6 +1088,8 @@ def test_splice_with_cached_hashes(self, transitive): assert (out['splice-h'].build_hash() == dep.build_hash()) == transitive assert out['splice-z'].build_hash() == out_z_expected.build_hash() + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('transitive', [True, False]) def test_splice_input_unchanged(self, transitive): spec = Spec('splice-t').concretized() @@ -1068,6 +1102,8 @@ def test_splice_input_unchanged(self, transitive): assert spec.full_hash() == orig_spec_hash assert dep.full_hash() == orig_dep_hash + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('transitive', [True, False]) def test_splice_subsequent(self, transitive): spec = Spec('splice-t') @@ -1172,6 +1208,8 @@ def test_satisfies_dependencies_ordered(self): assert s.satisfies('mpileaks ^zmpi ^fake', strict=True) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.regression('3887') @pytest.mark.parametrize('spec_str', [ 'git', 'hdf5', 'py-flake8' diff --git a/lib/spack/spack/test/spec_syntax.py b/lib/spack/spack/test/spec_syntax.py index 48e55254f4..81ce8c6344 100644 --- a/lib/spack/spack/test/spec_syntax.py +++ b/lib/spack/spack/test/spec_syntax.py @@ -5,6 +5,7 @@ import itertools import os import shlex +import sys import pytest @@ -286,6 +287,8 @@ def _check_hash_parse(self, spec): str(spec), spec.name + '@' + str(spec.version) + ' /' + spec.dag_hash()[:6]) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_spec_by_hash(self, database): specs = database.query() @@ -294,6 +297,8 @@ def test_spec_by_hash(self, database): for spec in specs: self._check_hash_parse(spec) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_dep_spec_by_hash(self, database): mpileaks_zmpi = database.query_one('mpileaks ^zmpi') @@ -322,6 +327,8 @@ def test_dep_spec_by_hash(self, database): assert 'fake' in mpileaks_hash_fake_and_zmpi assert mpileaks_hash_fake_and_zmpi['fake'] == fake + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_multiple_specs_with_hash(self, database): mpileaks_zmpi = database.query_one('mpileaks ^zmpi') @@ -355,6 +362,8 @@ def test_multiple_specs_with_hash(self, database): ' / ' + callpath_mpich2.dag_hash()) assert len(specs) == 2 + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_ambiguous_hash(self, mutable_database): x1 = Spec('a') @@ -373,6 +382,8 @@ def test_ambiguous_hash(self, mutable_database): # ambiguity in first hash character AND spec name self._check_raises(AmbiguousHashError, ['a/x']) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_invalid_hash(self, database): mpileaks_zmpi = database.query_one('mpileaks ^zmpi') @@ -391,6 +402,8 @@ def test_invalid_hash(self, database): 'mpileaks ^mpich /' + mpileaks_zmpi.dag_hash(), 'mpileaks ^zmpi /' + mpileaks_mpich.dag_hash()]) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_nonexistent_hash(self, database): """Ensure we get errors for nonexistant hashes.""" @@ -405,6 +418,8 @@ def test_nonexistent_hash(self, database): '/' + no_such_hash, 'mpileaks /' + no_such_hash]) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.db def test_redundant_spec(self, database): """Check that redundant spec constraints raise errors. @@ -491,6 +506,8 @@ def test_duplicate_architecture_component(self): ] self._check_raises(DuplicateArchitectureError, duplicates) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_parse_yaml_simple(self, mock_packages, tmpdir): s = Spec('libdwarf') @@ -511,6 +528,8 @@ def test_parse_yaml_simple(self, mock_packages, tmpdir): specs = sp.parse('mvapich_foo {0}'.format(specfile.strpath)) assert len(specs) == 2 + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_parse_filename_missing_slash_as_spec(self, mock_packages, tmpdir): """Ensure that libelf.yaml parses as a spec, NOT a file.""" @@ -554,6 +573,8 @@ def test_parse_filename_missing_slash_as_spec(self, mock_packages, tmpdir): ) ) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_parse_yaml_dependency(self, mock_packages, tmpdir): s = Spec('libdwarf') @@ -569,6 +590,8 @@ def test_parse_yaml_dependency(self, mock_packages, tmpdir): specs = sp.parse('libdwarf ^ {0}'.format(specfile.strpath)) assert len(specs) == 1 + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_parse_yaml_relative_paths(self, mock_packages, tmpdir): s = Spec('libdwarf') @@ -604,6 +627,8 @@ def test_parse_yaml_relative_paths(self, mock_packages, tmpdir): parent_dir, file_name)) assert len(specs) == 2 + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_parse_yaml_relative_subdir_path(self, mock_packages, tmpdir): s = Spec('libdwarf') @@ -624,6 +649,8 @@ def test_parse_yaml_relative_subdir_path(self, mock_packages, tmpdir): specs = sp.parse('subdir/{0}'.format(file_name)) assert len(specs) == 1 + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_parse_yaml_dependency_relative_paths(self, mock_packages, tmpdir): s = Spec('libdwarf') @@ -683,6 +710,8 @@ def test_yaml_spec_not_filename(self, mock_packages, tmpdir): with pytest.raises(spack.repo.UnknownPackageError): Spec('builtin.mock.yamlfoobar').concretize() + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.usefixtures('config') def test_parse_yaml_variant_error(self, mock_packages, tmpdir): s = Spec('a') diff --git a/lib/spack/spack/test/spec_yaml.py b/lib/spack/spack/test/spec_yaml.py index 8aa14b9230..abeeec8f36 100644 --- a/lib/spack/spack/test/spec_yaml.py +++ b/lib/spack/spack/test/spec_yaml.py @@ -11,6 +11,7 @@ import ast import inspect import os +import sys import pytest @@ -52,6 +53,8 @@ def test_normal_spec(mock_packages): check_json_round_trip(spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( "invalid_yaml", [ @@ -66,6 +69,8 @@ def test_invalid_yaml_spec(invalid_yaml): assert invalid_yaml in exc_msg +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( "invalid_json, error_message", [ @@ -80,6 +85,8 @@ def test_invalid_json_spec(invalid_json, error_message): assert error_message in exc_msg +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_external_spec(config, mock_packages): spec = Spec('externaltool') spec.concretize() @@ -99,6 +106,8 @@ def test_ambiguous_version_spec(mock_packages): check_json_round_trip(spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_concrete_spec(config, mock_packages): spec = Spec('mpileaks+debug~opt') spec.concretize() @@ -106,6 +115,8 @@ def test_concrete_spec(config, mock_packages): check_json_round_trip(spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_yaml_multivalue(config, mock_packages): spec = Spec('multivalue-variant foo="bar,baz"') spec.concretize() @@ -113,6 +124,8 @@ def test_yaml_multivalue(config, mock_packages): check_json_round_trip(spec) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_yaml_subdag(config, mock_packages): spec = Spec('mpileaks^mpich+debug') spec.concretize() @@ -157,6 +170,8 @@ def descend_and_check(iterable, level=0): ht.build_hash, ht.full_hash ]) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_ordered_read_not_required_for_consistent_dag_hash( hash_type, config, mock_packages ): @@ -331,6 +346,8 @@ def check_specs_equal(original_spec, spec_yaml_path): return original_spec.eq_dag(spec_from_yaml) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_save_dependency_spec_jsons_subset(tmpdir, config): output_path = str(tmpdir.mkdir('spec_jsons')) diff --git a/lib/spack/spack/test/stage.py b/lib/spack/spack/test/stage.py index 97462ac4f1..223769b29b 100644 --- a/lib/spack/spack/test/stage.py +++ b/lib/spack/spack/test/stage.py @@ -10,6 +10,8 @@ import os import shutil import stat +import sys +import tempfile import pytest @@ -39,6 +41,10 @@ _include_hidden = 2 _include_extra = 3 +_file_prefix = 'file://' +if sys.platform == 'win32': + _file_prefix += '/' + # Mock fetch directories are expected to appear as follows: # @@ -212,7 +218,7 @@ def create_stage_archive(expected_file_list=[_include_readme]): # Create the archive directory and associated file archive_dir = tmpdir.join(_archive_base) archive = tmpdir.join(_archive_fn) - archive_url = 'file://' + str(archive) + archive_url = _file_prefix + str(archive) archive_dir.ensure(dir=True) # Create the optional files as requested and make sure expanded @@ -278,7 +284,7 @@ def mock_expand_resource(tmpdir): archive_name = 'resource.tar.gz' archive = tmpdir.join(archive_name) - archive_url = 'file://' + str(archive) + archive_url = _file_prefix + str(archive) filename = 'resource-file.txt' test_file = resource_dir.join(filename) @@ -412,7 +418,7 @@ def test_noexpand_stage_file( property of the stage should refer to the path of that file. """ test_noexpand_fetcher = spack.fetch_strategy.from_kwargs( - url='file://' + mock_noexpand_resource, expand=False) + url=_file_prefix + mock_noexpand_resource, expand=False) with Stage(test_noexpand_fetcher) as stage: stage.fetch() stage.expand_archive() @@ -428,7 +434,7 @@ def test_composite_stage_with_noexpand_resource( resource_dst_name = 'resource-dst-name.sh' test_resource_fetcher = spack.fetch_strategy.from_kwargs( - url='file://' + mock_noexpand_resource, expand=False) + url=_file_prefix + mock_noexpand_resource, expand=False) test_resource = Resource( 'test_resource', test_resource_fetcher, resource_dst_name, None) resource_stage = ResourceStage( @@ -657,7 +663,9 @@ def test_source_path_available(self, mock_stage_archive): assert source_path.endswith(spack.stage._source_path_subdir) assert not os.path.exists(source_path) - @pytest.mark.skipif(os.getuid() == 0, reason='user is root') + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") + @pytest.mark.skipif(getuid() == 0, reason='user is root') def test_first_accessible_path(self, tmpdir): """Test _first_accessible_path names.""" spack_dir = tmpdir.join('paths') @@ -688,6 +696,8 @@ def test_first_accessible_path(self, tmpdir): # Cleanup shutil.rmtree(str(name)) + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_create_stage_root(self, tmpdir, no_path_access): """Test create_stage_root permissions.""" test_dir = tmpdir.join('path') @@ -788,7 +798,9 @@ def test_resolve_paths(self): assert spack.stage._resolve_paths(paths) == res_paths - @pytest.mark.skipif(os.getuid() == 0, reason='user is root') + @pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") + @pytest.mark.skipif(getuid() == 0, reason='user is root') def test_get_stage_root_bad_path(self, clear_stage_root): """Ensure an invalid stage path root raises a StageError.""" with spack.config.override('config:build_stage', '/no/such/path'): @@ -893,6 +905,8 @@ def test_diystage_preserve_file(self, tmpdir): _file.read() == _readme_contents +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_stage_create_replace_path(tmp_build_stage_dir): """Ensure stage creation replaces a non-directory path.""" _, test_stage_path = tmp_build_stage_dir @@ -909,6 +923,8 @@ def test_stage_create_replace_path(tmp_build_stage_dir): assert os.path.isdir(stage.path) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_cannot_access(capsys): """Ensure can_access dies with the expected error.""" with pytest.raises(SystemExit): diff --git a/lib/spack/spack/test/svn_fetch.py b/lib/spack/spack/test/svn_fetch.py index 73d672eb4a..b15d2e2ca3 100644 --- a/lib/spack/spack/test/svn_fetch.py +++ b/lib/spack/spack/test/svn_fetch.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -22,6 +23,8 @@ reason='requires subversion to be installed') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize("type_of_test", ['default', 'rev0']) @pytest.mark.parametrize("secure", [True, False]) def test_fetch( @@ -78,6 +81,8 @@ def test_fetch( assert h() == t.revision +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_svn_extra_fetch(tmpdir): """Ensure a fetch after downloading is effectively a no-op.""" testpath = str(tmpdir) diff --git a/lib/spack/spack/test/test_activations.py b/lib/spack/spack/test/test_activations.py index 86dcbbfef2..915b4d2081 100644 --- a/lib/spack/spack/test/test_activations.py +++ b/lib/spack/spack/test/test_activations.py @@ -8,6 +8,7 @@ """ import os +import sys import pytest @@ -177,6 +178,8 @@ def test_python_activation_with_files(tmpdir, python_and_extension_dirs, assert 'setuptools.egg' not in easy_install_contents +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_python_activation_view(tmpdir, python_and_extension_dirs, builtin_and_mock_packages, monkeypatch): python_prefix, ext_prefix = python_and_extension_dirs @@ -200,6 +203,8 @@ def test_python_activation_view(tmpdir, python_and_extension_dirs, assert os.path.exists(os.path.join(view_dir, 'bin/py-ext-tool')) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_python_ignore_namespace_init_conflict( tmpdir, namespace_extensions, builtin_and_mock_packages, monkeypatch): """Test the view update logic in PythonPackage ignores conflicting @@ -234,6 +239,8 @@ def test_python_ignore_namespace_init_conflict( assert os.path.exists(os.path.join(view_dir, init_file)) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_python_keep_namespace_init( tmpdir, namespace_extensions, builtin_and_mock_packages, monkeypatch): """Test the view update logic in PythonPackage keeps the namespace @@ -276,6 +283,8 @@ def test_python_keep_namespace_init( assert not os.path.exists(os.path.join(view_dir, init_file)) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_python_namespace_conflict(tmpdir, namespace_extensions, monkeypatch, builtin_and_mock_packages): """Test the view update logic in PythonPackage reports an error when two diff --git a/lib/spack/spack/test/test_suite.py b/lib/spack/spack/test/test_suite.py index 7235eb9453..419e633e9c 100644 --- a/lib/spack/spack/test/test_suite.py +++ b/lib/spack/spack/test/test_suite.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -12,6 +13,8 @@ import spack.spec +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_test_log_pathname(mock_packages, config): """Ensure test log path is reasonable.""" spec = spack.spec.Spec('libdwarf').concretized() @@ -25,6 +28,8 @@ def test_test_log_pathname(mock_packages, config): assert test_suite.test_log_name(spec) in logfile +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_test_ensure_stage(mock_test_stage): """Make sure test stage directory is properly set up.""" spec = spack.spec.Spec('libdwarf').concretized() @@ -38,6 +43,8 @@ def test_test_ensure_stage(mock_test_stage): assert mock_test_stage in test_suite.stage +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_write_test_result(mock_packages, mock_test_stage): """Ensure test results written to a results file.""" spec = spack.spec.Spec('libdwarf').concretized() @@ -58,6 +65,7 @@ def test_write_test_result(mock_packages, mock_test_stage): assert spec.name in msg +@pytest.mark.skipif(sys.platform == 'win32', reason="Not yet implemented on windows") def test_do_test(mock_packages, install_mockery, mock_test_stage): """Perform a stand-alone test with files to copy.""" spec = spack.spec.Spec('trivial-smoke-test').concretized() diff --git a/lib/spack/spack/test/url_fetch.py b/lib/spack/spack/test/url_fetch.py index 6e00a3f481..d3155a45f0 100644 --- a/lib/spack/spack/test/url_fetch.py +++ b/lib/spack/spack/test/url_fetch.py @@ -111,12 +111,16 @@ def test_archive_file_errors(tmpdir, mock_archive, _fetch_method): fetcher._fetch_from_url('file:///does-not-exist') +files = [('.tar.gz', 'z'), ('.tgz', 'z')] +if sys.platform != "win32": + files += [('.tar.bz2', 'j'), ('.tbz2', 'j'), + ('.tar.xz', 'J'), ('.txz', 'J')] + + @pytest.mark.parametrize('secure', [True, False]) @pytest.mark.parametrize('_fetch_method', ['curl', 'urllib']) @pytest.mark.parametrize('mock_archive', - [('.tar.gz', 'z'), ('.tgz', 'z'), - ('.tar.bz2', 'j'), ('.tbz2', 'j'), - ('.tar.xz', 'J'), ('.txz', 'J')], + files, indirect=True) def test_fetch( mock_archive, @@ -159,6 +163,8 @@ def test_fetch( assert 'echo Building...' in contents +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize('spec,url,digest', [ ('url-list-test @0.0.0', 'foo-0.0.0.tar.gz', '00000000000000000000000000000000'), ('url-list-test @1.0.0', 'foo-1.0.0.tar.gz', '00000000000000000000000000000100'), @@ -195,6 +201,8 @@ def test_from_list_url(mock_packages, config, spec, url, digest, _fetch_method): assert fetch_strategy.extra_options == {'timeout': 60} +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize("_fetch_method", ["curl", "urllib"]) @pytest.mark.parametrize("requested_version,tarball,digest", [ # This version is in the web data path (test/data/web/4.html), but not in the diff --git a/lib/spack/spack/test/util/editor.py b/lib/spack/spack/test/util/editor.py index ee8ed6295f..f197682a97 100644 --- a/lib/spack/spack/test/util/editor.py +++ b/lib/spack/spack/test/util/editor.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys import pytest @@ -15,11 +16,15 @@ def _make_exe(tmpdir_factory, name, contents=None): + if sys.platform == "win32": + name += '.exe' path = str(tmpdir_factory.mktemp('%s_exe' % name).join(name)) if contents is not None: with open(path, 'w') as f: f.write('#!/bin/sh\n%s\n' % contents) set_executable(path) + if sys.platform == "win32": + path = path.replace('\\', '/') return path @@ -43,11 +48,13 @@ def vim_exe(tmpdir_factory): return _make_exe(tmpdir_factory, 'vim', 'exit 0') +@pytest.mark.skipif(sys.platform == 'win32', reason="editor not implemented on windows") def test_find_exe_from_env_var(good_exe): os.environ['EDITOR'] = good_exe assert ed._find_exe_from_env_var('EDITOR') == (good_exe, [good_exe]) +@pytest.mark.skipif(sys.platform == 'win32', reason="editor not implemented on windows") def test_find_exe_from_env_var_with_args(good_exe): os.environ['EDITOR'] = good_exe + ' a b c' assert ed._find_exe_from_env_var('EDITOR') == ( @@ -65,6 +72,7 @@ def test_find_exe_from_env_var_no_editor(): assert ed._find_exe_from_env_var('FOO') == (None, []) +@pytest.mark.skipif(sys.platform == 'win32', reason="editor not implemented on windows") def test_editor_visual(good_exe): os.environ['VISUAL'] = good_exe @@ -75,6 +83,7 @@ def assert_exec(exe, args): ed.editor('/path/to/file', _exec_func=assert_exec) +@pytest.mark.skipif(sys.platform == 'win32', reason="editor not implemented on windows") def test_editor_visual_bad(good_exe, bad_exe): os.environ['VISUAL'] = bad_exe os.environ['EDITOR'] = good_exe @@ -89,6 +98,7 @@ def assert_exec(exe, args): ed.editor('/path/to/file', _exec_func=assert_exec) +@pytest.mark.skipif(sys.platform == 'win32', reason="editor not implemented on windows") def test_editor_no_visual(good_exe): if 'VISUAL' in os.environ: del os.environ['VISUAL'] @@ -101,6 +111,7 @@ def assert_exec(exe, args): ed.editor('/path/to/file', _exec_func=assert_exec) +@pytest.mark.skipif(sys.platform == 'win32', reason="editor not implemented on windows") def test_editor_no_visual_with_args(good_exe): if 'VISUAL' in os.environ: del os.environ['VISUAL'] @@ -115,12 +126,13 @@ def assert_exec(exe, args): ed.editor('/path/to/file', _exec_func=assert_exec) +@pytest.mark.skipif(sys.platform == 'win32', reason="editor not implemented on windows") def test_editor_both_bad(nosuch_exe, vim_exe): os.environ['VISUAL'] = nosuch_exe os.environ['EDITOR'] = nosuch_exe - os.environ['PATH'] = '%s:%s' % ( - os.path.dirname(vim_exe), os.environ['PATH']) + os.environ['PATH'] = '%s%s%s' % ( + os.path.dirname(vim_exe), os.pathsep, os.environ['PATH']) def assert_exec(exe, args): assert exe == vim_exe diff --git a/lib/spack/spack/test/util/environment.py b/lib/spack/spack/test/util/environment.py index 4d0a931a56..3604b7871b 100644 --- a/lib/spack/spack/test/util/environment.py +++ b/lib/spack/spack/test/util/environment.py @@ -5,6 +5,7 @@ """Test Spack's environment utility functions.""" import os +import sys import pytest @@ -19,6 +20,7 @@ def prepare_environment_for_tests(): del os.environ['TEST_ENV_VAR'] +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_is_system_path(): assert(envutil.is_system_path('/usr/bin')) assert(not envutil.is_system_path('/nonsense_path/bin')) @@ -34,6 +36,7 @@ def test_is_system_path(): '/usr/lib64'] +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_filter_system_paths(): expected = [p for p in test_paths if p.startswith('/nonsense_path')] filtered = envutil.filter_system_paths(test_paths) @@ -54,6 +57,7 @@ def test_prune_duplicate_paths(): assert(expected == envutil.prune_duplicate_paths(test_paths)) +@pytest.mark.skipif(sys.platform == 'win32', reason="All Fetchers Failed") def test_get_path(prepare_environment_for_tests): os.environ['TEST_ENV_VAR'] = '/a:/b:/c/d' expected = ['/a', '/b', '/c/d'] @@ -88,7 +92,8 @@ def test_env_flag(prepare_environment_for_tests): def test_path_set(prepare_environment_for_tests): envutil.path_set('TEST_ENV_VAR', ['/a', '/a/b', '/a/a']) - assert(os.environ['TEST_ENV_VAR'] == '/a:/a/b:/a/a') + assert(os.environ['TEST_ENV_VAR'] == '/a' + os.pathsep + + '/a/b' + os.pathsep + '/a/a') def test_path_put_first(prepare_environment_for_tests): @@ -111,8 +116,8 @@ def test_dump_environment(prepare_environment_for_tests, tmpdir): def test_reverse_environment_modifications(working_env): start_env = { - 'PREPEND_PATH': '/path/to/prepend/to', - 'APPEND_PATH': '/path/to/append/to', + 'PREPEND_PATH': os.sep + os.path.join('path', 'to', 'prepend', 'to'), + 'APPEND_PATH': os.sep + os.path.join('path', 'to', 'append', 'to'), 'UNSET': 'var_to_unset', 'APPEND_FLAGS': 'flags to append to', } diff --git a/lib/spack/spack/test/util/executable.py b/lib/spack/spack/test/util/executable.py index c8a21f9283..6a313e751f 100644 --- a/lib/spack/spack/test/util/executable.py +++ b/lib/spack/spack/test/util/executable.py @@ -36,21 +36,31 @@ def test_read_unicode(tmpdir, working_env): filter_shebangs_in_directory('.', [script_name]) # read the unicode back in and see whether things work - script = ex.Executable('./%s' % script_name) + if sys.platform == 'win32': + script = ex.Executable('%s %s' % (sys.executable, script_name)) + else: + script = ex.Executable('./%s' % script_name) + assert u'\xc3' == script(output=str).strip() def test_which_relative_path_with_slash(tmpdir, working_env): - tmpdir.ensure('exe') - path = str(tmpdir.join('exe')) + tmpdir.ensure("exe") + path = str(tmpdir.join("exe")) + os.environ['PATH'] = '' with tmpdir.as_cwd(): - no_exe = ex.which('./exe') + no_exe = ex.which('.{0}exe'.format(os.path.sep)) assert no_exe is None + if sys.platform == "win32": + # For Windows, need to create files with .exe after any assert is none tests + tmpdir.ensure("exe.exe") + path += ".exe" + else: + fs.set_executable(path) - fs.set_executable(path) - exe = ex.which('./exe') + exe = ex.which('.{0}exe'.format(os.path.sep)) assert exe.path == path @@ -62,24 +72,39 @@ def test_which_with_slash_ignores_path(tmpdir, working_env): wrong_path = str(tmpdir.join('bin', 'exe')) os.environ['PATH'] = os.path.dirname(wrong_path) - fs.set_executable(path) - fs.set_executable(wrong_path) - with tmpdir.as_cwd(): - exe = ex.which('./exe') + if sys.platform == "win32": + # For Windows, need to create files with .exe after any assert is none tests + tmpdir.ensure('exe.exe') + tmpdir.ensure('bin{0}exe.exe'.format(os.path.sep)) + path = path + ".exe" + wrong_path = wrong_path + ".exe" + else: + fs.set_executable(path) + fs.set_executable(wrong_path) + + exe = ex.which('.{0}exe'.format(os.path.sep)) assert exe.path == path def test_which(tmpdir): os.environ["PATH"] = str(tmpdir) assert ex.which("spack-test-exe") is None + with pytest.raises(ex.CommandNotFoundError): ex.which("spack-test-exe", required=True) - with tmpdir.as_cwd(): - fs.touch("spack-test-exe") - fs.set_executable('spack-test-exe') + path = str(tmpdir.join("spack-test-exe")) - exe = ex.which("spack-test-exe") - assert exe is not None - assert exe.path == str(tmpdir.join("spack-test-exe")) + with tmpdir.as_cwd(): + if sys.platform == "win32": + # For Windows, need to create files with .exe after any assert is none tests + tmpdir.ensure("spack-test-exe.exe") + path += ".exe" + else: + fs.touch("spack-test-exe") + fs.set_executable("spack-test-exe") + + exe = ex.which("spack-test-exe") + assert exe is not None + assert exe.path == path diff --git a/lib/spack/spack/test/util/file_cache.py b/lib/spack/spack/test/util/file_cache.py index 988e243835..02056fd444 100644 --- a/lib/spack/spack/test/util/file_cache.py +++ b/lib/spack/spack/test/util/file_cache.py @@ -5,6 +5,7 @@ """Test Spack's FileCache.""" import os +import sys import pytest @@ -29,6 +30,8 @@ def test_write_and_read_cache_file(file_cache): assert text == "foobar\n" +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_write_and_remove_cache_file(file_cache): """Test two write transactions on a cached file. Then try to remove an entry from it. diff --git a/lib/spack/spack/test/util/path.py b/lib/spack/spack/test/util/path.py index edd5492c85..13633195db 100644 --- a/lib/spack/spack/test/util/path.py +++ b/lib/spack/spack/test/util/path.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import sys + import pytest import llnl.util.tty as tty @@ -26,18 +28,24 @@ ] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize("padded,fixed", zip(padded_lines, fixed_lines)) def test_padding_substitution(padded, fixed): """Ensure that all padded lines are unpadded correctly.""" assert fixed == sup.padding_filter(padded) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_no_substitution(): """Ensure that a line not containing one full path placeholder is not modified.""" partial = "--prefix=/Users/gamblin2/padding-log-test/opt/__spack_path_pla/darwin-bigsur-skylake/apple-clang-12.0.5/zlib-1.2.11-74mwnxgn6nujehpyyalhwizwojwn5zga'" # noqa: E501 assert sup.padding_filter(partial) == partial +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_short_substitution(): """Ensure that a single placeholder path component is replaced""" short = "--prefix=/Users/gamblin2/padding-log-test/opt/__spack_path_placeholder__/darwin-bigsur-skylake/apple-clang-12.0.5/zlib-1.2.11-74mwnxgn6nujehpyyalhwizwojwn5zga'" # noqa: E501 @@ -45,6 +53,8 @@ def test_short_substitution(): assert short_subst == sup.padding_filter(short) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_partial_substitution(): """Ensure that a single placeholder path component is replaced""" short = "--prefix=/Users/gamblin2/padding-log-test/opt/__spack_path_placeholder__/__spack_p/darwin-bigsur-skylake/apple-clang-12.0.5/zlib-1.2.11-74mwnxgn6nujehpyyalhwizwojwn5zga'" # noqa: E501 @@ -62,6 +72,8 @@ def test_longest_prefix_re(): ) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_output_filtering(capfd, install_mockery, mutable_config): """Test filtering padding out of tty messages.""" long_path = "/" + "/".join([sup.SPACK_PATH_PADDING_CHARS] * 200) diff --git a/lib/spack/spack/test/util/prefix.py b/lib/spack/spack/test/util/prefix.py index ead170855d..8cd92306b5 100644 --- a/lib/spack/spack/test/util/prefix.py +++ b/lib/spack/spack/test/util/prefix.py @@ -5,29 +5,31 @@ """Tests various features of :py:class:`spack.util.prefix.Prefix`""" +import os + from spack.util.prefix import Prefix def test_prefix_attributes(): """Test normal prefix attributes like ``prefix.bin``""" - prefix = Prefix('/usr') + prefix = Prefix(os.sep + 'usr') - assert prefix.bin == '/usr/bin' - assert prefix.lib == '/usr/lib' - assert prefix.include == '/usr/include' + assert prefix.bin == os.sep + os.path.join('usr', 'bin') + assert prefix.lib == os.sep + os.path.join('usr', 'lib') + assert prefix.include == os.sep + os.path.join('usr', 'include') def test_prefix_join(): """Test prefix join ``prefix.join(...)``""" - prefix = Prefix('/usr') + prefix = Prefix(os.sep + 'usr') a1 = prefix.join('a_{0}'.format(1)).lib64 a2 = prefix.join('a-{0}'.format(1)).lib64 a3 = prefix.join('a.{0}'.format(1)).lib64 - assert a1 == '/usr/a_1/lib64' - assert a2 == '/usr/a-1/lib64' - assert a3 == '/usr/a.1/lib64' + assert a1 == os.sep + os.path.join('usr', 'a_1', 'lib64') + assert a2 == os.sep + os.path.join('usr', 'a-1', 'lib64') + assert a3 == os.sep + os.path.join('usr', 'a.1', 'lib64') assert isinstance(a1, Prefix) assert isinstance(a2, Prefix) @@ -37,9 +39,9 @@ def test_prefix_join(): p2 = prefix.share.join('pkg-config').join('foo.pc') p3 = prefix.join('dashed-directory').foo - assert p1 == '/usr/bin/executable.sh' - assert p2 == '/usr/share/pkg-config/foo.pc' - assert p3 == '/usr/dashed-directory/foo' + assert p1 == os.sep + os.path.join('usr', 'bin', 'executable.sh') + assert p2 == os.sep + os.path.join('usr', 'share', 'pkg-config', 'foo.pc') + assert p3 == os.sep + os.path.join('usr', 'dashed-directory', 'foo') assert isinstance(p1, Prefix) assert isinstance(p2, Prefix) @@ -48,16 +50,16 @@ def test_prefix_join(): def test_multilevel_attributes(): """Test attributes of attributes, like ``prefix.share.man``""" - prefix = Prefix('/usr/') + prefix = Prefix(os.sep + 'usr' + os.sep) - assert prefix.share.man == '/usr/share/man' - assert prefix.man.man8 == '/usr/man/man8' - assert prefix.foo.bar.baz == '/usr/foo/bar/baz' + assert prefix.share.man == os.sep + os.path.join('usr', 'share', 'man') + assert prefix.man.man8 == os.sep + os.path.join('usr', 'man', 'man8') + assert prefix.foo.bar.baz == os.sep + os.path.join('usr', 'foo', 'bar', 'baz') share = prefix.share assert isinstance(share, Prefix) - assert share.man == '/usr/share/man' + assert share.man == os.sep + os.path.join('usr', 'share', 'man') def test_string_like_behavior(): diff --git a/lib/spack/spack/test/util/util_url.py b/lib/spack/spack/test/util/util_url.py index fc70e88289..3e5a4816e5 100644 --- a/lib/spack/spack/test/util/util_url.py +++ b/lib/spack/spack/test/util/util_url.py @@ -6,6 +6,7 @@ """Test Spack's URL handling utility functions.""" import os import os.path +import sys import pytest @@ -34,11 +35,11 @@ def test_url_parse(): assert(parsed.netloc == '') assert(parsed.path == '/path/to/resource') - parsed = url_util.parse('file://path/to/resource') - assert(parsed.scheme == 'file') - assert(parsed.netloc == '') - expected = os.path.abspath(os.path.join('path', 'to', 'resource')) - assert(parsed.path == expected) + if sys.platform != 'win32': + parsed = url_util.parse('file://path/to/resource') + assert(parsed.scheme == 'file') + expected = os.path.abspath(os.path.join('path', 'to', 'resource')) + assert(parsed.path == expected) parsed = url_util.parse('https://path/to/resource') assert(parsed.scheme == 'https') @@ -48,15 +49,23 @@ def test_url_parse(): spack_root = spack.paths.spack_root parsed = url_util.parse('$spack') assert(parsed.scheme == 'file') - assert(parsed.netloc == '') - assert(parsed.path == spack_root) + if sys.platform != 'win32': + assert(parsed.netloc == '') - parsed = url_util.parse('/a/b/c/$spack') - assert(parsed.scheme == 'file') - assert(parsed.netloc == '') - expected = os.path.abspath(os.path.join( - '/', 'a', 'b', 'c', './' + spack_root)) - assert(parsed.path == expected) + if sys.platform == "win32": + spack_root = spack_root.replace('\\', '/') + + assert(parsed.netloc + parsed.path == spack_root) + + # Test that sticking the spack root at the end of a posix path resolves + # correctly. + if sys.platform != "win32": + parsed = url_util.parse('/a/b/c/$spack') + assert(parsed.scheme == 'file') + assert(parsed.netloc == '') + expected = os.path.abspath(os.path.join( + '/', 'a', 'b', 'c', './' + spack_root)) + assert(parsed.path == expected) def test_url_local_file_path(): @@ -68,17 +77,19 @@ def test_url_local_file_path(): lfp = url_util.local_file_path('file:///a/b/c.txt') assert(lfp == '/a/b/c.txt') - lfp = url_util.local_file_path('file://a/b/c.txt') - expected = os.path.abspath(os.path.join('a', 'b', 'c.txt')) - assert(lfp == expected) + if sys.platform != "win32": + lfp = url_util.local_file_path('file://a/b/c.txt') + expected = os.path.abspath(os.path.join('a', 'b', 'c.txt')) + assert(lfp == expected) lfp = url_util.local_file_path('$spack/a/b/c.txt') expected = os.path.abspath(os.path.join(spack_root, 'a', 'b', 'c.txt')) assert(lfp == expected) - lfp = url_util.local_file_path('file:///$spack/a/b/c.txt') - expected = os.path.abspath(os.path.join(spack_root, 'a', 'b', 'c.txt')) - assert(lfp == expected) + if sys.platform != "win32": + lfp = url_util.local_file_path('file:///$spack/a/b/c.txt') + expected = os.path.abspath(os.path.join(spack_root, 'a', 'b', 'c.txt')) + assert(lfp == expected) lfp = url_util.local_file_path('file://$spack/a/b/c.txt') expected = os.path.abspath(os.path.join(spack_root, 'a', 'b', 'c.txt')) @@ -177,20 +188,21 @@ def test_url_join_local_paths(): # file:// URL path components are *NOT* canonicalized spack_root = spack.paths.spack_root - join_result = url_util.join('/a/b/c', '$spack') - assert(join_result == 'file:///a/b/c/$spack') # not canonicalized - format_result = url_util.format(join_result) - # canoncalize by hand - expected = url_util.format(os.path.abspath(os.path.join( - '/', 'a', 'b', 'c', '.' + spack_root))) - assert(format_result == expected) + if sys.platform != 'win32': + join_result = url_util.join('/a/b/c', '$spack') + assert(join_result == 'file:///a/b/c/$spack') # not canonicalized + format_result = url_util.format(join_result) + # canoncalize by hand + expected = url_util.format(os.path.abspath(os.path.join( + '/', 'a', 'b', 'c', '.' + spack_root))) + assert(format_result == expected) - # see test_url_join_absolute_paths() for more on absolute path components - join_result = url_util.join('/a/b/c', '/$spack') - assert(join_result == 'file:///$spack') # not canonicalized - format_result = url_util.format(join_result) - expected = url_util.format(spack_root) - assert(format_result == expected) + # see test_url_join_absolute_paths() for more on absolute path components + join_result = url_util.join('/a/b/c', '/$spack') + assert(join_result == 'file:///$spack') # not canonicalized + format_result = url_util.format(join_result) + expected = url_util.format(spack_root) + assert(format_result == expected) # For s3:// URLs, the "netloc" (bucket) is considered part of the path. # Make sure join() can cross bucket boundaries in this case. @@ -271,6 +283,10 @@ def test_url_join_absolute_paths(): cwd = os.getcwd() # ...to work out what resource it points to) + if sys.platform == "win32": + cwd.replace('\\', '/') + cwd = '/' + cwd + # So, even though parse() assumes "file://" URL, the scheme is still # significant in URL path components passed to join(), even if the base # is a file:// URL. diff --git a/lib/spack/spack/test/verification.py b/lib/spack/spack/test/verification.py index c6063538c9..2ad81bb39f 100644 --- a/lib/spack/spack/test/verification.py +++ b/lib/spack/spack/test/verification.py @@ -6,6 +6,9 @@ """Tests for the `spack.verify` module""" import os import shutil +import sys + +import pytest import llnl.util.filesystem as fs from llnl.util.symlink import symlink @@ -16,6 +19,8 @@ import spack.verify +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_link_manifest_entry(tmpdir): # Test that symlinks are properly checked against the manifest. # Test that the appropriate errors are generated when the check fails. @@ -115,6 +120,8 @@ def test_file_manifest_entry(tmpdir): assert sorted(results.errors[file]) == sorted(expected) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_check_chmod_manifest_entry(tmpdir): # Check that the verification properly identifies errors for files whose # permissions have been modified. @@ -188,6 +195,8 @@ def test_check_prefix_manifest(tmpdir): assert results.errors[spec.prefix] == ['manifest corrupted'] +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_single_file_verification(tmpdir): # Test the API to verify a single file, including finding the package # to which it belongs diff --git a/lib/spack/spack/test/versions.py b/lib/spack/spack/test/versions.py index 93697fedda..9b89222162 100644 --- a/lib/spack/spack/test/versions.py +++ b/lib/spack/spack/test/versions.py @@ -8,6 +8,7 @@ where it makes sense. """ import os +import sys import pytest @@ -585,6 +586,8 @@ def test_invalid_versions(version_str): Version(version_str) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_versions_from_git(mock_git_version_info, monkeypatch, mock_packages): repo_path, filename, commits = mock_git_version_info monkeypatch.setattr(spack.package.PackageBase, 'git', 'file://%s' % repo_path, diff --git a/lib/spack/spack/test/views.py b/lib/spack/spack/test/views.py index acf9393043..c7e9bb5213 100644 --- a/lib/spack/spack/test/views.py +++ b/lib/spack/spack/test/views.py @@ -4,12 +4,17 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os +import sys + +import pytest from spack.directory_layout import DirectoryLayout from spack.filesystem_view import YamlFilesystemView from spack.spec import Spec +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_global_activation(install_mockery, mock_fetch): """This test ensures that views which are maintained inside of an extendee package's prefix are maintained as expected and are compatible with @@ -31,6 +36,8 @@ def test_global_activation(install_mockery, mock_fetch): expected_path) +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_remove_extensions_ordered(install_mockery, mock_fetch, tmpdir): view_dir = str(tmpdir.join('view')) layout = DirectoryLayout(view_dir) diff --git a/lib/spack/spack/test/web.py b/lib/spack/spack/test/web.py index 8c4512c791..7d04d564ce 100644 --- a/lib/spack/spack/test/web.py +++ b/lib/spack/spack/test/web.py @@ -4,6 +4,8 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import collections import os +import posixpath +import sys import pytest @@ -17,8 +19,8 @@ def _create_url(relative_url): - web_data_path = os.path.join(spack.paths.test_path, 'data', 'web') - return 'file://' + os.path.join(web_data_path, relative_url) + web_data_path = posixpath.join(spack.paths.test_path, 'data', 'web') + return 'file://' + posixpath.join(web_data_path, relative_url) root = _create_url('index.html') @@ -29,6 +31,8 @@ def _create_url(relative_url): page_4 = _create_url('4.html') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") @pytest.mark.parametrize( 'depth,expected_found,expected_not_found,expected_text', [ (0, @@ -87,12 +91,16 @@ def test_spider_no_response(monkeypatch): assert not pages and not links +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_find_versions_of_archive_0(): versions = spack.util.web.find_versions_of_archive( root_tarball, root, list_depth=0) assert ver('0.0.0') in versions +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_find_versions_of_archive_1(): versions = spack.util.web.find_versions_of_archive( root_tarball, root, list_depth=1) @@ -100,6 +108,8 @@ def test_find_versions_of_archive_1(): assert ver('1.0.0') in versions +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_find_versions_of_archive_2(): versions = spack.util.web.find_versions_of_archive( root_tarball, root, list_depth=2) @@ -108,6 +118,8 @@ def test_find_versions_of_archive_2(): assert ver('2.0.0') in versions +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_find_exotic_versions_of_archive_2(): versions = spack.util.web.find_versions_of_archive( root_tarball, root, list_depth=2) @@ -115,6 +127,8 @@ def test_find_exotic_versions_of_archive_2(): assert ver('2.0.0b2') in versions +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_find_versions_of_archive_3(): versions = spack.util.web.find_versions_of_archive( root_tarball, root, list_depth=3) @@ -125,6 +139,8 @@ def test_find_versions_of_archive_3(): assert ver('4.5') in versions +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_find_exotic_versions_of_archive_3(): versions = spack.util.web.find_versions_of_archive( root_tarball, root, list_depth=3) @@ -174,6 +190,8 @@ def test_get_header(): spack.util.web.get_header(headers, 'ContentLength') +@pytest.mark.skipif(sys.platform == 'win32', + reason="Not supported on Windows (yet)") def test_list_url(tmpdir): testpath = str(tmpdir) diff --git a/lib/spack/spack/util/url.py b/lib/spack/spack/util/url.py index 046856aac1..34c387d57d 100644 --- a/lib/spack/spack/util/url.py +++ b/lib/spack/spack/util/url.py @@ -8,7 +8,8 @@ """ import itertools -import os.path +import ntpath +import posixpath import re import six.moves.urllib.parse as urllib_parse @@ -20,16 +21,16 @@ def _split_all(path): """Split path into its atomic components. - Returns the shortest list, L, of strings such that os.path.join(*L) == path - and os.path.split(element) == ('', element) for every element in L except - possibly the first. This first element may possibly have the value of '/', - or some other OS-dependent path root. + Returns the shortest list, L, of strings such that posixpath.join(*L) == + path and posixpath.split(element) == ('', element) for every element in L + except possibly the first. This first element may possibly have the value + of '/'. """ result = [] a = path old_a = None while a != old_a: - (old_a, (a, b)) = a, os.path.split(a) + (old_a, (a, b)) = a, posixpath.split(a) if a or b: result.insert(0, b or '/') @@ -47,7 +48,15 @@ def local_file_path(url): url = parse(url) if url.scheme == 'file': + is_windows_path = (len(url.netloc) == 2 and + url.netloc[1] == ':' and + 'A' <= url.netloc[0] and + url.netloc[0] <= 'Z') + if is_windows_path: + return ntpath.abspath(ntpath.join(url.netloc, '\\', url.path)) + return url.path + return None @@ -68,10 +77,48 @@ def parse(url, scheme='file'): (scheme, netloc, path, params, query, _) = url_obj scheme = (scheme or 'file').lower() + # This is the first way that a windows path can be parsed. + # (The user leaves out the file:// scheme.) + # examples: + # C:\\a\\b\\c + # X:/a/b/c + is_windows_path = (len(scheme) == 1 and 'a' <= scheme and scheme <= 'z') + if is_windows_path: + netloc = scheme.upper() + ':' + scheme = 'file' + if scheme == 'file': + # If the above windows path case did not hold, check the second case. + if not is_windows_path: + # This is the other way that a windows path can be parsed. + # (The user explicitly provides the file:// scheme.) + # examples: + # file://C:\\a\\b\\c + # file://X:/a/b/c + is_windows_path = (len(netloc) == 2 and + netloc[1] == ':' and + (('A' <= netloc[0] and netloc[0] <= 'Z') or + ('a' <= netloc[0] and netloc[0] <= 'z'))) + if is_windows_path: + netloc = netloc[0].upper() + ':' + path = spack.util.path.canonicalize_path(netloc + path) + path = re.sub(r'\\', '/', path) path = re.sub(r'^/+', '/', path) - netloc = '' + + if not is_windows_path: + netloc = '' + + # If canonicalize_path() returns a path with a drive letter (e.g.: on + # windows), we need to pop that part off from the head of the string. + # We also need to set netloc == that part to handle the case of a local + # file path being passed. (e.g.: file://../a/b/c) + update_netloc = (len(path) >= 2 and + path[1] == ':' and + (('A' <= path[0] and path[0] <= 'Z') or + ('a' <= path[0] and path[0] <= 'z'))) + if update_netloc: + netloc, path = path[:2], path[2:] return urllib_parse.ParseResult(scheme=scheme, netloc=netloc, @@ -97,13 +144,13 @@ def join(base_url, path, *extra, **kwargs): If resolve_href is True, treat the base URL as though it where the locator of a web page, and the remaining URL path components as though they formed - a relative URL to be resolved against it (i.e.: as in os.path.join(...)). + a relative URL to be resolved against it (i.e.: as in posixpath.join(...)). The result is an absolute URL to the resource to which a user's browser would navigate if they clicked on a link with an "href" attribute equal to the relative URL. If resolve_href is False (default), then the URL path components are joined - as in os.path.join(). + as in posixpath.join(). Note: file:// URL path components are not canonicalized as part of this operation. To canonicalize, pass the joined url to format(). @@ -192,7 +239,7 @@ def join(base_url, path, *extra, **kwargs): result = urllib_parse.ParseResult( scheme=result.scheme, netloc='', - path=os.path.abspath(result.netloc + result.path), + path=posixpath.abspath(result.netloc + result.path), params=result.params, query=result.query, fragment=None) @@ -227,11 +274,11 @@ def _join(base_url, path, *extra, **kwargs): base_path_args.append(base_path) if resolve_href: - new_base_path, _ = os.path.split(os.path.join(*base_path_args)) + new_base_path, _ = posixpath.split(posixpath.join(*base_path_args)) base_path_args = [new_base_path] base_path_args.extend(path_tokens) - base_path = os.path.relpath(os.path.join(*base_path_args), '/fake-root') + base_path = posixpath.relpath(posixpath.join(*base_path_args), '/fake-root') if scheme == 's3': path_tokens = [ @@ -240,7 +287,7 @@ def _join(base_url, path, *extra, **kwargs): if path_tokens: netloc = path_tokens.pop(0) - base_path = os.path.join('', *path_tokens) + base_path = posixpath.join('', *path_tokens) return format(urllib_parse.ParseResult(scheme=scheme, netloc=netloc, diff --git a/lib/spack/spack/util/web.py b/lib/spack/spack/util/web.py index 7786bed255..34f4c3b0c6 100644 --- a/lib/spack/spack/util/web.py +++ b/lib/spack/spack/util/web.py @@ -111,9 +111,14 @@ def read_from_url(url, accept_content_type=None): if not __UNABLE_TO_VERIFY_SSL: context = ssl._create_unverified_context() - req = Request(url_util.format(url)) + url_scheme = url.scheme + url = url_util.format(url) + if sys.platform == "win32" and url_scheme == "file": + url = url.replace("\\", "/") + req = Request(url) + content_type = None - is_web_url = url.scheme in ('http', 'https') + is_web_url = url_scheme in ('http', 'https') if accept_content_type and is_web_url: # Make a HEAD request first to check the content type. This lets # us ignore tarballs and gigantic files. @@ -144,7 +149,7 @@ def read_from_url(url, accept_content_type=None): if reject_content_type: tty.debug("ignoring page {0}{1}{2}".format( - url_util.format(url), + url, " with content type " if content_type is not None else "", content_type or ""))