45 lines
594 B
Go
45 lines
594 B
Go
|
package shelly
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"os"
|
||
|
"os/exec"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestLines(t *testing.T) {
|
||
|
lines, err := Lines("; \";\" ;;")
|
||
|
//Lines("a\nb\\\\nc")
|
||
|
// Lines(`
|
||
|
//"A STR" 1 2 "a b" 1.23 \n &
|
||
|
//"STR \\ with escape \n chars \t" 1 234 true
|
||
|
//ls -larth
|
||
|
//pwd
|
||
|
//whoami
|
||
|
//date`)
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
for _, l := range lines {
|
||
|
log.Printf("%#v", l)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestExec(t *testing.T) {
|
||
|
err := Exec(`
|
||
|
ls -larth
|
||
|
pwd
|
||
|
whoami
|
||
|
date`, &Opts{
|
||
|
SetupProc: func(cmd *exec.Cmd) {
|
||
|
cmd.Stdout = os.Stdout
|
||
|
cmd.Stderr = os.Stderr
|
||
|
},
|
||
|
})
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
}
|