From patchwork Wed Nov 9 16:58:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13037798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BC64C433FE for ; Wed, 9 Nov 2022 17:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231586AbiKIRBn (ORCPT ); Wed, 9 Nov 2022 12:01:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230005AbiKIRAz (ORCPT ); Wed, 9 Nov 2022 12:00:55 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9EEE13EB8 for ; Wed, 9 Nov 2022 08:58:41 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id g12so26651316wrs.10 for ; Wed, 09 Nov 2022 08:58:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Sxjw4FZind5IBeKVQ8WS0RO5VP8SsMIjVtapS56zweM=; b=hwMGRlR5zCf38YrMnfZRGnk7e6rGxxEKpWHeMRhzhm5eQebMkhxK2U9ahuPAMcBQcS ofEsYJ1QOyhQERVqquw9MS3xBJTFyqrWr4jf2Nxr2VOItf5zoQtKsYlU4vpEBuAU4zvK D/pkVax9FB601UADH8hSOnmyiZGA0plVD5qqEvPbkNdIO2noFuxg9vUETh2nonHGZK7c 49Bxj9AklhWN/PwdtL5B7sfkT6h1oVTZVpLgEWVfS2MWU3hIrSiJB4F61k9rYq7aM0MN 7DuSW2h9m2IgzsGKoXuAVfGCSvi0txGh+rWG29sBPJjn2A4FLaeKz49nWCuFcoQGGc5x zAWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sxjw4FZind5IBeKVQ8WS0RO5VP8SsMIjVtapS56zweM=; b=gphgB/Hx8lXYqUwpVabXhvRPHPOpVp5BH26qirG8C+UF4pnZavqTC1ItkxHVDRJnGQ qz8GvI82X3uv/xWhK+PJXK9fuB+A3sQJPWFYJBDop17wCRghb2usO7torAc1lw3Z5Zis 8WcSEFkm2K52YoArKDTbp1ilQHPQsqJoWttBwD5p9Do4EPsS2FiQCGPYGTqQL3aoDATJ HGWvXRsCwWaBynUbVwEBFxqpDqfPQ6eTS5N9UxilS/L7ePezI5Ps8ua/FKMxn5eQ2LyP EJ2QUNDEYBE5OVvoOA9WfduET15tVIZOZJVy5k78LL0g5cdutLZMx0aAAeFxTMQt4/hJ B8cQ== X-Gm-Message-State: ACrzQf3Uvuws2zzb0/lVsvDPO/Fy2xQRjhGSVig+idc6Mprt8Z4E9yB/ EkYhlHMa6kbrjOkLoqv175mO8FG5As0= X-Google-Smtp-Source: AMsMyM4/ySEgAHrsKWWG88wKzkyvxMrsBfQ9JrTqCf9e+joguqE0hWGuJim5m+ssvTkvcB0qT5KiNw== X-Received: by 2002:adf:f10e:0:b0:239:6cea:a4ff with SMTP id r14-20020adff10e000000b002396ceaa4ffmr21960099wro.36.1668013120075; Wed, 09 Nov 2022 08:58:40 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m189-20020a1c26c6000000b003c6edc05159sm2099946wmm.1.2022.11.09.08.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 08:58:37 -0800 (PST) Message-Id: In-Reply-To: References: Date: Wed, 09 Nov 2022 16:58:32 +0000 Subject: [PATCH 1/3] chainlint: sidestep impoverished macOS "terminfo" Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Eric Sunshine , Eric Sunshine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Eric Sunshine From: Eric Sunshine Although the macOS Terminal.app is "xterm"-compatible, its corresponding "terminfo" entry neglects to mention capabilities which Terminal.app actually supports (such as "dim text"). This oversight on Apple's part ends up penalizing users of "good citizen" console programs which consult "terminfo" to tailor their output based upon reported terminal capabilities (as opposed to programs which assume that the terminal supports ANSI codes). Sidestep this Apple problem by imbuing get_colors() with specific knowledge of "xterm" capabilities rather than trusting "terminfo" to report them correctly. Although hard-coding such knowledge is ugly, "xterm" support is nearly ubiquitous these days, and Git itself sets precedence by assuming support for ANSI color codes. For non-"xterm", fall back to querying "terminfo" via `tput` as usual. Signed-off-by: Eric Sunshine --- t/chainlint.pl | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/t/chainlint.pl b/t/chainlint.pl index 7972c5bbe6f..fcf4d459249 100755 --- a/t/chainlint.pl +++ b/t/chainlint.pl @@ -653,21 +653,32 @@ my @NOCOLORS = (bold => '', rev => '', reset => '', blue => '', green => '', red my %COLORS = (); sub get_colors { return \%COLORS if %COLORS; - if (exists($ENV{NO_COLOR}) || - system("tput sgr0 >/dev/null 2>&1") != 0 || - system("tput bold >/dev/null 2>&1") != 0 || - system("tput rev >/dev/null 2>&1") != 0 || - system("tput setaf 1 >/dev/null 2>&1") != 0) { + if (exists($ENV{NO_COLOR})) { %COLORS = @NOCOLORS; return \%COLORS; } - %COLORS = (bold => `tput bold`, - rev => `tput rev`, - reset => `tput sgr0`, - blue => `tput setaf 4`, - green => `tput setaf 2`, - red => `tput setaf 1`); - chomp(%COLORS); + if ($ENV{TERM} =~ /\bxterm\b/) { + %COLORS = (bold => "\e[1m", + rev => "\e[7m", + reset => "\e[0m", + blue => "\e[34m", + green => "\e[32m", + red => "\e[31m"); + return \%COLORS; + } + if (system("tput sgr0 >/dev/null 2>&1") == 0 && + system("tput bold >/dev/null 2>&1") == 0 && + system("tput rev >/dev/null 2>&1") == 0 && + system("tput setaf 1 >/dev/null 2>&1") == 0) { + %COLORS = (bold => `tput bold`, + rev => `tput rev`, + reset => `tput sgr0`, + blue => `tput setaf 4`, + green => `tput setaf 2`, + red => `tput setaf 1`); + return \%COLORS; + } + %COLORS = @NOCOLORS; return \%COLORS; } From patchwork Wed Nov 9 16:58:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13037799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67F12C4332F for ; Wed, 9 Nov 2022 17:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230423AbiKIRBo (ORCPT ); Wed, 9 Nov 2022 12:01:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231597AbiKIRAz (ORCPT ); Wed, 9 Nov 2022 12:00:55 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1333913CFB for ; Wed, 9 Nov 2022 08:58:44 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id h9so26758224wrt.0 for ; Wed, 09 Nov 2022 08:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=2Jzh+0MPxBQhnbGSanUWM0t/1IOrgMetYazY8mp6q3w=; b=E5ZyBEibEM100itBXkyUqVma7BiVhVPkLdq6zAWx2LONqj+n6U1BXbsIfkKYrbkwL6 iIXKPlU9b/17Yey2u5C9C6DkTrbHlVa46X9wpe4wUShKPf+QwL1hVgLDpqxwO87Ep8Ps HdJUaN0aapEn5GcDfQ2IGeLQaS0hbtWBQulyn5jobTRgKQbN8oOo2f/jE+s1ZnWeQoxd Gcoe9iCwEQJJmfq50V3k4psSy1vQaI2VSMt7ZGexVwxODezjLdX9lxfa+oahuHQWpFTk +DaqHrcRvNF1kM7lok+lBbpjLCVPd8xDStDzjRAzETe+9ZfrdIqW8E8k5UkfsucHefkf EbNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Jzh+0MPxBQhnbGSanUWM0t/1IOrgMetYazY8mp6q3w=; b=6/JDUX+3E3bo6QefaFBhraetk1oxD02YkmFchnb9G3sHDyCAHixBCw3r4OQ7MsWOt3 xpQoX/r9KR7FgKNWKoToBdqfRnwa3sYs3Nq4EvBDrJ0sfJUjaiK9DiyvMZ0GW6Y4A3C1 E/1iOPm/ffIc1d4ZJWdjmBURX97AgVinkOzFmUlmI4DaCv5VQA3JNDSM7flftXDoctcU RvMcrS22LAMDBtv/WS9l7E8tB+qTuQclDel8I/glaZ0T1PqJw2dia+3i6fUi4hddrUwM lMpIrS5ysXhk6zKy3oFMTmFR/+gFWH3fmkOBeDYdKDxLEiO7clITNjs1YXsqqa7n40yf Z/Jg== X-Gm-Message-State: ACrzQf1qmsJ/YMTk94BOpX288mSAcFtpp5V2BCYOcGWHB2oUH/fX/0S0 v1M45MMvrSNoI8pOGFLI3xvxUL6GX6M= X-Google-Smtp-Source: AMsMyM5m1heuNwE9eaA9fnBReWuvhTagbKAqoBWboyUoMlF2n27099EghbfOnQrqFfW99N3XRpLqAA== X-Received: by 2002:a5d:5004:0:b0:236:c92e:5b41 with SMTP id e4-20020a5d5004000000b00236c92e5b41mr36253612wrt.655.1668013122362; Wed, 09 Nov 2022 08:58:42 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t17-20020a05600c199100b003b4fdbb6319sm2307279wmq.21.2022.11.09.08.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 08:58:41 -0800 (PST) Message-Id: In-Reply-To: References: Date: Wed, 09 Nov 2022 16:58:33 +0000 Subject: [PATCH 2/3] chainlint: latch line numbers at which each token starts and ends Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Eric Sunshine , Eric Sunshine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Eric Sunshine From: Eric Sunshine When chainlint detects problems in a test, it prints out the name of the test script, the name of the problematic test, and a copy of the test definition with "?!FOO?!" annotations inserted at the locations where problems were detected. Taken together this information is sufficient for the test author to identify the problematic code in the original test definition. However, in a lengthy script or a lengthy test definition, the author may still end up using the editor's search feature to home in on the exact problem location. To further assist the test author, an upcoming change will display line numbers along with the annotated test definition, thus allowing the author to jump directly to each problematic line. As preparation, upgrade Lexer to latch the line numbers at which each token starts and ends, and return that information with the token itself. Signed-off-by: Eric Sunshine --- t/chainlint.pl | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/t/chainlint.pl b/t/chainlint.pl index fcf4d459249..01f261165b1 100755 --- a/t/chainlint.pl +++ b/t/chainlint.pl @@ -67,6 +67,7 @@ sub new { bless { parser => $parser, buff => $s, + lineno => 1, heretags => [] } => $class; } @@ -97,7 +98,9 @@ sub scan_op { sub scan_sqstring { my $self = shift @_; ${$self->{buff}} =~ /\G([^']*'|.*\z)/sgc; - return "'" . $1; + my $s = $1; + $self->{lineno} += () = $s =~ /\n/sg; + return "'" . $s; } sub scan_dqstring { @@ -115,7 +118,7 @@ sub scan_dqstring { if ($c eq '\\') { $s .= '\\', last unless $$b =~ /\G(.)/sgc; $c = $1; - next if $c eq "\n"; # line splice + $self->{lineno}++, next if $c eq "\n"; # line splice # backslash escapes only $, `, ", \ in dq-string $s .= '\\' unless $c =~ /^[\$`"\\]$/; $s .= $c; @@ -123,6 +126,7 @@ sub scan_dqstring { } die("internal error scanning dq-string '$c'\n"); } + $self->{lineno} += () = $s =~ /\n/sg; return $s; } @@ -137,6 +141,7 @@ sub scan_balanced { $depth--; last if $depth == 0; } + $self->{lineno} += () = $s =~ /\n/sg; return $s; } @@ -165,6 +170,8 @@ sub swallow_heredocs { while (my $tag = shift @$tags) { my $indent = $tag =~ s/^\t// ? '\\s*' : ''; $$b =~ /(?:\G|\n)$indent\Q$tag\E(?:\n|\z)/gc; + my $body = $&; + $self->{lineno} += () = $body =~ /\n/sg; } } @@ -172,11 +179,12 @@ sub scan_token { my $self = shift @_; my $b = $self->{buff}; my $token = ''; - my $start; + my ($start, $startln); RESTART: + $startln = $self->{lineno}; $$b =~ /\G[ \t]+/gc; # skip whitespace (but not newline) $start = pos($$b) || 0; - return ["\n", $start, pos($$b)] if $$b =~ /\G#[^\n]*(?:\n|\z)/gc; # comment + $self->{lineno}++, return ["\n", $start, pos($$b), $startln, $startln] if $$b =~ /\G#[^\n]*(?:\n|\z)/gc; # comment while (1) { # slurp up non-special characters $token .= $1 if $$b =~ /\G([^\\;&|<>(){}'"\$\s]+)/gc; @@ -188,20 +196,20 @@ RESTART: $token .= $self->scan_sqstring(), next if $c eq "'"; $token .= $self->scan_dqstring(), next if $c eq '"'; $token .= $c . $self->scan_dollar(), next if $c eq '$'; - $self->swallow_heredocs(), $token = $c, last if $c eq "\n"; + $self->{lineno}++, $self->swallow_heredocs(), $token = $c, last if $c eq "\n"; $token = $self->scan_op($c), last if $c =~ /^[;&|<>]$/; $token = $c, last if $c =~ /^[(){}]$/; if ($c eq '\\') { $token .= '\\', last unless $$b =~ /\G(.)/sgc; $c = $1; - next if $c eq "\n" && length($token); # line splice - goto RESTART if $c eq "\n"; # line splice + $self->{lineno}++, next if $c eq "\n" && length($token); # line splice + $self->{lineno}++, goto RESTART if $c eq "\n"; # line splice $token .= '\\' . $c; next; } die("internal error scanning character '$c'\n"); } - return length($token) ? [$token, $start, pos($$b)] : undef; + return length($token) ? [$token, $start, pos($$b), $startln, $self->{lineno}] : undef; } # ShellParser parses POSIX shell scripts (with minor extensions for Bash). It From patchwork Wed Nov 9 16:58:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13037800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97288C433FE for ; Wed, 9 Nov 2022 17:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231216AbiKIRBr (ORCPT ); Wed, 9 Nov 2022 12:01:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbiKIRAz (ORCPT ); Wed, 9 Nov 2022 12:00:55 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62DCC13EA8 for ; Wed, 9 Nov 2022 08:58:44 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id g12so26651584wrs.10 for ; Wed, 09 Nov 2022 08:58:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:fcc:content-transfer-encoding:mime-version:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=QXkbfX/y2huPC/dZjCOIXo5RszT66Kow8WyYzH+vLNE=; b=hPi9R3sW2zJvvymy41YjOgL5ztPiGzcOtPJCzsAfxr2SXA893Lxdyc72QBhTswrYox i8Di9rPwBHzcP05ecORR+CwsV9O+w/5XxTurzq9ThjkaBsbylgEWnE86tOGrRks7+HNW Y9+6HawdnYgKIsT1mKZVkTHvxKyTtoOT9WBi6jtTk5KUN5KNU/kl/j/oDXnm/D9hNCwI yrkaADm2zt/C3Wq9bV68Iv/VfbdNBhXJTbdOnWSfXjpBO3LkbjqQfLY0TV+zxcOUve88 eFyvB4Sc7VkanbyaNYluXSB/rrh48zxqG98DzBfkZR1ytraEduQyQH3G1VTIpVa8X6yh Ug2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:fcc:content-transfer-encoding:mime-version:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QXkbfX/y2huPC/dZjCOIXo5RszT66Kow8WyYzH+vLNE=; b=U/uQsM9r05rejQa/9hzB6+SeRMV7JQ/RobeYHhhjI8CVb3QXR8WVbuMWUf9U9Y+A/I syci4onC04sjCMI4fVJE1FZfJCliAGv8E0ubMS3PwvnAeopeXjPZtMh4N141YMmeu9Xd U3aZFCKaPYMbOmZNaMzYHSO2jsAc6cCzNuPMQ7CYz8S+dkR37OWsyYnpZECqZwnP+6pn H/7xSyTLp64P9RiLOzGkRiywvThwbcTvsqyK3pe/nE+GbL/ntayQGZej1WGF4u+/IQFe HWJwyitQ4cnEmO3qVP7lPszOnvlZQPUlQhEIZALwSGTGQ+L52ecobuJ8OPAEtyC223S9 kGlw== X-Gm-Message-State: ACrzQf2N153XWnfD5AWq3d1jHYGX6ST+GB9yZbPcQyB2DzW7UC3ArBF8 ITSxqfHB+DXCHDqVBbvW+34vxRmaV3k= X-Google-Smtp-Source: AMsMyM5ZjLFmrlmqSCvl7FXb8vciGYyvI2lJp94E5SLLpqdTltDVRwq2p+lnxPInHB32RcpyKvKl9Q== X-Received: by 2002:a5d:58d9:0:b0:236:5b81:2c99 with SMTP id o25-20020a5d58d9000000b002365b812c99mr39703329wrf.494.1668013123641; Wed, 09 Nov 2022 08:58:43 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t17-20020a05600c199100b003b4fdbb6319sm2307378wmq.21.2022.11.09.08.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 08:58:43 -0800 (PST) Message-Id: <380b146abd1d97d51511c7acd11ffb99d1affcc6.1668013114.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 09 Nov 2022 16:58:34 +0000 Subject: [PATCH 3/3] chainlint: prefix annotated test definition with line numbers MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Eric Sunshine , Eric Sunshine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Eric Sunshine From: Eric Sunshine When chainlint detects problems in a test, it prints out the name of the test script, the name of the problematic test, and a copy of the test definition with "?!FOO?!" annotations inserted at the locations where problems were detected. Taken together this information is sufficient for the test author to identify the problematic code in the original test definition. However, in a lengthy script or a lengthy test definition, the author may still end up using the editor's search feature to home in on the exact problem location. To further assist the test author, display line numbers along with the annotated test definition, thus allowing the author to jump directly to each problematic line. Suggested-by: Ævar Arnfjörð Bjarmason Signed-off-by: Eric Sunshine --- t/Makefile | 2 +- t/chainlint.pl | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/t/Makefile b/t/Makefile index 882782a519c..2c2b2522402 100644 --- a/t/Makefile +++ b/t/Makefile @@ -94,7 +94,7 @@ check-chainlint: done \ } >'$(CHAINLINTTMP_SQ)'/expect && \ $(CHAINLINT) --emit-all '$(CHAINLINTTMP_SQ)'/tests | \ - grep -v '^[ ]*$$' >'$(CHAINLINTTMP_SQ)'/actual && \ + sed -e 's/^[1-9][0-9]* //;/^[ ]*$$/d' >'$(CHAINLINTTMP_SQ)'/actual && \ if test -f ../GIT-BUILD-OPTIONS; then \ . ../GIT-BUILD-OPTIONS; \ fi && \ diff --git a/t/chainlint.pl b/t/chainlint.pl index 01f261165b1..48dde978480 100755 --- a/t/chainlint.pl +++ b/t/chainlint.pl @@ -613,6 +613,7 @@ sub check_test { my $problems = $parser->{problems}; return unless $emit_all || @$problems; my $c = main::fd_colors(1); + my $lineno = $_[1]->[3]; my $start = 0; my $checked = ''; for (sort {$a->[1]->[2] <=> $b->[1]->[2]} @$problems) { @@ -622,10 +623,12 @@ sub check_test { $start = $pos; } $checked .= substr($body, $start); - $checked =~ s/^\n//; + $checked =~ s/^/$lineno++ . ' '/mge; + $checked =~ s/^\d+ \n//; $checked =~ s/(\s) \?!/$1?!/mg; $checked =~ s/\?! (\s)/?!$1/mg; $checked =~ s/(\?![^?]+\?!)/$c->{rev}$c->{red}$1$c->{reset}/mg; + $checked =~ s/^\d+/$c->{dim}$&$c->{reset}/mg; $checked .= "\n" unless $checked =~ /\n$/; push(@{$self->{output}}, "$c->{blue}# chainlint: $title$c->{reset}\n$checked"); } @@ -657,7 +660,7 @@ if (eval {require Time::HiRes; Time::HiRes->import(); 1;}) { # thread and ignore %ENV changes in subthreads. $ENV{TERM} = $ENV{USER_TERM} if $ENV{USER_TERM}; -my @NOCOLORS = (bold => '', rev => '', reset => '', blue => '', green => '', red => ''); +my @NOCOLORS = (bold => '', rev => '', dim => '', reset => '', blue => '', green => '', red => ''); my %COLORS = (); sub get_colors { return \%COLORS if %COLORS; @@ -668,6 +671,7 @@ sub get_colors { if ($ENV{TERM} =~ /\bxterm\b/) { %COLORS = (bold => "\e[1m", rev => "\e[7m", + dim => "\e[2m", reset => "\e[0m", blue => "\e[34m", green => "\e[32m", @@ -677,9 +681,11 @@ sub get_colors { if (system("tput sgr0 >/dev/null 2>&1") == 0 && system("tput bold >/dev/null 2>&1") == 0 && system("tput rev >/dev/null 2>&1") == 0 && + system("tput dim >/dev/null 2>&1") == 0 && system("tput setaf 1 >/dev/null 2>&1") == 0) { %COLORS = (bold => `tput bold`, rev => `tput rev`, + dim => `tput dim`, reset => `tput sgr0`, blue => `tput setaf 4`, green => `tput setaf 2`,