executable: filter long paths from debug output (#25168)
Long, padded install paths can get to be very long in the verbose install output. This has to be filtered out by the Executable class, as it generates these debug messages. - [x] add ability to filter paths from Executable output. - [x] add a context manager that can enable path filtering - [x] make `build_process` in `installer.py` This should hopefully allow us to see most of the build output in Gitlab pipeline builds again.
This commit is contained in:
parent
e477101345
commit
fc840c904b
@ -54,6 +54,7 @@
|
||||
import spack.package_prefs as prefs
|
||||
import spack.repo
|
||||
import spack.store
|
||||
import spack.util.executable
|
||||
from spack.util.environment import dump_environment
|
||||
from spack.util.executable import which
|
||||
from spack.util.timer import Timer
|
||||
@ -1883,7 +1884,10 @@ def build_process(pkg, install_args):
|
||||
|
||||
"""
|
||||
installer = BuildProcessInstaller(pkg, install_args)
|
||||
return installer.run()
|
||||
|
||||
# don't print long padded paths in executable debug output.
|
||||
with spack.util.executable.filter_padding():
|
||||
return installer.run()
|
||||
|
||||
|
||||
class BuildTask(object):
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
import contextlib
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
@ -16,6 +17,27 @@
|
||||
|
||||
__all__ = ['Executable', 'which', 'ProcessError']
|
||||
|
||||
#: optionally filter padding on debug output in spack.util.executable
|
||||
_filter_padding = False
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def filter_padding():
|
||||
"""Context manager to safely disable path padding in debug output.
|
||||
|
||||
This is needed because Spack's debug output gets extremely long when we use a
|
||||
long padded installation path.
|
||||
"""
|
||||
global _filter_padding
|
||||
try:
|
||||
# don't bother filtering if padding isn't actually enabled
|
||||
padding = spack.config.get("config:install_tree:padded_length", None)
|
||||
if padding:
|
||||
_filter_padding = True
|
||||
yield
|
||||
finally:
|
||||
_filter_padding = False
|
||||
|
||||
|
||||
class Executable(object):
|
||||
"""Class representing a program that can be run on the command line."""
|
||||
@ -187,7 +209,10 @@ def streamify(arg, mode):
|
||||
cmd_line = "'%s'" % "' '".join(
|
||||
map(lambda arg: arg.replace("'", "'\"'\"'"), cmd))
|
||||
|
||||
tty.debug(cmd_line)
|
||||
debug_cmd_line = cmd_line
|
||||
if _filter_padding:
|
||||
debug_cmd_line = [spack.util.path.padding_filter(elt) for elt in cmd_line]
|
||||
tty.debug(debug_cmd_line)
|
||||
|
||||
try:
|
||||
proc = subprocess.Popen(
|
||||
|
Loading…
Reference in New Issue
Block a user