From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677836158; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=eUPXep6cyLcIVrPCFl9QpUb7g+5wQ8XilVnE+ZShDmQ=; b=d5desGeXdR/OFqtTebUDcEpJm3c4L1HBFFXW5JxeyAeCLh68QPCZamCq96oDNlpz0zWHJI WqgCltkDYGATyVt+jJ+zUvMDYZkF1njXC6AQBJC+5cAB2+oAeEnU68hJElAzW/igTeV49z JqxJPe7bWnhO6wrEYFc6X4mOvpFKJZA= 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 From: Jakub Jelinek To: David Malcolm Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973] Message-ID: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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. --- 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 () Jakub