terminal: Implements init file and source command

The 'source' command reads the file specified as argument and executes
it as a list of delve commands.
Additionally a flag '--init' can be passed to delve specifying a file
containing a list of commands to execute on startup.

Issue #96
This commit is contained in:
aarzilli
2015-09-29 18:40:12 +02:00
committed by Derek Parker
parent bc9ac0ec78
commit eb2bc2a7ee
6 changed files with 107 additions and 7 deletions

View File

@ -2,7 +2,10 @@ package terminal
import (
"fmt"
"path/filepath"
"testing"
"github.com/derekparker/delve/proc/test"
)
func TestCommandDefault(t *testing.T) {
@ -65,3 +68,33 @@ func TestCommandThread(t *testing.T) {
t.Fatal("wrong command output: ", err.Error())
}
}
func TestExecuteFile(t *testing.T) {
breakCount := 0
traceCount := 0
c := &Commands{
client: nil,
cmds: []command{
{aliases: []string{"trace"}, cmdFn: func(t *Term, args ...string) error {
traceCount++
return nil
}},
{aliases: []string{"break"}, cmdFn: func(t *Term, args ...string) error {
breakCount++
return nil
}},
},
}
fixturesDir := test.FindFixturesDir()
err := c.executeFile(nil, filepath.Join(fixturesDir, "bpfile"))
if err != nil {
t.Fatalf("executeFile: %v", err)
}
if breakCount != 1 || traceCount != 1 {
t.Fatalf("Wrong counts break: %d trace: %d\n", breakCount, traceCount)
}
}