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 120533858D37 for ; Fri, 3 Mar 2023 13:54:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 120533858D37 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=1677851675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4Yq09rApAIPtA3lEo5NdSgSV9G706m8/C2i98yozr08=; b=AkKMt2TeblNXUy7Wc1ItL8Bm8hNlfZtwYsLGxkCutU2MrUTrCLeEvpjnIUoilrWYcAvCNS H/+E+vGqBCgxGIKF3A+1YcgKWLMIlGoEr7kIl4W2+zADnlNHXvYyZiwIBxEVg5c8AwRYW5 7ALweYncEZAAjaSrFZuRNVs41+yNfQI= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-xqgJPiQ1PUStjonKM7ooEg-1; Fri, 03 Mar 2023 08:54:34 -0500 X-MC-Unique: xqgJPiQ1PUStjonKM7ooEg-1 Received: by mail-qt1-f197.google.com with SMTP id h21-20020ac87d55000000b003bffb1c9745so1510250qtb.4 for ; Fri, 03 Mar 2023 05:54:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677851674; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4Yq09rApAIPtA3lEo5NdSgSV9G706m8/C2i98yozr08=; b=oW8hUY51h1yvs/pvECfd+mSztcfXV/0X6W934qUOyXhNzmsmeTBDlAIResJoM2IomY lZc2HbYwU7SIimCr5ieBqZ3ij0JcJ3Bf58Xu5dvQ+NGaQdIfa6AoRqDNIhN5hQBFJzJZ VsEqDRLXKFlMwnMA5xwRSeBti8Cx4yzbhV1gJsFbqslWNqWiRx2ii8FThoZJ/iOlIp4m KvkBIrB/D7eQFkv9AYPbgpWEoM2L6ramyRs5guKB/hmQyETm8oYp7a5dAT7SxBJAFzuJ f3j1Nz93/5S7S4L5eAjVm27A26XCAF/9dLkBTfoLmw61Xc7TS+UmQGomUxidQvo3TifN 94ug== X-Gm-Message-State: AO0yUKUscNWeRsBf7/J+Eak2f16TbAWyje5uif9GYhWbpA2pPgVjZH9D Mj4063/PhaVxi7oNUt/jy6bP+EVM32hUkzoaHP/BqL0ZRYszQBKVcjO+dWWLl8UnVqmh3Q+I5Uw fOH+6CPqDBulvy6Fb2vqyKPw= X-Received: by 2002:ac8:7d91:0:b0:3bf:cfdd:702b with SMTP id c17-20020ac87d91000000b003bfcfdd702bmr3219826qtd.23.1677851673858; Fri, 03 Mar 2023 05:54:33 -0800 (PST) X-Google-Smtp-Source: AK7set9Ici2mejhQOZKa4DLdSVw4zprIQS1CfoJtWkrUbjCPFSbK6OgnOSeBdadC3uOzawJ2D7ERTA== X-Received: by 2002:ac8:7d91:0:b0:3bf:cfdd:702b with SMTP id c17-20020ac87d91000000b003bfcfdd702bmr3219799qtd.23.1677851673582; Fri, 03 Mar 2023 05:54:33 -0800 (PST) Received: from t14s.localdomain (c-73-69-212-193.hsd1.nh.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id d2-20020ac851c2000000b003bfd27755d7sm1784340qtn.19.2023.03.03.05.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 05:54:33 -0800 (PST) Message-ID: Subject: Re: [PATCH] diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973] From: David Malcolm To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Date: Fri, 03 Mar 2023 08:54:32 -0500 In-Reply-To: References: User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,BODY_8BITS,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: On Fri, 2023-03-03 at 10:35 +0100, Jakub Jelinek wrote: > Hi! >=20 > 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.=C2=A0 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. >=20 > Bootstrapped/regtested on x86_64-linux and i686-linux, plus tested > on self-tests with $COLUMNS down to 1, ok for trunk? >=20 > 2023-03-03=C2=A0 Jakub Jelinek=C2=A0 >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0PR testsuite/108973 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* selftest-diagnostic.cc > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(test_diagnostic_context:= :test_diagnostic_context): Ensure > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0caret_max_width isn't sma= ller than 80. >=20 > --- gcc/selftest-diagnostic.cc.jj=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A02023-01-02 09:32:31.991146491 > +0100 > +++ gcc/selftest-diagnostic.cc=C2=A0=C2=A02023-03-02 10:05:17.974321025 += 0100 > @@ -41,6 +41,7 @@ test_diagnostic_context::test_diagnostic > =C2=A0=C2=A0 show_column =3D true; > =C2=A0=C2=A0 start_span =3D start_span_cb; > =C2=A0=C2=A0 min_margin_width =3D 6; > +=C2=A0 caret_max_width =3D MAX (caret_max_width, 80); > =C2=A0} Thanks for working on this. Patch is OK, but I wonder if it would even better to just hardcode caret_max_width as 80 here, to better eliminate that influence from from the environment in the unit tests? I think all of the tests that modify caret_max_width do so after the ctor has run. Dave