Skip to content

Commit

Permalink
- add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansissel committed Sep 6, 2011
1 parent ba14cf6 commit d44a098
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/dir-deb-with-prefix.out
Original file line number Diff line number Diff line change
@@ -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/
17 changes: 17 additions & 0 deletions test/dir-deb-with-prefix.test
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 16 additions & 0 deletions test/dir-rpm-with-prefix.out
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions test/dir-rpm-with-prefix.test
Original file line number Diff line number Diff line change
@@ -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
}
46 changes: 46 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
@@ -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.