From 36add2263716cb282158d4587863b042d0c2c0e2 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 26 May 2014 13:52:55 +0100 Subject: [PATCH] Use test-runner.sh instead of homegrown test.sh --- .gitignore | 3 +- Makefile | 38 ++++++++++++++----- test.sh | 35 ----------------- test/lib/{env-test.sh => env.test.sh} | 0 ...and_path-test.sh => __expand_path.test.sh} | 0 ...ession-test.sh => __go_to_session.test.sh} | 0 test/lib/{runtime-test.sh => runtime.test.sh} | 0 test/lib/{util-test.sh => util.test.sh} | 0 ...er-tmux-test.sh => tmuxifier-tmux.test.sh} | 0 9 files changed, 30 insertions(+), 46 deletions(-) delete mode 100755 test.sh rename test/lib/{env-test.sh => env.test.sh} (100%) rename test/lib/layout-helpers/{__expand_path-test.sh => __expand_path.test.sh} (100%) rename test/lib/layout-helpers/{__go_to_session-test.sh => __go_to_session.test.sh} (100%) rename test/lib/{runtime-test.sh => runtime.test.sh} (100%) rename test/lib/{util-test.sh => util.test.sh} (100%) rename test/libexec/{tmuxifier-tmux-test.sh => tmuxifier-tmux.test.sh} (100%) diff --git a/.gitignore b/.gitignore index 71ab7b8..6946830 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +test-runner.sh test/assert.sh -test/stub.sh \ No newline at end of file +test/stub.sh diff --git a/Makefile b/Makefile index 23aa059..8fc5798 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,24 @@ -test: prepare - ./test.sh +test: bootstrap + ./test-runner.sh -prepare: test/assert.sh test/stub.sh +bootstrap: test-runner.sh test/assert.sh test/stub.sh + +clean: remove-test-runner.sh remove-assert.sh remove-stub.sh + +test-runner.sh: + test -f "test-runner.sh" || \ + echo "fetching test-runner.sh..." && \ + curl -s -L -o test-runner.sh \ + https://github.com/jimeh/test-runner.sh/raw/v0.1.0/test-runner.sh && \ + chmod +x test-runner.sh + +remove-test-runner.sh: + ( \ + test -f "test-runner.sh" && rm "test-runner.sh" && \ + echo "removed test-runner.sh"\ + ) || exit 0 + +update-test-runner.sh: remove-test-runner.sh test-runner.sh test/assert.sh: test -f "test/assert.sh" || ( \ @@ -10,13 +27,13 @@ test/assert.sh: https://raw.github.com/lehmannro/assert.sh/v1.0.2/assert.sh \ ) -update-assert.sh: remove-assert.sh test/assert.sh - remove-assert.sh: test -f "test/assert.sh" && \ rm "test/assert.sh" && \ echo "removed test/assert.sh" +update-assert.sh: remove-assert.sh test/assert.sh + test/stub.sh: test -f "test/stub.sh" || ( \ echo "fetching test/stub.sh..." && \ @@ -24,14 +41,15 @@ test/stub.sh: https://raw.github.com/jimeh/stub.sh/v1.0.1/stub.sh \ ) -update-stub.sh: remove-stub.sh test/stub.sh - remove-stub.sh: test -f "test/stub.sh" && \ rm "test/stub.sh" && \ echo "removed test/stub.sh" +update-stub.sh: remove-stub.sh test/stub.sh + .SILENT: -.PHONY: test prepare \ - test/assert.sh update-assert.sh remove-assert.sh \ - test/stub.sh update-stub.sh remove-stub.sh +.PHONY: test bootstrap clean \ + test-runner.sh remove-test-runner.sh update-test-runner.sh \ + test/assert.sh remove-assert.sh update-assert.sh \ + test/stub.sh remove-stub.sh update-stub.sh diff --git a/test.sh b/test.sh deleted file mode 100755 index f9ae4f1..0000000 --- a/test.sh +++ /dev/null @@ -1,35 +0,0 @@ -#! /usr/bin/env bash - -resolve_link() { - $(type -p greadlink readlink | head -1) $1 -} - -abs_dirname() { - local cwd="$(pwd)" - local path="$1" - - while [ -n "$path" ]; do - cd "${path%/*}" - local name="${path##*/}" - path="$(resolve_link "$name" || true)" - done - - pwd - cd "$cwd" -} - - -testdir="$(abs_dirname "$0")/test" -testfiles="$(find "$testdir" -name "*-test.sh")" - -RET=0 -for testfile in $testfiles; do - echo "" - echo -en "$(tput setaf 5)running: " - echo -e "$(tput setaf 6)${testfile/#$(dirname "$testdir")\//}$(tput sgr0)" - cd "$(dirname "$testfile")" - "$testfile" - if [ "$?" != "0" ]; then RET=1; fi -done -echo "" -exit $RET diff --git a/test/lib/env-test.sh b/test/lib/env.test.sh similarity index 100% rename from test/lib/env-test.sh rename to test/lib/env.test.sh diff --git a/test/lib/layout-helpers/__expand_path-test.sh b/test/lib/layout-helpers/__expand_path.test.sh similarity index 100% rename from test/lib/layout-helpers/__expand_path-test.sh rename to test/lib/layout-helpers/__expand_path.test.sh diff --git a/test/lib/layout-helpers/__go_to_session-test.sh b/test/lib/layout-helpers/__go_to_session.test.sh similarity index 100% rename from test/lib/layout-helpers/__go_to_session-test.sh rename to test/lib/layout-helpers/__go_to_session.test.sh diff --git a/test/lib/runtime-test.sh b/test/lib/runtime.test.sh similarity index 100% rename from test/lib/runtime-test.sh rename to test/lib/runtime.test.sh diff --git a/test/lib/util-test.sh b/test/lib/util.test.sh similarity index 100% rename from test/lib/util-test.sh rename to test/lib/util.test.sh diff --git a/test/libexec/tmuxifier-tmux-test.sh b/test/libexec/tmuxifier-tmux.test.sh similarity index 100% rename from test/libexec/tmuxifier-tmux-test.sh rename to test/libexec/tmuxifier-tmux.test.sh