shelly/lib_test.go

48 lines
637 B
Go
Raw Normal View History

2021-10-24 21:31:09 +00:00
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(`
2021-10-25 00:42:20 +00:00
ls -larth &
pwd &
whoami &
2021-10-24 21:31:09 +00:00
date`, &Opts{
2021-10-25 00:42:20 +00:00
Await: false,
2021-10-24 21:31:09 +00:00
SetupProc: func(cmd *exec.Cmd) {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
},
})
if err != nil {
t.Fatal(err)
}
2021-10-25 00:42:20 +00:00
log.Printf("DONE")
2021-10-24 21:31:09 +00:00
}