1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-12-22 22:06:29 +00:00
go-mtree/test/cli.go
Vincent Batts 235566d9e0
cli.test: passthrough and use TMPDIR
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-01-20 11:30:54 -05:00

30 lines
508 B
Go

package main
import (
"flag"
"fmt"
"os"
"os/exec"
)
func main() {
flag.Parse()
failed := 0
for _, arg := range flag.Args() {
cmd := exec.Command("bash", arg)
if os.Getenv("TMPDIR") != "" {
cmd.Env = append(cmd.Env, "TMPDIR="+os.Getenv("TMPDIR"))
}
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
failed++
fmt.Fprintf(os.Stderr, "FAILED: %s\n", arg)
}
}
if failed > 0 {
fmt.Fprintf(os.Stderr, "%d FAILED tests\n", failed)
os.Exit(1)
}
}