diff options
author | Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> | 2021-10-06 12:03:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-06 21:03:33 +0200 |
commit | affd2236e6f48e693eb5cbbf50baf2a9b413d7e7 (patch) | |
tree | 862fe71a494402ae8996ed154ad08824c24db5c0 /lib | |
parent | cb5b28392edddf72b3e7575a584e3fc3faf28539 (diff) | |
download | spack-affd2236e6f48e693eb5cbbf50baf2a9b413d7e7.tar.gz spack-affd2236e6f48e693eb5cbbf50baf2a9b413d7e7.tar.bz2 spack-affd2236e6f48e693eb5cbbf50baf2a9b413d7e7.tar.xz spack-affd2236e6f48e693eb5cbbf50baf2a9b413d7e7.zip |
Provide more info in `SbangPathError` to aid CI debugging (#26316)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/hooks/sbang.py | 9 | ||||
-rw-r--r-- | lib/spack/spack/test/sbang.py | 18 |
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/spack/spack/hooks/sbang.py b/lib/spack/spack/hooks/sbang.py index 7eff565618..33aa29691f 100644 --- a/lib/spack/spack/hooks/sbang.py +++ b/lib/spack/spack/hooks/sbang.py @@ -28,9 +28,12 @@ def sbang_install_path(): """Location sbang should be installed within Spack's ``install_tree``.""" sbang_root = str(spack.store.unpadded_root) install_path = os.path.join(sbang_root, "bin", "sbang") - if len(install_path) > shebang_limit: - raise SbangPathError( - 'Install tree root is too long. Spack cannot patch shebang lines.') + path_length = len(install_path) + if path_length > shebang_limit: + 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 diff --git a/lib/spack/spack/test/sbang.py b/lib/spack/spack/test/sbang.py index 57ae2ba0f6..e0d7a8ccf3 100644 --- a/lib/spack/spack/test/sbang.py +++ b/lib/spack/spack/test/sbang.py @@ -225,3 +225,21 @@ def test_install_sbang(install_mockery): # install again and make sure sbang is still fine sbang.install_sbang() 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 |