Provide more info in SbangPathError
to aid CI debugging (#26316)
This commit is contained in:
parent
cb5b28392e
commit
affd2236e6
@ -28,9 +28,12 @@ def sbang_install_path():
|
|||||||
"""Location sbang should be installed within Spack's ``install_tree``."""
|
"""Location sbang should be installed within Spack's ``install_tree``."""
|
||||||
sbang_root = str(spack.store.unpadded_root)
|
sbang_root = str(spack.store.unpadded_root)
|
||||||
install_path = os.path.join(sbang_root, "bin", "sbang")
|
install_path = os.path.join(sbang_root, "bin", "sbang")
|
||||||
if len(install_path) > shebang_limit:
|
path_length = len(install_path)
|
||||||
raise SbangPathError(
|
if path_length > shebang_limit:
|
||||||
'Install tree root is too long. Spack cannot patch shebang lines.')
|
msg = ('Install tree root is too long. Spack cannot patch shebang lines'
|
||||||
|
' when script path length ({0}) exceeds limit ({1}).\n {2}')
|
||||||
|
msg = msg.format(path_length, shebang_limit, install_path)
|
||||||
|
raise SbangPathError(msg)
|
||||||
return install_path
|
return install_path
|
||||||
|
|
||||||
|
|
||||||
|
@ -225,3 +225,21 @@ def test_install_sbang(install_mockery):
|
|||||||
# install again and make sure sbang is still fine
|
# install again and make sure sbang is still fine
|
||||||
sbang.install_sbang()
|
sbang.install_sbang()
|
||||||
check_sbang_installation()
|
check_sbang_installation()
|
||||||
|
|
||||||
|
|
||||||
|
def test_install_sbang_too_long(tmpdir):
|
||||||
|
root = str(tmpdir)
|
||||||
|
num_extend = sbang.shebang_limit - len(root) - len('/bin/sbang')
|
||||||
|
long_path = root
|
||||||
|
while num_extend > 1:
|
||||||
|
add = min(num_extend, 255)
|
||||||
|
long_path = os.path.join(long_path, 'e' * add)
|
||||||
|
num_extend -= add
|
||||||
|
with spack.store.use_store(spack.store.Store(long_path)):
|
||||||
|
with pytest.raises(sbang.SbangPathError) as exc_info:
|
||||||
|
sbang.sbang_install_path()
|
||||||
|
|
||||||
|
err = str(exc_info.value)
|
||||||
|
assert 'root is too long' in err
|
||||||
|
assert 'exceeds limit' in err
|
||||||
|
assert 'cannot patch' in err
|
||||||
|
Loading…
Reference in New Issue
Block a user