[2/6] gdb/testsuite/tui: Split enter_tui into two procs

Message ID e4fd88b0a279b4a6f1f9864c1ad8e8149122c7e7.1578397591.git.andrew.burgess@embecosm.com
State New, archived
Headers

Commit Message

Andrew Burgess Jan. 7, 2020, 11:52 a.m. UTC
  Split Term::enter_tui into two procedures, a core which does the
setup, but doesn't actually enable tui mode, and the old enter_tui
that calls the new core, and then enables tui mode.

This is going to be useful in a later commit.

gdb/testsuite/ChangeLog:

	* lib/tuiterm.exp (Term::prepare_for_tui): New proc.
	(Term::enter_tui): Use Term::prepare_for_tui.

Change-Id: I501dfb2ddaa4a4e7246a5ad319ab428e4f42b3af
---
 gdb/testsuite/ChangeLog       |  5 +++++
 gdb/testsuite/lib/tuiterm.exp | 16 +++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)
  

Comments

Tom Tromey Jan. 7, 2020, 7:19 p.m. UTC | #1
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> Split Term::enter_tui into two procedures, a core which does the
Andrew> setup, but doesn't actually enable tui mode, and the old enter_tui
Andrew> that calls the new core, and then enables tui mode.

Andrew> This is going to be useful in a later commit.

Andrew> gdb/testsuite/ChangeLog:

Andrew> 	* lib/tuiterm.exp (Term::prepare_for_tui): New proc.
Andrew> 	(Term::enter_tui): Use Term::prepare_for_tui.

Thanks, this looks good.

Tom
  

Patch

diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 36e034a3639..9ac599b6f2d 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -462,15 +462,25 @@  namespace eval Term {
 	}
     }
 
-    # Start the TUI.  Returns 1 on success, 0 if TUI tests should be
-    # skipped.
-    proc enter_tui {} {
+    # Setup ready for starting the tui, but don't actually start it.
+    # Returns 1 on success, 0 if TUI tests should be skipped.
+    proc prepare_for_tui {} {
 	if {[skip_tui_tests]} {
 	    return 0
 	}
 
 	gdb_test_no_output "set tui border-kind ascii"
 	gdb_test_no_output "maint set tui-resize-message on"
+	return 1
+    }
+
+    # Start the TUI.  Returns 1 on success, 0 if TUI tests should be
+    # skipped.
+    proc enter_tui {} {
+	if {![prepare_for_tui]} {
+	    return 0
+	}
+
 	command "tui enable"
 	return 1
     }