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.133.124]) by sourceware.org (Postfix) with ESMTPS id F04F13817F83 for ; Thu, 15 Dec 2022 16:30:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F04F13817F83 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=1671121858; 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=hGudqjBbP8d00KUIqAN4AOBMQX/IRcWIq/V0JodKyM0=; b=iUHG2dqmiIWwWELLU2gRV5JXKAyQuypvlTJCbJ8wSX/LSm1n6IQiIOc7v4YXGqmrEp/h20 Uv/wMuF3i0k9J1J+YIwUa6UGxKIKoFLnXPiuLtvjU08cftbDmHHWdfCAvFewaVKP66nUnR Lvql4uK222sStM0uxxDWQlez1WtnHVs= Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-616-kNxDwwdFNqmpaM0FprPqvQ-1; Thu, 15 Dec 2022 11:30:56 -0500 X-MC-Unique: kNxDwwdFNqmpaM0FprPqvQ-1 Received: by mail-yb1-f199.google.com with SMTP id a5-20020a25af05000000b006e450a5e507so4392156ybh.22 for ; Thu, 15 Dec 2022 08:30:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hGudqjBbP8d00KUIqAN4AOBMQX/IRcWIq/V0JodKyM0=; b=OAilTJoGDVR0If1xXCyj1DDGTFdaP959uyAOOSW5qVTOYqzdt+SajY7m/hyN585qTQ M0U24lG0Cfb81I3zLiMB80j3BzTkYZQ7Ouhhmry3vto8lPKN3+Aa5Ww8Tq9ageEYKmZy GMwf5M7N+tgq07rxlegbTp+XBJ26oTmG3eWvv47YQILuWxV2bsNvK5s0z0LXwZXPsjz0 2Er/AoEulEgT1/PmFor2gEt64OiaE5Xv8arNxJSWv5PwlhvtSIyvLmu6UGX1VtPor69H KQCyDH53CuNc3BSACZmrEpxA2O7fsrWCoGBsGT1FnLEpzkKmP7cjdbHdlgu98mRIrPaq wSyA== X-Gm-Message-State: ANoB5pnArIcANW6JSp+u1DOloNLJXoZ+kImSTidfliGipHKSSbSXsLY+ V7kXeQelF4Y0PA3LA/C6GXM5NowFGKp4YckwnQW/jIpdzNYBQW12R9I1S4GFIy0VLFcfM4gy5uw 5Wn3h6x8FxaE/SUA= X-Received: by 2002:a25:c697:0:b0:6fb:365b:e851 with SMTP id k145-20020a25c697000000b006fb365be851mr27328110ybf.16.1671121855273; Thu, 15 Dec 2022 08:30:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf4qEQEEPDfQwUi2Z/uVgQdIfuJsqttJGY6F4l83fIxHow2KF35Ni4bYgQOPE7uBiLnUszDrkg== X-Received: by 2002:a25:c697:0:b0:6fb:365b:e851 with SMTP id k145-20020a25c697000000b006fb365be851mr27328075ybf.16.1671121854944; Thu, 15 Dec 2022 08:30:54 -0800 (PST) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id m3-20020a05620a24c300b006fc7302cf89sm12703764qkn.28.2022.12.15.08.30.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Dec 2022 08:30:54 -0800 (PST) Message-ID: <3e56cf50-344b-fbb1-fb12-4f44330cf560@redhat.com> Date: Thu, 15 Dec 2022 11:30:53 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH 4/4] contrib: Add dg-out-generator.pl To: =?UTF-8?Q?Arsen_Arsenovi=c4=87?= , gcc-patches@gcc.gnu.org Cc: jwakely@redhat.com, libstdc++@gcc.gnu.org References: <20221210094303.2180127-1-arsen@aarsen.me> <20221210094303.2180127-5-arsen@aarsen.me> From: Jason Merrill In-Reply-To: <20221210094303.2180127-5-arsen@aarsen.me> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,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 12/10/22 04:43, Arsen Arsenović wrote: > This script is a helper used to generate dg-output lines from an existing > program output conveniently. It takes care of escaping Tcl and ARE stuff. > contrib/ChangeLog: > > * dg-out-generator.pl: New file. > --- > contrib/dg-out-generator.pl | 67 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 67 insertions(+) > create mode 100755 contrib/dg-out-generator.pl > > diff --git a/contrib/dg-out-generator.pl b/contrib/dg-out-generator.pl > new file mode 100755 > index 00000000000..38aed2aa38d > --- /dev/null > +++ b/contrib/dg-out-generator.pl > @@ -0,0 +1,67 @@ > +#!/usr/bin/env perl > +# > +# Copyright (C) 2022 GCC Contributors. > +# Contributed by Arsen Arsenović. > +# > +# This script is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3, or (at your option) > +# any later version. > + > +# This script reads program output on STDIN, and out of it produces a block of > +# dg-output lines that can be yanked at the end of a file. It will escape > +# special ARE and Tcl constructs automatically. > +# > +# Each argument passed on the standard input is treated as a string to be > +# replaced by ``.*'' in the final result. This is intended to mask out build > +# paths, filenames, etc. > +# > +# Usage example: > + > +# $ g++-13 -fcontracts -o test \ > +# 'g++.dg/contracts/contracts-access1.C' && \ > +# ./test |& dg-out-generator.pl 'g++.dg/contracts/contracts-access1.C' > +# // { dg-output "contract violation in function Base::b at .*:11: pub > 0(\n|\r\n|\r)*" } > +# // { dg-output "\\\[level:default, role:default, continuation mode:never\\\](\n|\r\n|\r)*" } > +# // { dg-output "terminate called without an active exception(\n|\r\n|\r)*" } > +# You can now freely dump the above into your testcase. > + > +use strict; > +use warnings; > +use POSIX 'floor'; > + > +my $escapees = '(' . join ('|', map { quotemeta } @ARGV) . ')'; > + > +sub gboundary($) > +{ > + my $str = shift; > + my $sz = 10.0; > + for (;;) > + { > + my $bnd = join '', (map chr 64 + rand 27, 1 .. floor $sz); > + return $bnd unless index ($str, $bnd) >= 0; > + $sz += 0.1; > + } > +} > + > +while () > + { > + # Escape our escapees. > + my $boundary = gboundary $_; > + s/$escapees/$boundary/; > + > + # Quote stuff special in Tcl ARE. > + s/([[\]*+?{}()\\])/\\$1/g; > + > + # Then, special stuff in TCL itself. > + s/([\][\\])/\\$1/g; > + > + # Newlines should be more tolerant. > + s/\n$/(\\n|\\r\\n|\\r)*/; > + > + # Then split out the boundary, replacing it with .*. > + s/$boundary/.*/; > + > + # Then, let's print it in a dg-output block. > + print "// { dg-output \"$_\" }\n"; I wonder if you want to wrap the pattern in {} instead of "" so you don't need the "special stuff in TCL itself" quoting? Jason