1
1
mirror of https://github.com/walles/moar.git synced 2024-11-14 11:25:20 +03:00
moar/test.sh

47 lines
1.2 KiB
Bash
Raw Normal View History

2019-06-09 19:42:25 +03:00
#!/bin/bash
set -e -o pipefail
2019-06-09 19:42:25 +03:00
# Unit tests first
go test github.com/walles/moar/m
2019-06-09 19:42:25 +03:00
2019-07-07 19:34:05 +03:00
# Ensure we can cross compile
2019-08-04 20:07:14 +03:00
# NOTE: Make sure this list matches the one in release.sh
2019-07-07 19:34:05 +03:00
GOOS=linux GOARCH=386 ./build.sh
GOOS=darwin GOARCH=amd64 ./build.sh
# Make sure we have a runnable binary for the current platform when done
./build.sh
2019-07-07 19:34:05 +03:00
# Verify sending the output to a file
RESULT="$(mktemp)"
function cleanup {
rm -rf "$RESULT"
}
trap cleanup EXIT
echo Running to-file redirection tests...
echo Test reading from redirected stdin, writing to redirected stdout...
./moar < moar.go > "$RESULT"
diff -u moar.go "$RESULT"
echo Test redirecting a file by name into file by redirecting stdout...
./moar moar.go > "$RESULT"
diff -u moar.go "$RESULT"
echo Test redirecting non-existing file by name into redirected stdout...
if ./moar does-not-exist >& /dev/null ; then
echo ERROR: Should have failed on non-existing input file name
exit 1
fi
2019-07-07 19:23:57 +03:00
echo Test --version...
./moar --version > /dev/null # Should exit with code 0
diff -u <(./moar --version) <(git describe --tags --dirty)
2019-07-15 23:14:36 +03:00
# FIXME: On unknown command line options, test that help text goes to stderr
echo
echo "All tests passed!"