Isolate util/lock and util/naming

This commit is contained in:
Douglas Jacobsen 2023-10-30 11:52:40 -06:00
parent 3fd543328b
commit 1d07e4cb8d
3 changed files with 9 additions and 9 deletions

View File

@ -12,6 +12,7 @@
import spack.config
import spack.util.lock as lk
import spack.util.error
def test_disable_locking(tmpdir):
@ -54,7 +55,7 @@ def test_lock_checks_user(tmpdir):
# unsafe
tmpdir.chmod(0o777)
with pytest.raises(spack.error.SpackError):
with pytest.raises(spack.util.error.UtilityError):
lk.check_lock_safety(path)
# safe
@ -85,12 +86,12 @@ def test_lock_checks_group(tmpdir):
# unsafe
tmpdir.chmod(0o774)
with pytest.raises(spack.error.SpackError):
with pytest.raises(spack.util.error.UtilityError):
lk.check_lock_safety(path)
# unsafe
tmpdir.chmod(0o777)
with pytest.raises(spack.error.SpackError):
with pytest.raises(spack.util.error.UtilityError):
lk.check_lock_safety(path)
# safe

View File

@ -18,8 +18,7 @@
from llnl.util.lock import ReadTransaction # noqa: F401
from llnl.util.lock import WriteTransaction # noqa: F401
import spack.error
import spack.paths
import spack.util.error
class Lock(llnl.util.lock.Lock):
@ -100,4 +99,4 @@ def check_lock_safety(path: str) -> None:
f"Running a shared spack without locks is unsafe. You must "
f"restrict permissions on {path} or enable locks."
)
raise spack.error.SpackError(msg, long_msg)
raise spack.util.error.UtilityError(msg, long_msg)

View File

@ -8,7 +8,7 @@
import re
import string
import spack.error
import spack.util.error
__all__ = [
"mod_to_class",
@ -159,7 +159,7 @@ def validate_fully_qualified_module_name(mod_name):
raise InvalidFullyQualifiedModuleNameError(mod_name)
class InvalidModuleNameError(spack.error.SpackError):
class InvalidModuleNameError(spack.util.error.UtilityError):
"""Raised when we encounter a bad module name."""
def __init__(self, name):
@ -167,7 +167,7 @@ def __init__(self, name):
self.name = name
class InvalidFullyQualifiedModuleNameError(spack.error.SpackError):
class InvalidFullyQualifiedModuleNameError(spack.util.error.UtilityError):
"""Raised when we encounter a bad full package name."""
def __init__(self, name):