From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6Lt5AOYtvWElIwAAWB0awg (envelope-from ) for ; Fri, 17 Dec 2021 19:40:06 -0500 Received: by simark.ca (Postfix, from userid 112) id E07801F0CE; Fri, 17 Dec 2021 19:40:05 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 046561E940 for ; Fri, 17 Dec 2021 19:40:04 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4D683385801A for ; Sat, 18 Dec 2021 00:40:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D683385801A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1639788003; bh=prTlYgREv2V/sS1pRpKuhm8tfZV0J6mvuLQligl7DdQ=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=p90tB7v1ZE2V6lz/hTw3eMiHuaiA2/V2y6z/hEnv024kwUSPNzKHlNZWLoyYdF1hu 4aH7pBcxJPqW+bXbrO1i+4QNqY0ZTP6Osl8C/Q0EWGeJKHzLJUgoTl4f6tZ6dIBDFx A1bDtILGEr3cWtePJOsTOtsRQSgZ83J7OVfYbpfw= Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id DC7AC3858407 for ; Sat, 18 Dec 2021 00:39:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DC7AC3858407 Received: from Plymouth (unknown [IPv6:2a02:390:9086:0:413a:a3d0:a542:d809]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 9873280D5D; Sat, 18 Dec 2021 00:39:42 +0000 (UTC) Date: Sat, 18 Dec 2021 00:39:39 +0000 To: Pedro Alves Subject: Re: [PATCH 00/29] Remove DUPLICATEs from testsuite/gdb.base/*.exp Message-ID: <20211218003939.tbizhc7qbuhyq5dr@Plymouth> References: <20211121175636.779325-1-lsix@lancelotsix.com> <6a859188-8e54-4053-6e20-d6e50091bbd5@palves.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6a859188-8e54-4053-6e20-d6e50091bbd5@palves.net> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Sat, 18 Dec 2021 00:39:42 +0000 (UTC) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" > I reviewed all patches except patch #15 (gdb.base/complete-empty.exp). I left that for > last as I think I'll need look a bit in more detail, but I ran out of time for now. > I sent a few comments. Patches that I didn't comment on (other than #15) looks > OK to me. > > Thanks a lot for doing this. > Hi, I do not know if you have had a chance to look an #15, but I think I have another approach you might prefer. Instead of going around the testing framework in the testcase, it improves the completion testing framework. See below the alternative approach. Let me know what you think. Best, Lancelot. --- >From d62890e28d1492248649365946b931886192da76 Mon Sep 17 00:00:00 2001 From: Lancelot SIX Date: Sat, 20 Nov 2021 23:20:23 +0000 Subject: [PATCH] gdb: completion-support.exp: improve leading whitespace support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a expect support library in the source tree designed to help developers test the auto-completion capabilities of GDB. One of the functions is test_gdb_complete_unique_re. It is used (usually indirectly via test_gdb_complete_unique) to test that a given input line is completed as a given output line. The test checks for two ways to do the completion: using tab-completion, or using the 'complete' command. To do this, calls to two dedicated functions are performed. If we omit few details, we can consider that a call to test_gdb_complete_unique $input $expected is equivalent to the two following calls: test_gdb_complete_tab_unique $input $expected test_gdb_complete_cmd_unique $input $expected When using the tab-completion, everything works as expected, but some care must be taken when using the 'complete' command if the given input has leading whitespaces. In such situation, the output of the 'complete' command will drop the leading whitespaces. The current approach is that in such situation, the input and expected outputs are right trimmed (i.e. all leading whitespaces are removed) when performing the command completion check. This means that the following call: test_gdb_complete_unique " $input" " $expected" is almost equivalent to (again, omitting few details and arguments): test_gdb_complete_tab_unique " $input" " $expected" test_gdb_complete_cmd_unique "$input" "$expected" This approach comes with a problem that we encounter when running the tests in complete-empty.exp. When doing so, we have: Running .../gdb/testsuite/gdb.base/complete-empty.exp ... DUPLICATE: gdb.base/complete-empty.exp: empty-input-line: cmd complete "" This is because the test file does something like: test_gdb_complete_unique "" "!" " " 1 test_gdb_complete_unique " " " !" " " 1¬ which, if we do the substitution introduced above is equivalent to: test_gdb_complete_tab_unique "" "!" test_gdb_complete_cmd_unique "" "!" test_gdb_complete_tab_unique " " " !" test_gdb_complete_cmd_unique "" "!" We see that the lines 2 and 4 are now the same, and for this reason the testing framework complains about DUPLICATE test names. To fix that, this commit proposes that instead of left trimming both input and expected outputs, only the expected output is trimmed. Care must be taken in the case the completion gives more possibilities than allowed by the max-completions setting. In this case, the input will be repeated in the output in its left trimmed version. This commit also ensures that this is taken care of. With this commit, the gdb.base/complete-empty.exp still passes all its tests but does not report the DUPLICATE anymore. Tested on x86_64-linux. --- gdb/testsuite/lib/completion-support.exp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp index ddd3921977b..706ecdcb923 100644 --- a/gdb/testsuite/lib/completion-support.exp +++ b/gdb/testsuite/lib/completion-support.exp @@ -254,10 +254,8 @@ proc test_gdb_complete_unique_re { input_line complete_line_re {append_char " "} } } - # Trim INPUT_LINE and COMPLETE LINE, for the case we're completing - # a command with leading whitespace. Leading command whitespace - # is discarded by GDB. - set input_line [string trimleft $input_line] + # Trim COMPLETE LINE, for the case we're completing a command with leading + # whitespace. Leading command whitespace is discarded by GDB. set expected_output_re [string trimleft $complete_line_re] if {$append_char_re != " "} { append expected_output_re $append_char_re @@ -266,7 +264,7 @@ proc test_gdb_complete_unique_re { input_line complete_line_re {append_char " "} set max_completion_reached_msg \ "*** List may be truncated, max-completions reached. ***" set input_line_re \ - [string_to_regexp $input_line] + [string_to_regexp [string trimleft $input_line]] set max_completion_reached_msg_re \ [string_to_regexp $max_completion_reached_msg] -- 2.34.0