From d44a0988bdb4ca11e3ca008365c131ffca2b03f5 Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Mon, 5 Sep 2011 18:30:39 -0700 Subject: [PATCH] - add tests --- test/dir-deb-with-prefix.out | 19 +++++++++++++++ test/dir-deb-with-prefix.test | 17 +++++++++++++ test/dir-rpm-with-prefix.out | 16 ++++++++++++ test/dir-rpm-with-prefix.test | 15 ++++++++++++ test/test.sh | 46 +++++++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+) create mode 100644 test/dir-deb-with-prefix.out create mode 100644 test/dir-deb-with-prefix.test create mode 100644 test/dir-rpm-with-prefix.out create mode 100644 test/dir-rpm-with-prefix.test create mode 100644 test/test.sh diff --git a/test/dir-deb-with-prefix.out b/test/dir-deb-with-prefix.out new file mode 100644 index 0000000000..c3d6628828 --- /dev/null +++ b/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/ diff --git a/test/dir-deb-with-prefix.test b/test/dir-deb-with-prefix.test new file mode 100644 index 0000000000..6e17df3e2a --- /dev/null +++ b/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 +} diff --git a/test/dir-rpm-with-prefix.out b/test/dir-rpm-with-prefix.out new file mode 100644 index 0000000000..4b2fd4b0c0 --- /dev/null +++ b/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 diff --git a/test/dir-rpm-with-prefix.test b/test/dir-rpm-with-prefix.test new file mode 100644 index 0000000000..cb6e8a6f47 --- /dev/null +++ b/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 +} diff --git a/test/test.sh b/test/test.sh new file mode 100644 index 0000000000..605f911315 --- /dev/null +++ b/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 "$@"