diff --git a/Makefile b/Makefile index a428984..220cdbb 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,7 @@ vet: .vet cli.test: .cli.test .cli.test: $(BUILD) $(wildcard ./test/cli/*.sh) - @ for test in ./test/cli/*.sh ; do \ - bash $$test $(CWD) ; \ - done && touch $@ + @go run ./test/cli.go ./test/cli/*.sh && touch $@ .PHONY: build build: $(BUILD) diff --git a/test/cli.go b/test/cli.go new file mode 100644 index 0000000..286dd7f --- /dev/null +++ b/test/cli.go @@ -0,0 +1,26 @@ +package main + +import ( + "flag" + "fmt" + "os" + "os/exec" +) + +func main() { + flag.Parse() + + failed := 0 + for _, arg := range flag.Args() { + cmd := exec.Command("bash", arg) + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + if err := cmd.Run(); err != nil { + failed++ + } + } + if failed > 0 { + fmt.Printf("%d FAILED tests\n", failed) + os.Exit(1) + } +} diff --git a/test/cli/0001.sh b/test/cli/0001.sh index 5119c1b..47162fe 100644 --- a/test/cli/0001.sh +++ b/test/cli/0001.sh @@ -2,7 +2,7 @@ set -e name=$(basename $0) -root=$1 +root="$(dirname $(dirname $(dirname $0)))" gomtree=$(readlink -f ${root}/gomtree) t=$(mktemp -d /tmp/go-mtree.XXXXXX) diff --git a/test/cli/0002.sh b/test/cli/0002.sh index 5bf9a40..c474103 100644 --- a/test/cli/0002.sh +++ b/test/cli/0002.sh @@ -2,7 +2,7 @@ set -e name=$(basename $0) -root=$1 +root="$(dirname $(dirname $(dirname $0)))" gomtree=$(readlink -f ${root}/gomtree) t=$(mktemp -d /tmp/go-mtree.XXXXXX) diff --git a/test/cli/0004.sh b/test/cli/0004.sh index b538285..1488ef0 100644 --- a/test/cli/0004.sh +++ b/test/cli/0004.sh @@ -3,7 +3,7 @@ set -e #set -x name=$(basename $0) -root=$1 +root="$(dirname $(dirname $(dirname $0)))" gomtree=$(readlink -f ${root}/gomtree) t=$(mktemp -d /tmp/go-mtree.XXXXXX) diff --git a/test/cli/0005.sh b/test/cli/0005.sh index 48e025b..a4732d6 100644 --- a/test/cli/0005.sh +++ b/test/cli/0005.sh @@ -2,7 +2,7 @@ set -e name=$(basename $0) -root=$1 +root="$(dirname $(dirname $(dirname $0)))" gomtree=$(readlink -f ${root}/gomtree) t=$(mktemp -d /tmp/go-mtree.XXXXXX) diff --git a/test/cli/0006.sh b/test/cli/0006.sh index 611353a..70b0770 100644 --- a/test/cli/0006.sh +++ b/test/cli/0006.sh @@ -2,7 +2,7 @@ set -e name=$(basename $0) -root=$1 +root="$(dirname $(dirname $(dirname $0)))" gomtree=$(readlink -f ${root}/gomtree) t=$(mktemp -d /tmp/go-mtree.XXXXXX)