2016-11-22 15:57:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
2018-08-19 22:34:53 +00:00
|
|
|
|
|
|
|
"github.com/fatih/color"
|
2016-11-22 15:57:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
2018-08-19 22:34:53 +00:00
|
|
|
green := color.New(color.FgGreen).SprintFunc()
|
|
|
|
red := color.New(color.FgRed).SprintFunc()
|
2016-11-22 15:57:47 +00:00
|
|
|
|
|
|
|
failed := 0
|
|
|
|
for _, arg := range flag.Args() {
|
|
|
|
cmd := exec.Command("bash", arg)
|
2017-01-20 16:29:59 +00:00
|
|
|
if os.Getenv("TMPDIR") != "" {
|
|
|
|
cmd.Env = append(cmd.Env, "TMPDIR="+os.Getenv("TMPDIR"))
|
|
|
|
}
|
2016-11-22 15:57:47 +00:00
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
cmd.Stdout = os.Stdout
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
|
|
failed++
|
2018-08-19 22:34:53 +00:00
|
|
|
fmt.Fprintf(os.Stderr, red("FAILED: %s\n"), arg)
|
2016-11-22 15:57:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if failed > 0 {
|
2018-08-19 22:34:53 +00:00
|
|
|
fmt.Fprintf(os.Stderr, red("%d FAILED tests\n"), failed)
|
2016-11-22 15:57:47 +00:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
2018-08-19 22:34:53 +00:00
|
|
|
fmt.Fprintf(os.Stdout, green("SUCCESS: no cli tests failed\n"))
|
2016-11-22 15:57:47 +00:00
|
|
|
}
|