gdb/testsuite: Adjust command completion output when TUI is disabled

Message ID 73d8a79e-8dea-cbbb-a29f-925eda3230dd@codesourcery.com
State New
Headers show
Series
  • gdb/testsuite: Adjust command completion output when TUI is disabled
Related show

Commit Message

Sandra Loosemore June 23, 2020, 6:27 a.m.
This is another almost-obvious testsuite fix, for one of the 
command-completion tests that was failing due to an incorrect assumption 
that TUI commands are always present.  OK to commit, or is this just a 
poorly-designed testcase that we should rewrite some other way instead?

-Sandra

Comments

Andrew Burgess June 23, 2020, 8:39 a.m. | #1
* Sandra Loosemore <sandra@codesourcery.com> [2020-06-23 00:27:45 -0600]:

> This is another almost-obvious testsuite fix, for one of the

> command-completion tests that was failing due to an incorrect assumption

> that TUI commands are always present.  OK to commit, or is this just a

> poorly-designed testcase that we should rewrite some other way instead?

> 

> -Sandra


> commit 8e0cc2870a30390e745110d4c8181f010d09c17f

> Author: Sandra Loosemore <sandra@codesourcery.com>

> Date:   Mon Jun 22 23:01:19 2020 -0700

> 

>     Adjust command completion output when TUI is disabled

>     

>     The history-scrolling commands "+", "-", "<" and ">" are only known to

>     GDB when TUI is enabled.  This means the "complete pipe " command

>     produces different output depending on whether TUI is present, which

>     in turn caused

>     

>     FAIL: gdb.base/shell.exp: cmd complete "pipe "

>     

>     This patch provides different patterns for that test depending on

>     whether or not TUI is available.

>     

>     2020-06-23  Sandra Loosemore  <sandra@codesourcery.com>

>     

>     	gdb/testsuite/

>     	* lib/completion-support.exp (test_gdb_completion_offers_commands):

>     	Adjust for omitted commands when TUI is disabled.


LGTM.

Thanks,
Andrew


> 

> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog

> index d6c43e6..38f2188 100644

> --- a/gdb/testsuite/ChangeLog

> +++ b/gdb/testsuite/ChangeLog

> @@ -1,3 +1,8 @@

> +2020-06-23  Sandra Loosemore  <sandra@codesourcery.com>

> +

> +	* lib/completion-support.exp (test_gdb_completion_offers_commands):

> +	Adjust for omitted commands when TUI is disabled.

> +

>  2020-06-22  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

>  

>  	* gdb.base/default-args.exp: New test.

> diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp

> index 18eac82..51436cc 100644

> --- a/gdb/testsuite/lib/completion-support.exp

> +++ b/gdb/testsuite/lib/completion-support.exp

> @@ -555,10 +555,19 @@ proc test_gdb_completion_offers_commands {input_line} {

>      # Force showing two commands.

>      gdb_test_no_output "set max-completions 2" ""

>  

> -    test_gdb_complete_multiple $input_line "" "" {

> -	"!"

> -	"+"

> -    } "" "" 1

> +    # TUI adds additional commands to the possible completions, so we

> +    # need different patterns depending on whether or not it is enabled.

> +    if { [skip_tui_tests] } {

> +	test_gdb_complete_multiple $input_line "" "" {

> +	    "!"

> +	    "actions"

> +	} "" "" 1

> +    } else {

> +	test_gdb_complete_multiple $input_line "" "" {

> +	    "!"

> +	    "+"

> +	} "" "" 1

> +    }

>  

>      # Restore.

>      gdb_test_no_output "set max-completions $max_completions" ""
Jose E. Marchesi via Gdb-patches June 23, 2020, 12:06 p.m. | #2
On 6/23/20 7:27 AM, Sandra Loosemore wrote:
> This is another almost-obvious testsuite fix, for one of the command-completion tests that was failing due to an incorrect assumption that TUI commands are always present.  OK to commit, or is this just a poorly-designed testcase that we should rewrite some other way instead?


With my "I wrote that" hat on, I don't see any other way to write that
test.  We want to check that TAB on an empty input line completes
all commands.  "+" only happens to be the one that sorts second in
the all-commands set.  The only way that I think we could get rid of the
TUI vs non-TUI difference is if we limit the number of completions to 1
instead of 2.  Then only "!" shows up.  But the "1 completion match only"
case makes GDB behave differently (it completes immediately), so I don't
think that's a good idea.

Thus, I think your patch is OK.

Thanks,
Pedro Alves

Patch

commit 8e0cc2870a30390e745110d4c8181f010d09c17f
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Mon Jun 22 23:01:19 2020 -0700

    Adjust command completion output when TUI is disabled
    
    The history-scrolling commands "+", "-", "<" and ">" are only known to
    GDB when TUI is enabled.  This means the "complete pipe " command
    produces different output depending on whether TUI is present, which
    in turn caused
    
    FAIL: gdb.base/shell.exp: cmd complete "pipe "
    
    This patch provides different patterns for that test depending on
    whether or not TUI is available.
    
    2020-06-23  Sandra Loosemore  <sandra@codesourcery.com>
    
    	gdb/testsuite/
    	* lib/completion-support.exp (test_gdb_completion_offers_commands):
    	Adjust for omitted commands when TUI is disabled.

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index d6c43e6..38f2188 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@ 
+2020-06-23  Sandra Loosemore  <sandra@codesourcery.com>
+
+	* lib/completion-support.exp (test_gdb_completion_offers_commands):
+	Adjust for omitted commands when TUI is disabled.
+
 2020-06-22  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
 	* gdb.base/default-args.exp: New test.
diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp
index 18eac82..51436cc 100644
--- a/gdb/testsuite/lib/completion-support.exp
+++ b/gdb/testsuite/lib/completion-support.exp
@@ -555,10 +555,19 @@  proc test_gdb_completion_offers_commands {input_line} {
     # Force showing two commands.
     gdb_test_no_output "set max-completions 2" ""
 
-    test_gdb_complete_multiple $input_line "" "" {
-	"!"
-	"+"
-    } "" "" 1
+    # TUI adds additional commands to the possible completions, so we
+    # need different patterns depending on whether or not it is enabled.
+    if { [skip_tui_tests] } {
+	test_gdb_complete_multiple $input_line "" "" {
+	    "!"
+	    "actions"
+	} "" "" 1
+    } else {
+	test_gdb_complete_multiple $input_line "" "" {
+	    "!"
+	    "+"
+	} "" "" 1
+    }
 
     # Restore.
     gdb_test_no_output "set max-completions $max_completions" ""