Skip to content
Browse files

- add tests

  • Loading branch information...
1 parent ba14cf6 commit d44a0988bdb4ca11e3ca008365c131ffca2b03f5 @jordansissel committed Sep 5, 2011
Showing with 113 additions and 0 deletions.
  1. +19 −0 test/dir-deb-with-prefix.out
  2. +17 −0 test/dir-deb-with-prefix.test
  3. +16 −0 test/dir-rpm-with-prefix.out
  4. +15 −0 test/dir-rpm-with-prefix.test
  5. +46 −0 test/test.sh
View
19 test/dir-deb-with-prefix.out
@@ -0,0 +1,19 @@
+./
+./opt/
+./opt/foo/
+./opt/foo/bar/
+./opt/foo/bar/a/
+./opt/foo/bar/a/e/
+./opt/foo/bar/a/d/
+./opt/foo/bar/a/d/hello
+./opt/foo/bar/a/f/
+./opt/foo/bar/a/hello
+./opt/foo/bar/b/
+./opt/foo/bar/b/e/
+./opt/foo/bar/b/d/
+./opt/foo/bar/b/f/
+./opt/foo/bar/c/
+./opt/foo/bar/c/e/
+./opt/foo/bar/c/d/
+./opt/foo/bar/c/d/hello
+./opt/foo/bar/c/f/
View
17 test/dir-deb-with-prefix.test
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+run() {
+ mkdir -p $tmpdir/{a,b,c}/{d,e,f}
+ touch $tmpdir/a/hello
+ touch $tmpdir/a/d/hello
+ touch $tmpdir/c/d/hello
+
+ prefix=/opt/foo/bar
+
+ fpm -s dir -t deb -n testing -a all --prefix $prefix -C $tmpdir
+
+ file=testing_1.0_all.deb
+ dpkg -c $file | fex '{6:}' > $output
+
+ rm $file
+}
View
16 test/dir-rpm-with-prefix.out
@@ -0,0 +1,16 @@
+/opt/foo/bar
+/opt/foo/bar/a
+/opt/foo/bar/a/d
+/opt/foo/bar/a/d/hello
+/opt/foo/bar/a/e
+/opt/foo/bar/a/f
+/opt/foo/bar/a/hello
+/opt/foo/bar/b
+/opt/foo/bar/b/d
+/opt/foo/bar/b/e
+/opt/foo/bar/b/f
+/opt/foo/bar/c
+/opt/foo/bar/c/d
+/opt/foo/bar/c/d/hello
+/opt/foo/bar/c/e
+/opt/foo/bar/c/f
View
15 test/dir-rpm-with-prefix.test
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+run() {
+ mkdir -p $tmpdir/{a,b,c}/{d,e,f}
+ touch $tmpdir/a/hello
+ touch $tmpdir/a/d/hello
+ touch $tmpdir/c/d/hello
+
+ prefix=/opt/foo/bar
+
+ fpm -s dir -t rpm -n testing -a all --prefix $prefix -C $tmpdir
+
+ rpm -qlp testing-1.0.noarch.rpm > $output
+ rm testing-1.0.noarch.rpm
+}
View
46 test/test.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+fpm() {
+ ../bin/fpm "$@" > $debugout 2> $debugerr
+}
+
+cleanup() {
+ rm -f $tmpout $debugout $debugerr
+ [ ! -z "$tmpdir" ] && rm -r $tmpdir
+}
+
+main() {
+ set -e
+ test="$1"
+ tmpdir=$(mktemp -d)
+ debugout=$(mktemp)
+ debugerr=$(mktemp)
+ output=$(mktemp)
+ expected=${1%.test}.out
+
+ echo "Loading $test"
+ . "./$test"
+
+ # Run the test.
+ run
+
+ # Compare output
+ diff -u $output $expected
+ diffstatus=$?
+
+ cleanup
+
+ if [ $diffstatus -ne 0 ] ; then
+ echo "Fail: $test"
+ echo "FPM STDOUT"
+ cat $debugout
+ echo "FPM STDERR"
+ cat $debugerr
+ return 1
+ else
+ echo "OK: $test"
+ return 0
+ fi
+}
+
+main "$@"

0 comments on commit d44a098

Please sign in to comment.
Something went wrong with that request. Please try again.