mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 12:47:22 +08:00
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:
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user