mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-26 12:22:15 +00:00
fix(xcat-probe): a terminal tput cannot measure erases every checkpoint message
xcatprobe asks 'tput cols' for the screen width whenever TERM is set. The GitHub Actions container sets TERM=unknown, terminfo carries no such terminal, and tput writes nothing. The width became 0 and the layout cut every checkpoint message to the empty string, so the probe printed a column of bare [ OK ], [WARN] and [FAIL] marks with no text beside them. xcatprobe_xcatmn_selinux failed on that output. It asserts that the SELinux checkpoint reports [ OK ], and no checkpoint text reached the log. The rest of the probe diagnostics were unreadable for the same reason, so the one [FAIL] in the run named no checkpoint. probe_format::screen_width keeps the 80 column default when 'tput cols' gives no usable number. probe_xcatmn_selinux_case.t renders the checkpoint at that width and three of its assertions fail without this change. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,7 @@ my $FLAG_WIDTH = 6;
|
||||
Arguments:
|
||||
raw: the output of 'tput cols', or undef when there is no terminal
|
||||
Returns:
|
||||
the column count
|
||||
the column count, always more than the flag width
|
||||
|
||||
=cut
|
||||
|
||||
@@ -25,8 +25,12 @@ my $FLAG_WIDTH = 6;
|
||||
sub screen_width {
|
||||
my ($raw) = @_;
|
||||
|
||||
return $DEFAULT_WIDTH unless (defined($raw));
|
||||
return $raw =~ /(\d+)/ ? $1 + 0 : 0;
|
||||
# 'tput cols' writes nothing when TERM names a terminal terminfo does not
|
||||
# carry, and the GitHub Actions container sets TERM=unknown. A width of 0
|
||||
# cuts every checkpoint message down to the empty string.
|
||||
return $DEFAULT_WIDTH unless (defined($raw) && $raw =~ /(\d+)/);
|
||||
my $cols = $1 + 0;
|
||||
return $cols > $FLAG_WIDTH ? $cols : $DEFAULT_WIDTH;
|
||||
}
|
||||
|
||||
#-----------------------------------
|
||||
|
||||
Reference in New Issue
Block a user