From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 9713D3942008; Tue, 2 May 2023 20:15:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9713D3942008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683058526; bh=RpCpVKf5iYUauBTnv8q4pvgWbsT3CW47yrK2cr2R8sQ=; h=From:To:Subject:Date:From; b=qeYjch2ZSPNB6k4QfuJ/XECOmpzTyy9tu07v8tIzojUACmG/FTfoAY0N+IDi4K4G7 7kFQXdMe0ajpWOVv1g82OeyU5L0XVZf8uuIiJAO1XYcs4z3zWJAL6G7FqfDteedYa0 3WAqXYIOE93DQhsXpEhJzGcmWvQvYm2mcXw1rH24= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-10720] diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 9d98f84ca37a154a24f3f2b2950bfb450cbe6316 X-Git-Newrev: 8b564ac2db506189c87b2871d9fc0fb994b809a5 Message-Id: <20230502201526.9713D3942008@sourceware.org> Date: Tue, 2 May 2023 20:15:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8b564ac2db506189c87b2871d9fc0fb994b809a5 commit r11-10720-g8b564ac2db506189c87b2871d9fc0fb994b809a5 Author: Jakub Jelinek Date: Sat Mar 4 09:48:17 2023 +0100 diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973] As mentioned in the PR, GCC's diagnostics self-tests fail if $COLUMNS < 42. Guarding each self-test with if (get_terminal_width () > 41) or similar would be a maintainance nightmare (PR has a patch to do so without reformatting to make it work for $COLUMNS in [30, 41] inclusive, but I'm afraid going down to $COLUMNS 1 would mean marking everything). Furthermore, the self-tests don't really emit stuff to the terminal, but into a buffer, so using get_terminal_width () for it seems inappropriate. The following patch makes sure test_diagnostic_context constructor uses exactly 80 columns wide caret max width, of course some tests override it already if they want to test for behavior in narrower cases. 2023-03-04 Jakub Jelinek PR testsuite/108973 * selftest-diagnostic.c (test_diagnostic_context::test_diagnostic_context): Set caret_max_width to 80. (cherry picked from commit 739e7ebb3d378ece25d64b39baae47c584253498) Diff: --- gcc/selftest-diagnostic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/selftest-diagnostic.c b/gcc/selftest-diagnostic.c index 27976f161b3..45f1446fb3c 100644 --- a/gcc/selftest-diagnostic.c +++ b/gcc/selftest-diagnostic.c @@ -41,6 +41,7 @@ test_diagnostic_context::test_diagnostic_context () show_column = true; start_span = start_span_cb; min_margin_width = 6; + caret_max_width = 80; } test_diagnostic_context::~test_diagnostic_context ()