Isolate util/gpg
This commit is contained in:
parent
30cafc553a
commit
3fd543328b
@ -12,6 +12,7 @@
|
|||||||
import spack.bootstrap
|
import spack.bootstrap
|
||||||
import spack.util.executable
|
import spack.util.executable
|
||||||
import spack.util.gpg
|
import spack.util.gpg
|
||||||
|
import spack.paths
|
||||||
from spack.main import SpackCommand
|
from spack.main import SpackCommand
|
||||||
from spack.paths import mock_gpg_data_path, mock_gpg_keys_path
|
from spack.paths import mock_gpg_data_path, mock_gpg_keys_path
|
||||||
from spack.util.executable import ProcessError
|
from spack.util.executable import ProcessError
|
||||||
@ -46,9 +47,9 @@ def test_find_gpg(cmd_name, version, tmpdir, mock_gnupghome, monkeypatch):
|
|||||||
monkeypatch.setenv("PATH", str(tmpdir))
|
monkeypatch.setenv("PATH", str(tmpdir))
|
||||||
if version == "undetectable" or version.endswith("1.3.4"):
|
if version == "undetectable" or version.endswith("1.3.4"):
|
||||||
with pytest.raises(spack.util.gpg.SpackGPGError):
|
with pytest.raises(spack.util.gpg.SpackGPGError):
|
||||||
spack.util.gpg.init(force=True)
|
spack.util.gpg.init(force=True, gpg_path=spack.paths.gpg_path)
|
||||||
else:
|
else:
|
||||||
spack.util.gpg.init(force=True)
|
spack.util.gpg.init(force=True, gpg_path=spack.paths.gpg_path)
|
||||||
assert spack.util.gpg.GPG is not None
|
assert spack.util.gpg.GPG is not None
|
||||||
assert spack.util.gpg.GPGCONF is not None
|
assert spack.util.gpg.GPGCONF is not None
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ def test_no_gpg_in_path(tmpdir, mock_gnupghome, monkeypatch, mutable_config):
|
|||||||
monkeypatch.setenv("PATH", str(tmpdir))
|
monkeypatch.setenv("PATH", str(tmpdir))
|
||||||
bootstrap("disable")
|
bootstrap("disable")
|
||||||
with pytest.raises(RuntimeError):
|
with pytest.raises(RuntimeError):
|
||||||
spack.util.gpg.init(force=True)
|
spack.util.gpg.init(force=True, gpg_path=spack.paths.gpg_path)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.maybeslow
|
@pytest.mark.maybeslow
|
||||||
|
@ -1074,7 +1074,7 @@ def mock_gnupghome(monkeypatch):
|
|||||||
# This comes up because tmp paths on macOS are already long-ish, and
|
# This comes up because tmp paths on macOS are already long-ish, and
|
||||||
# pytest makes them longer.
|
# pytest makes them longer.
|
||||||
try:
|
try:
|
||||||
spack.util.gpg.init()
|
spack.util.gpg.init(gpg_path=spack.paths.gpg_path)
|
||||||
except spack.util.gpg.SpackGPGError:
|
except spack.util.gpg.SpackGPGError:
|
||||||
if not spack.util.gpg.GPG:
|
if not spack.util.gpg.GPG:
|
||||||
pytest.skip("This test requires gpg")
|
pytest.skip("This test requires gpg")
|
||||||
|
@ -7,12 +7,13 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import spack.paths
|
||||||
import spack.util.gpg
|
import spack.util.gpg
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def has_socket_dir():
|
def has_socket_dir():
|
||||||
spack.util.gpg.init()
|
spack.util.gpg.init(gpg_path=spack.paths.gpg_path)
|
||||||
return bool(spack.util.gpg.SOCKET_DIR)
|
return bool(spack.util.gpg.SOCKET_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import spack.error
|
import spack.util.error
|
||||||
import spack.paths
|
|
||||||
import spack.util.executable
|
import spack.util.executable
|
||||||
import spack.version
|
import spack.version
|
||||||
|
|
||||||
@ -29,7 +28,7 @@ def clear():
|
|||||||
GPG, GPGCONF, SOCKET_DIR, GNUPGHOME = None, None, None, None
|
GPG, GPGCONF, SOCKET_DIR, GNUPGHOME = None, None, None, None
|
||||||
|
|
||||||
|
|
||||||
def init(gnupghome=None, force=False):
|
def init(gnupghome=None, force=False, gpg_path=None):
|
||||||
"""Initialize the global objects in the module, if not set.
|
"""Initialize the global objects in the module, if not set.
|
||||||
|
|
||||||
When calling any gpg executable, the GNUPGHOME environment
|
When calling any gpg executable, the GNUPGHOME environment
|
||||||
@ -56,7 +55,7 @@ def init(gnupghome=None, force=False):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Set the value of GNUPGHOME to be used in this module
|
# Set the value of GNUPGHOME to be used in this module
|
||||||
GNUPGHOME = gnupghome or os.getenv("SPACK_GNUPGHOME") or spack.paths.gpg_path
|
GNUPGHOME = gnupghome or os.getenv("SPACK_GNUPGHOME") or gpg_path
|
||||||
|
|
||||||
# Set the executable objects for "gpg" and "gpgconf"
|
# Set the executable objects for "gpg" and "gpgconf"
|
||||||
with spack.bootstrap.ensure_bootstrap_configuration():
|
with spack.bootstrap.ensure_bootstrap_configuration():
|
||||||
@ -165,7 +164,7 @@ def _get_unimported_public_keys(output):
|
|||||||
return keys
|
return keys
|
||||||
|
|
||||||
|
|
||||||
class SpackGPGError(spack.error.SpackError):
|
class SpackGPGError(spack.util.error.UtilityError):
|
||||||
"""Class raised when GPG errors are detected."""
|
"""Class raised when GPG errors are detected."""
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user