diff options
| author | Tharre <tharre3@gmail.com> | 2015-01-25 20:38:20 +0100 | 
|---|---|---|
| committer | Tharre <tharre3@gmail.com> | 2015-01-25 20:41:16 +0100 | 
| commit | 5322817d1c382d5ba377be0080bd4c5da525cd2f (patch) | |
| tree | a6053e4c13e72ed29f6441e7626b5d751d79102a | |
| parent | c4a2f0dec7bd7d3f50115bb88467a0841c91d957 (diff) | |
| download | redo-5322817d1c382d5ba377be0080bd4c5da525cd2f.tar.gz redo-5322817d1c382d5ba377be0080bd4c5da525cd2f.tar.xz redo-5322817d1c382d5ba377be0080bd4c5da525cd2f.zip  | |
Add testing framework `bats`, this fixes #6
| -rw-r--r-- | .travis.yml | 6 | ||||
| -rw-r--r-- | test/always.bats | 8 | ||||
| -rw-r--r-- | test/always.do | 5 | ||||
| -rw-r--r-- | test/always_test.do | 1 | ||||
| -rw-r--r-- | test/args.bats | 8 | ||||
| -rw-r--r-- | test/args_test.ext.do | 3 | ||||
| -rw-r--r-- | test/fail.bats | 13 | ||||
| -rw-r--r-- | test/fail.do | 2 | ||||
| -rw-r--r-- | test/no-output.bats | 8 | ||||
| -rw-r--r-- | test/no-output_result.do | 1 | ||||
| -rw-r--r-- | test/test_helper.bash | 12 | 
11 files changed, 66 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml index 82f52cd..2f50da2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,8 @@ language: c  compiler:    - gcc    - clang -script: ./autogen.sh && ./configure && ./build.sh +script: ./autogen.sh && ./configure && ./build.sh && bats test/ +before_install: +  - sudo add-apt-repository ppa:duggan/bats --yes +  - sudo apt-get update -qq +  - sudo apt-get install -qq bats diff --git a/test/always.bats b/test/always.bats new file mode 100644 index 0000000..a4ab1a2 --- /dev/null +++ b/test/always.bats @@ -0,0 +1,8 @@ +#!/usr/bin/env bats + +load test_helper + +@test "check if do-files marked with always really do execute always" { +	run redo always +	[ $status -eq 0 ] && [ -e always_result ] +} diff --git a/test/always.do b/test/always.do new file mode 100644 index 0000000..0c112e1 --- /dev/null +++ b/test/always.do @@ -0,0 +1,5 @@ +redo-ifchange always_test + +rm -f always_result + +redo-ifchange always_test diff --git a/test/always_test.do b/test/always_test.do new file mode 100644 index 0000000..e73e2e0 --- /dev/null +++ b/test/always_test.do @@ -0,0 +1 @@ +touch always_result diff --git a/test/args.bats b/test/args.bats new file mode 100644 index 0000000..4115b66 --- /dev/null +++ b/test/args.bats @@ -0,0 +1,8 @@ +#!/usr/bin/env bats + +load test_helper + +@test "check arguments supplied to .do files" { +	run redo args_test.ext +	[ $status -eq 0 ] +} diff --git a/test/args_test.ext.do b/test/args_test.ext.do new file mode 100644 index 0000000..588192a --- /dev/null +++ b/test/args_test.ext.do @@ -0,0 +1,3 @@ +[ "$1" = "args_test.ext" ] && +[ "$2" = "args_test" ] && +[ "$3" != "args_test.ext" ] diff --git a/test/fail.bats b/test/fail.bats new file mode 100644 index 0000000..1a77ced --- /dev/null +++ b/test/fail.bats @@ -0,0 +1,13 @@ +#!/usr/bin/env bats + +load test_helper + +@test "invoke with target without do-file" { +	run redo this-does-not-exist +	[ $status -ne 0 ] +} + +@test "invoke with failing do-file" { +	run redo fail +	[ $status -ne 0 ] && [ ! -e fail_result ] +} diff --git a/test/fail.do b/test/fail.do new file mode 100644 index 0000000..f87b607 --- /dev/null +++ b/test/fail.do @@ -0,0 +1,2 @@ +this-shall-fail +touch fail_result diff --git a/test/no-output.bats b/test/no-output.bats new file mode 100644 index 0000000..c492e4f --- /dev/null +++ b/test/no-output.bats @@ -0,0 +1,8 @@ +#!/usr/bin/env bats + +load test_helper + +@test "produce empty result" { +	run redo no-output_result +	[ $status -eq 0 ] && [ ! -e no-output_result ] +} diff --git a/test/no-output_result.do b/test/no-output_result.do new file mode 100644 index 0000000..b58ff30 --- /dev/null +++ b/test/no-output_result.do @@ -0,0 +1 @@ +touch $3 diff --git a/test/test_helper.bash b/test/test_helper.bash new file mode 100644 index 0000000..2c26399 --- /dev/null +++ b/test/test_helper.bash @@ -0,0 +1,12 @@ +teardown() { +	rm -rf .redo/ + +	# remove all helper files +	for i in *.bats; do +		rm -f "${i%%.*}_result" +	done +} + +setup() { +	cd "$BATS_TEST_DIRNAME" +}  | 
