terminal: bugfix: tolerate spurious spaces after command prefixes

Expressions such as:

 frame 0    list
 frame   0   list
 on abreakpoint     print x
 goroutine    1    frame     0     list

should all execute correctly

Fixes #712
This commit is contained in:
aarzilli
2017-04-19 12:17:21 +02:00
committed by Derek Parker
parent 182f805094
commit 86a59c52a6
4 changed files with 22 additions and 38 deletions

View File

@ -38,8 +38,6 @@ type FakeTerminal struct {
}
func (ft *FakeTerminal) Exec(cmdstr string) (outstr string, err error) {
cmdstr, args := parseCommand(cmdstr)
outfh, err := ioutil.TempFile("", "cmdtestout")
if err != nil {
ft.t.Fatalf("could not create temporary file: %v", err)
@ -57,7 +55,7 @@ func (ft *FakeTerminal) Exec(cmdstr string) (outstr string, err error) {
outstr = string(outbs)
os.Remove(outfh.Name())
}()
err = ft.cmds.Call(cmdstr, args, ft.Term)
err = ft.cmds.Call(cmdstr, ft.Term)
return
}
@ -305,7 +303,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), "(no locals)\n")
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)