This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

simple TAP-like test framework and smoke tests

  • Loading branch information...
rtomayko committed Mar 23, 2010
1 parent 36af74d commit b4901665e15d06002d754439be1cd3a38f5a6c1e
Showing with 93 additions and 0 deletions.
  1. +3 −0 Makefile
  2. +1 −0 test/.gitignore
  3. BIN test/specs.4.8.gz
  4. +69 −0 test/test-lib.sh
  5. +20 −0 test/test-rpg.sh
View
@@ -94,6 +94,9 @@ man:
doc: $(DOCHTML)
+test: build
+ cd test && $(SHELL) test-rpg.sh
+
install:
mkdir -p "$(bindir)" || true
for f in $(USERPROGRAMS); do \
View
@@ -0,0 +1 @@
+trash
View
Binary file not shown.
View
@@ -0,0 +1,69 @@
+
+: ${VERBOSE:=false}
+
+unset CDPATH
+
+cd "$(dirname $0)"
+TESTDIR=$(pwd)
+
+test_count=0
+successes=0
+failures=0
+
+output="$testdir/$(basename "$0" .sh).out"
+trap "rm -f $output" 0
+
+succeeds () {
+ test_count=$(( test_count + 1 ))
+ echo "\$ ${2:-$1}" > "$output"
+ eval "( ${2:-$1} )" 1>>"$output" 2>&1
+ ec=$?
+ if test $ec -eq 0
+ then successes=$(( successes + 1 ))
+ printf 'ok %d - %s\n' $test_count "$1"
+ else failures=$(( failures + 1 ))
+ printf 'not ok %d - %s [%d]\n' $test_count "$1" "$ec"
+ fi
+
+ $VERBOSE && dcat $output
+ return 0
+}
+
+fails () {
+ if test $# -eq 1
+ then succeeds "! $1"
+ else succeeds "$1" "! $2"
+ fi
+}
+
+diag () { echo "$@" | sed 's/^/# /'; }
+dcat () { cat "$@" | sed 's/^/# /'; }
+desc () { diag "$@"; }
+
+# setup environment for a fake rpg environment under ./trash
+RPGPATH="$TESTDIR/trash"
+RPGBIN="$RPGPATH/bin"
+RPGLIB="$RPGPATH/lib"
+RPGMAN="$RPGPATH/man"
+RPGDB="$RPGPATH/db"
+RPGINDEX="$RPGPATH/index"
+RPGPACKS="$RPGPATH/packs"
+RPGCACHE="$RPGPATH/cache"
+export RPGPATH RPGBIN RPGLIB RPGMAN RPGDB RPGINDEX RPGPACKS RPGCACHE
+
+RPGSYSCONF=false
+RPGUSERCONF=false
+RPGTRACE=false
+RPGSHOWBUILD=false
+RPGSTALETIME='1 day'
+RPGSPECSURL="file://$TESTDIR/specs.4.8.gz"
+export RPGSYSCONF RPGUSERCONF RPGTRACE RPGSHOWBUILD RPGSTALETIME RPGSPECSURL
+
+# put source directory on PATH so we're running the right rpg commands
+PATH="$(dirname $TESTDIR):$PATH"
+export PATH
+
+setup () {
+ rm -rf "$TESTDIR/trash"
+ return 0
+}
View
@@ -0,0 +1,20 @@
+#
+. ./test-lib.sh
+
+desc 'main rpg command tests'
+setup
+
+succeeds 'rpg'
+succeeds 'rpg --help'
+fails 'passing invalid arguments' 'rpg -X'
+
+succeeds 'enabling verbose mode with -v' 'rpg -v help'
+succeeds 'enabling trace mode with -x' 'rpg -x help'
+
+succeeds 'rpg config'
+succeeds 'rpg env'
+succeeds 'rpg sync'
+succeeds 'rpg list'
+succeeds 'rpg prepare rails'
+succeeds 'rpg install rails'
+succeeds 'rpg fsck'

0 comments on commit b490166

Please sign in to comment.