summaryrefslogtreecommitdiff
path: root/test/helper.sh
diff options
context:
space:
mode:
authorGravatar patrick brisbin <pbrisbin@gmail.com>2013-08-23 14:31:32 -0400
committerGravatar Mike Burns <mike@mike-burns.com>2014-04-08 11:37:36 +0200
commita5344a3940f292d8d4f8907f92a54bf726b87e44 (patch)
tree9c6030113ca0db2f83626f4f68857cb0de43f475 /test/helper.sh
parenta7c2b6bed845b8512e878c992e07841ea9b88462 (diff)
An integration test suite
This test suite uses cram to run integration tests through `/bin/sh`. The tests are all high-level acceptance tests; they should work regardless of the implemention code. To run them, you must first install cram: sudo pip install cram Then the `check` target will run them: make check Failure output should be printed clearly to stdout, but in general: full test output is in `test/test-suite.log` and output specific to a test named `foo.t` is in `foo.t.log`. Tests are now encouraged in `CONTRIBUTING.md` as part of the normal pull request process. This is a TAP-enabled test suite.
Diffstat (limited to 'test/helper.sh')
-rw-r--r--test/helper.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/helper.sh b/test/helper.sh
new file mode 100644
index 0000000..539e270
--- /dev/null
+++ b/test/helper.sh
@@ -0,0 +1,34 @@
+for bin in lsrc mkrc rcup rcdn; do
+ chmod +x "$TESTDIR/../bin"/$bin
+done
+
+export HOME="$PWD"
+export PATH="$TESTDIR/../bin:$PATH"
+export RCRC="$HOME/.rcrc"
+export RCM_LIB="$TESTDIR/../share"
+
+mkdir .dotfiles
+
+assert() {
+ local msg="$1"; shift
+
+ test "$@" || echo "Failed assertion: $msg"
+
+ return 0
+}
+
+refute() {
+ local msg="$1"; shift
+
+ test "$@" && echo "Failed assertion: $msg"
+
+ return 0
+}
+
+assert_linked() {
+ local from="$1" to="$2"
+ local resolved="$(readlink -f "$from")"
+
+ assert "$from should be a symlink" -h "$from"
+ assert "$from should resolve to $to, resolved to $resolved" "$resolved" = "$to"
+}