From patchwork Fri Mar 3 09:35:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 63839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp316576wrd; Fri, 3 Mar 2023 01:36:48 -0800 (PST) X-Google-Smtp-Source: AK7set/0a8pk4nkC+GTy+N47yJw91zdqKo7jnWKLNumd7A6wlLpLfTGxO2NPLkQ0PDz9yizHE0D7 X-Received: by 2002:a17:906:9f21:b0:884:3707:bd83 with SMTP id fy33-20020a1709069f2100b008843707bd83mr909210ejc.69.1677836208231; Fri, 03 Mar 2023 01:36:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677836208; cv=none; d=google.com; s=arc-20160816; b=eNsV7k8isX8djnzNrxBGQVk41YXG2tKFSYD0fnRiCVNndNuLpy7Tf2aeR9ESfAEBw8 IxNYt31BK+KyszyvrIpQ2TjXKqZELAZNO516YevYP7ZxYYZG490IBfpSNZflwHsYSEsb wrE1VskvL1XYzC+M7x2bG7rKkJMj5/0bGFqRumlcct5b0ZQn6+tBzscSgWqTESm9yA14 RYf6mMr3l3k19V+V+4lMRlWtzr7uTP+W/9xW4K024NQYxfia6c1bswSPHIjuvX5Np0Q6 CUSBsaexZCAk1t/ToDaYusIPD8s+Zcuk4XlQcgRgOiIMjBzEgfwOnIe2+cvQaoj/Zqk9 zYyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=eUPXep6cyLcIVrPCFl9QpUb7g+5wQ8XilVnE+ZShDmQ=; b=yO4RROH+a5QDsXFZ2AIEF/7Jr1yYhUemCYRgv3u5l/wXIgChxOczBaaFRZ8DmghjRB e3jfvbvOD6QogJau4m2LlhgIv/VA+Rs0p+Ecze8BVonEBPp7/Q03rx+qfEpsluXfUgJv wAU0Mms2LtYFNVk0L0BNrFVzEvcPZSG9+CDGJAkoFTyuk5Z0lDLs7ip1koQtJLjRjI/5 UY55YmGN7qekJBtK6DNkm+U1xQoxByrKDWAI4lr1Oku4Z+s8m9A8gpVWdsWvpsYeIt9r FN6OUUhFTEtSrluC9tCEwBtBYW4BYBhxwYl9kMKMEk6sEhqIn/NJ2HxjDS/QH6kE9tyS dd3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yT8kyyBI; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 17-20020a170906311100b008c5cdeef474si1704638ejx.985.2023.03.03.01.36.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 01:36:48 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yT8kyyBI; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 021BA3858D37 for ; Fri, 3 Mar 2023 09:36:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 021BA3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677836207; bh=eUPXep6cyLcIVrPCFl9QpUb7g+5wQ8XilVnE+ZShDmQ=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=yT8kyyBIyEBMgWBNcc/UdfIfhCsMBhUyvdaatQ1FXbbEDOQm4X0OgQ34rMqMzVFzW udZM7J6YHTm5IZwoJ9KJzEHUASF32Pu2KfrLsY7Ic24fKt7XkVRWopzfMpc1qkpbu8 tLogRWNwaL4iFD7OG+VpXYydsE4X3quE7nKWsF9g= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 516633858D33 for ; Fri, 3 Mar 2023 09:35:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 516633858D33 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-WZmeq6WRNsS-1evTzm7I7Q-1; Fri, 03 Mar 2023 04:35:57 -0500 X-MC-Unique: WZmeq6WRNsS-1evTzm7I7Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 87AE6185A7A4 for ; Fri, 3 Mar 2023 09:35:57 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C28B40C6EC4; Fri, 3 Mar 2023 09:35:57 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3239ZsJt1820260 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 3 Mar 2023 10:35:55 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3239Zs991820259; Fri, 3 Mar 2023 10:35:54 +0100 Date: Fri, 3 Mar 2023 10:35:54 +0100 To: David Malcolm Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759338780135485560?= X-GMAIL-MSGID: =?utf-8?q?1759338780135485560?= Hi! 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 at least 80 columns wide caret max width, of course some tests override it already if they want to test for behavior in narrower cases. Bootstrapped/regtested on x86_64-linux and i686-linux, plus tested on self-tests with $COLUMNS down to 1, ok for trunk? 2023-03-03 Jakub Jelinek PR testsuite/108973 * selftest-diagnostic.cc (test_diagnostic_context::test_diagnostic_context): Ensure caret_max_width isn't smaller than 80. Jakub --- gcc/selftest-diagnostic.cc.jj 2023-01-02 09:32:31.991146491 +0100 +++ gcc/selftest-diagnostic.cc 2023-03-02 10:05:17.974321025 +0100 @@ -41,6 +41,7 @@ test_diagnostic_context::test_diagnostic show_column = true; start_span = start_span_cb; min_margin_width = 6; + caret_max_width = MAX (caret_max_width, 80); } test_diagnostic_context::~test_diagnostic_context ()