diff --git a/lib/spack/spack/test/cmd/view.py b/lib/spack/spack/test/cmd/view.py index 26fc019deb..b4f3275172 100644 --- a/lib/spack/spack/test/cmd/view.py +++ b/lib/spack/spack/test/cmd/view.py @@ -23,6 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack.main import SpackCommand +import os.path activate = SpackCommand('activate') extensions = SpackCommand('extensions') @@ -62,6 +63,26 @@ def test_view_extension( assert 'extension1@1.0' in view_activated assert 'extension1@2.0' not in view_activated assert 'extension2@1.0' not in view_activated + assert os.path.exists(os.path.join(viewpath, 'bin', 'extension1')) + + +def test_view_extension_remove( + tmpdir, builtin_mock, mock_archive, mock_fetch, config, + install_mockery): + install('extendee') + install('extension1@1.0') + viewpath = str(tmpdir.mkdir('view')) + view('symlink', viewpath, 'extension1@1.0') + view('remove', viewpath, 'extension1@1.0') + all_installed = extensions('--show', 'installed', 'extendee') + assert 'extension1@1.0' in all_installed + global_activated = extensions('--show', 'activated', 'extendee') + assert 'extension1@1.0' not in global_activated + view_activated = extensions('--show', 'activated', + '-v', viewpath, + 'extendee') + assert 'extension1@1.0' not in view_activated + assert not os.path.exists(os.path.join(viewpath, 'bin', 'extension1')) def test_view_extension_global_activation( @@ -89,6 +110,8 @@ def test_view_extension_global_activation( assert 'extension1@1.0' in view_activated assert 'extension1@2.0' not in view_activated assert 'extension2@1.0' not in view_activated + assert os.path.exists(os.path.join(viewpath, 'bin', 'extension1')) + assert not os.path.exists(os.path.join(viewpath, 'bin', 'extension2')) def test_view_extendee_with_global_activations( diff --git a/var/spack/repos/builtin.mock/packages/extension1/package.py b/var/spack/repos/builtin.mock/packages/extension1/package.py index 6a1e600ba9..c9837bde90 100644 --- a/var/spack/repos/builtin.mock/packages/extension1/package.py +++ b/var/spack/repos/builtin.mock/packages/extension1/package.py @@ -23,6 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * +import os.path class Extension1(Package): @@ -38,3 +39,5 @@ class Extension1(Package): def install(self, spec, prefix): mkdirp(prefix.bin) + with open(os.path.join(prefix.bin, 'extension1'), 'w+'): + pass diff --git a/var/spack/repos/builtin.mock/packages/extension2/package.py b/var/spack/repos/builtin.mock/packages/extension2/package.py index 55a9d8baca..5616d4c3ca 100644 --- a/var/spack/repos/builtin.mock/packages/extension2/package.py +++ b/var/spack/repos/builtin.mock/packages/extension2/package.py @@ -23,6 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * +import os.path class Extension2(Package): @@ -39,3 +40,5 @@ class Extension2(Package): def install(self, spec, prefix): mkdirp(prefix.bin) + with open(os.path.join(prefix.bin, 'extension2'), 'w+'): + pass