diff --git a/README.md b/README.md index f10c6df..1014b26 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,18 @@ you can send questions to . Developing ---------- -Build + test + run: +Build+ run: ```bash ./moar.sh ``` +Run integration tests: + +```bash +./test.sh +``` + Making a new Release -------------------- diff --git a/integration-tests/test-to-file.sh b/integration-tests/test-to-file.sh new file mode 100755 index 0000000..f22cc57 --- /dev/null +++ b/integration-tests/test-to-file.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Verify sending the output to a file + +set -e -o pipefail + +echo Test redirecting a file by name into file by redirecting stdout... +RESULT="$(mktemp)" +./moar moar.go > "$RESULT" +diff -u moar.go "$RESULT" +rm "$RESULT" + +echo Test reading from redirected stdin, writing to redirected stdout... +RESULT="$(mktemp)" +./moar < moar.go > "$RESULT" +diff -u moar.go "$RESULT" +rm "$RESULT" diff --git a/moar.sh b/moar.sh index 3ca2efe..fc88d00 100755 --- a/moar.sh +++ b/moar.sh @@ -2,14 +2,10 @@ set -e -o pipefail -# Ensure we can cross compile -GOOS=linux GOARCH=amd64 go build -GOOS=linux GOARCH=386 go build -GOOS=darwin GOARCH=amd64 go build +rm -f moar go test -# Make sure we're built for the current platform go build ./moar "$@" diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..de82e22 --- /dev/null +++ b/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Ensure we can cross compile +GOOS=linux GOARCH=386 go build +GOOS=darwin GOARCH=amd64 go build + +# Unit tests first... +go test + +# ... then integration. +go build +for TEST in integration-tests/*.sh ; do + echo "Executing: $(basename "$TEST")..." + "$TEST" +done