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: 65962 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 86948385842A for ; Fri, 3 Mar 2023 09:36:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86948385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677836191; 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=YMSdzls++mCIavFcExawTv9wDavnm48vMb9h7WsCVLHOW/RIZcMSMl67Lf8WFDsC2 yl9Er3SRg1vn6TxkOGe4lvEHCOLnjE1b60mzzlL7Do+6cxyq6K08akMNjrtsWISWsF QtEWQsGmZIddjGybfdumlAI6NzkB9ax+7C7B41ek= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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 ()