Esempio n. 1
0
def test_load_installed_package_not_in_repo(install_mockery, mock_fetch,
                                            monkeypatch):
    # Get a basic concrete spec for the trivial install package.
    spec = Spec('trivial-install-test-package')
    spec.concretize()
    assert spec.concrete

    # Get the package
    pkg = spec.package

    def find_nothing(*args):
        raise spack.repo.UnknownPackageError(
            'Repo package access is disabled for test')

    try:
        pkg.do_install()

        spec._package = None
        monkeypatch.setattr(spack.repo, 'get', find_nothing)
        with pytest.raises(spack.repo.UnknownPackageError):
            spec.package

        module_path = spack.modules.common.get_module('tcl', spec, True)
        assert module_path
        pkg.do_uninstall()
    except Exception:
        pkg.remove_prefix()
        raise
Esempio n. 2
0
def test_uninstall_non_existing_package(install_mockery, mock_fetch, monkeypatch):
    """Ensure that we can uninstall a package that has been deleted from the repo"""
    spec = Spec('trivial-install-test-package').concretized()

    spec.package.do_install()
    assert spec.installed

    # Mock deletion of the package
    spec._package = None
    monkeypatch.setattr(spack.repo.path, 'get', find_nothing)
    with pytest.raises(spack.repo.UnknownPackageError):
        spec.package

    # Ensure we can uninstall it
    PackageBase.uninstall_by_spec(spec)
    assert not spec.installed
Esempio n. 3
0
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')
    spec.concretize()
    assert spec.concrete

    # Get the package
    pkg = spec.package
    try:
        pkg.do_install()

        spec._package = None
        monkeypatch.setattr(spack.repo, 'get', find_nothing)
        with pytest.raises(spack.repo.UnknownPackageError):
            spec.package

        pkg.do_uninstall()
    except Exception:
        pkg.remove_prefix()
        raise
Esempio n. 4
0
def test_load_installed_package_not_in_repo(
        install_mockery, mock_fetch, monkeypatch
):
    """Test that installed packages that have been removed are still loadable"""
    spec = Spec('trivial-install-test-package').concretized()
    spec.package.do_install()

    def find_nothing(*args):
        raise spack.repo.UnknownPackageError(
            'Repo package access is disabled for test')

    # Mock deletion of the package
    spec._package = None
    monkeypatch.setattr(spack.repo.path, 'get', find_nothing)
    with pytest.raises(spack.repo.UnknownPackageError):
        spec.package

    module_path = spack.modules.common.get_module('tcl', spec, True)
    assert module_path

    spack.package_base.PackageBase.uninstall_by_spec(spec)