Share test code between test suites

This commit is contained in:
Tor Arne Vestbø
2018-09-17 18:51:51 +02:00
parent 24400ff67b
commit fef3aeadfa
3 changed files with 19 additions and 20 deletions

View File

@@ -1,16 +1,9 @@
#!/usr/bin/env testrunner.sh
source "$(dirname "$0")/testhelpers.sh"
function setup() {
test ! -z "$TEST_BUNDLE"
mount_dir=$(mktemp -d)
sparsebundlefs -s -f -D $TEST_BUNDLE $mount_dir &
pid=$!
for i in {0..50}; do
kill -0 $pid >/dev/null 2>&1
# FIXME: Find actual mount callback in fuse?
grep -q "bundle has" $test_output_file && break || sleep 0.1
done
dmg_file=$mount_dir/sparsebundle.dmg
mount_sparsebundle
}
function test_dmg_exists_after_mounting() {

View File

@@ -1,16 +1,9 @@
#!/usr/bin/env testrunner.sh
source "$(dirname "$0")/testhelpers.sh"
function setup() {
test ! -z "$TEST_BUNDLE"
mount_dir=$(mktemp -d)
sparsebundlefs -s -f -D -o allow_other $TEST_BUNDLE $mount_dir &
pid=$!
for i in {0..50}; do
kill -0 $pid >/dev/null 2>&1
# FIXME: Find actual mount callback in fuse?
grep -q "bundle has" $test_output_file && break || sleep 0.1
done
dmg_file=$mount_dir/sparsebundle.dmg
mount_sparsebundle -o allow_other
}
function test_dmg_has_correct_permissions() {

13
tests/testhelpers.sh Normal file
View File

@@ -0,0 +1,13 @@
function mount_sparsebundle() {
test ! -z "$TEST_BUNDLE"
mount_dir=$(mktemp -d)
sparsebundlefs -s -f -D $* $TEST_BUNDLE $mount_dir &
pid=$!
for i in {0..50}; do
kill -0 $pid >/dev/null 2>&1
# FIXME: Find actual mount callback in fuse?
grep -q "bundle has" $test_output_file && break || sleep 0.1
done
dmg_file=$mount_dir/sparsebundle.dmg
}