diff options
-rw-r--r-- | lib/spack/spack/test/cmd/pkg.py | 3 | ||||
-rw-r--r-- | lib/spack/spack/test/conftest.py | 13 | ||||
-rw-r--r-- | lib/spack/spack/test/data/config/config.yaml | 5 | ||||
-rw-r--r-- | lib/spack/spack/test/data/config/modules.yaml | 3 | ||||
-rw-r--r-- | lib/spack/spack/test/modules/common.py | 14 | ||||
-rw-r--r-- | lib/spack/spack/test/modules/conftest.py | 14 | ||||
-rw-r--r-- | lib/spack/spack/test/modules/tcl.py | 10 |
7 files changed, 39 insertions, 23 deletions
diff --git a/lib/spack/spack/test/cmd/pkg.py b/lib/spack/spack/test/cmd/pkg.py index 352ffca4ac..b868c62c66 100644 --- a/lib/spack/spack/test/cmd/pkg.py +++ b/lib/spack/spack/test/cmd/pkg.py @@ -54,7 +54,8 @@ def mock_pkg_git_repo(tmpdir_factory): git('init') # initial commit with mock packages - git('add', '.') + # the -f is necessary in case people ignore build-* in their ignores + git('add', '-f', '.') git('config', 'user.email', 'testing@spack.io') git('config', 'user.name', 'Spack Testing') git('-c', 'commit.gpgsign=false', 'commit', diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 11a24ba044..a10ccc7f0f 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -1335,7 +1335,16 @@ def mock_git_repository(tmpdir_factory): tag = 'test-tag' git('tag', tag) - git('checkout', 'master') + try: + default_branch = git( + 'config', + '--get', + 'init.defaultBranch', + output=str, + ).strip() + except Exception: + default_branch = 'master' + git('checkout', default_branch) r2_file = 'r2_file' repodir.ensure(r2_file) @@ -1357,7 +1366,7 @@ def mock_git_repository(tmpdir_factory): # that revision/branch. checks = { 'master': Bunch( - revision='master', file=r0_file, args={'git': url} + revision=default_branch, file=r0_file, args={'git': url} ), 'branch': Bunch( revision=branch, file=branch_file, args={ diff --git a/lib/spack/spack/test/data/config/config.yaml b/lib/spack/spack/test/data/config/config.yaml index 43e8ad1abc..0ae86957db 100644 --- a/lib/spack/spack/test/data/config/config.yaml +++ b/lib/spack/spack/test/data/config/config.yaml @@ -7,9 +7,8 @@ config: - $spack/lib/spack/spack/test/data/templates_again build_stage: - $tempdir/$user/spack-stage - - ~/.spack/stage - source_cache: $spack/var/spack/cache - misc_cache: ~/.spack/cache + source_cache: $user_cache_path/source + misc_cache: $user_cache_path/cache verify_ssl: true checksum: true dirty: false diff --git a/lib/spack/spack/test/data/config/modules.yaml b/lib/spack/spack/test/data/config/modules.yaml index e2ddd841c5..28e2ec91b3 100644 --- a/lib/spack/spack/test/data/config/modules.yaml +++ b/lib/spack/spack/test/data/config/modules.yaml @@ -17,6 +17,9 @@ modules: default: enable: - tcl + roots: + tcl: $user_cache_path/tcl + lmod: $user_cache_path/lmod prefix_inspections: bin: - PATH diff --git a/lib/spack/spack/test/modules/common.py b/lib/spack/spack/test/modules/common.py index 39619ce741..9eff0c23cc 100644 --- a/lib/spack/spack/test/modules/common.py +++ b/lib/spack/spack/test/modules/common.py @@ -46,20 +46,6 @@ def test_update_dictionary_extending_list(): @pytest.fixture() -def mock_module_filename(monkeypatch, tmpdir): - filename = str(tmpdir.join('module')) - # Set for both module types so we can test both - monkeypatch.setattr(spack.modules.lmod.LmodFileLayout, - 'filename', - filename) - monkeypatch.setattr(spack.modules.tcl.TclFileLayout, - 'filename', - filename) - - yield filename - - -@pytest.fixture() def mock_module_defaults(monkeypatch): def impl(*args): # No need to patch both types because neither override base diff --git a/lib/spack/spack/test/modules/conftest.py b/lib/spack/spack/test/modules/conftest.py index 04e28f5f53..61fe4add0a 100644 --- a/lib/spack/spack/test/modules/conftest.py +++ b/lib/spack/spack/test/modules/conftest.py @@ -62,3 +62,17 @@ def factory(request): return writer_cls(spec, module_set_name), spec return _mock + + +@pytest.fixture() +def mock_module_filename(monkeypatch, tmpdir): + filename = str(tmpdir.join('module')) + # Set for both module types so we can test both + monkeypatch.setattr(spack.modules.lmod.LmodFileLayout, + 'filename', + filename) + monkeypatch.setattr(spack.modules.tcl.TclFileLayout, + 'filename', + filename) + + yield filename diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py index d9e4ad17bd..a8be4e87b6 100644 --- a/lib/spack/spack/test/modules/tcl.py +++ b/lib/spack/spack/test/modules/tcl.py @@ -22,7 +22,7 @@ pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows") -@pytest.mark.usefixtures('config', 'mock_packages') +@pytest.mark.usefixtures('config', 'mock_packages', 'mock_module_filename') class TestTcl(object): def test_simple_case(self, modulefile_content, module_configuration): @@ -199,7 +199,9 @@ class TestTcl(object): projection = writer.spec.format(writer.conf.projections['all']) assert projection in writer.layout.use_name - def test_invalid_naming_scheme(self, factory, module_configuration): + def test_invalid_naming_scheme( + self, factory, module_configuration, mock_module_filename + ): """Tests the evaluation of an invalid naming scheme.""" module_configuration('invalid_naming_scheme') @@ -210,7 +212,9 @@ class TestTcl(object): with pytest.raises(RuntimeError): writer.layout.use_name - def test_invalid_token_in_env_name(self, factory, module_configuration): + def test_invalid_token_in_env_name( + self, factory, module_configuration, mock_module_filename + ): """Tests setting environment variables with an invalid name.""" module_configuration('invalid_token_in_env_var_name') |