diff options
author | Jordan Galby <67924449+Jordan474@users.noreply.github.com> | 2022-11-08 03:58:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-08 02:58:19 +0000 |
commit | 84a3d32aa36f8af902ef67a58ce1944050bd7e1d (patch) | |
tree | 6760a6f841fe623fb022501d69de32f9b7036ddf /lib | |
parent | 69d4637671f50d1224de02aa278ab721a438c98f (diff) | |
download | spack-84a3d32aa36f8af902ef67a58ce1944050bd7e1d.tar.gz spack-84a3d32aa36f8af902ef67a58ce1944050bd7e1d.tar.bz2 spack-84a3d32aa36f8af902ef67a58ce1944050bd7e1d.tar.xz spack-84a3d32aa36f8af902ef67a58ce1944050bd7e1d.zip |
Fix missing "*.spack*" files in views (#30980)
All files/dirs containing ".spack" anywhere their name were ignored when
generating a spack view.
For example, this happened with the 'r' package.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/directory_layout.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/view.py | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py index 28f3caab9e..b5848f12a7 100644 --- a/lib/spack/spack/directory_layout.py +++ b/lib/spack/spack/directory_layout.py @@ -102,7 +102,7 @@ class DirectoryLayout(object): @property def hidden_file_regexes(self): - return (re.escape(self.metadata_dir),) + return ("^{0}$".format(re.escape(self.metadata_dir)),) def relative_path_for_spec(self, spec): _check_concrete(spec) diff --git a/lib/spack/spack/test/cmd/view.py b/lib/spack/spack/test/cmd/view.py index 51af2bae2a..67c4275ddd 100644 --- a/lib/spack/spack/test/cmd/view.py +++ b/lib/spack/spack/test/cmd/view.py @@ -10,6 +10,7 @@ import pytest import spack.util.spack_yaml as s_yaml from spack.main import SpackCommand +from spack.spec import Spec activate = SpackCommand("activate") extensions = SpackCommand("extensions") @@ -261,3 +262,34 @@ def test_view_fails_with_missing_projections_file(tmpdir): projection_file = os.path.join(str(tmpdir), "nonexistent") with pytest.raises(SystemExit): view("symlink", "--projection-file", projection_file, viewpath, "foo") + + +@pytest.mark.parametrize("with_projection", [False, True]) +@pytest.mark.parametrize("cmd", ["symlink", "copy"]) +def test_view_files_not_ignored( + tmpdir, mock_packages, mock_archive, mock_fetch, config, install_mockery, cmd, with_projection +): + spec = Spec("view-not-ignored").concretized() + pkg = spec.package + pkg.do_install() + pkg.assert_installed(spec.prefix) + + install("view-dir-file") # Arbitrary package to add noise + + viewpath = str(tmpdir.mkdir("view_{0}".format(cmd))) + + if with_projection: + proj = str(tmpdir.join("proj.yaml")) + with open(proj, "w") as f: + f.write('{"projections":{"all":"{name}"}}') + prefix_in_view = os.path.join(viewpath, "view-not-ignored") + args = ["--projection-file", proj] + else: + prefix_in_view = viewpath + args = [] + + view(cmd, *(args + [viewpath, "view-not-ignored", "view-dir-file"])) + pkg.assert_installed(prefix_in_view) + + view("remove", viewpath, "view-not-ignored") + pkg.assert_not_installed(prefix_in_view) |