terminal: show message if there are no vars/locals/args

When the vars, locals, or args commands return no results, nothing is

printed out to the terminal. This commit makes these commands print a

message like `(no locals)` when there is nothing to show. This feedback

is more descriptive of what is being returned than an empty string.
This commit is contained in:
Wesley Merkel
2016-04-06 09:26:10 -07:00
committed by Derek Parker
parent ae7abe1a9d
commit e60942a39d
2 changed files with 21 additions and 4 deletions

View File

@ -269,7 +269,7 @@ func TestScopePrefix(t *testing.T) {
if fid < 0 {
t.Fatalf("Could not find frame for goroutine %d: %v", gid, stackOut)
}
term.AssertExec(fmt.Sprintf("goroutine %d frame %d locals", gid, fid), "")
term.AssertExec(fmt.Sprintf("goroutine %d frame %d locals", gid, fid), "(no locals)\n")
argsOut := strings.Split(term.MustExec(fmt.Sprintf("goroutine %d frame %d args", gid, fid)), "\n")
if len(argsOut) != 4 || argsOut[3] != "" {
t.Fatalf("Wrong number of arguments in goroutine %d frame %d: %v", gid, fid, argsOut)
@ -347,3 +347,13 @@ func TestOnPrefix(t *testing.T) {
}
})
}
func TestNoVars(t *testing.T) {
withTestTerminal("locationsUpperCase", t, func(term *FakeTerminal) {
term.MustExec("b main.main")
term.MustExec("continue")
term.AssertExec("args", "(no args)\n")
term.AssertExec("locals", "(no locals)\n")
term.AssertExec("vars filterThatMatchesNothing", "(no vars)\n")
})
}