summaryrefslogtreecommitdiff
path: root/test/librechroot-test.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-06-04 22:02:21 -0600
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-06-05 20:06:25 -0600
commita329839346a3c2c9591985b70841858dd575846f (patch)
treeb7cbde15e7e46d42726058b9e318ce6a8e85c29c /test/librechroot-test.sh
parent695b9b8af8e2629d460d877abab4bdf216c71df2 (diff)
add a system to skip tests that require networking or sudo.
Diffstat (limited to 'test/librechroot-test.sh')
-rw-r--r--test/librechroot-test.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh
index 8c9d690..7096e37 100644
--- a/test/librechroot-test.sh
+++ b/test/librechroot-test.sh
@@ -2,19 +2,22 @@
describe librechroot
+. ./test-common.sh
+
before() {
- tmpdir=$(mktemp -d --tmpdir test-librechroot.XXXXXXXXXXXX)
+ _before librechroot
mkdir -p "$XDG_CONFIG_HOME"/libretools
echo "CHROOTDIR='$tmpdir'" > "$XDG_CONFIG_HOME"/libretools/chroot.conf
echo "CHROOT='default'" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
- stat=0
}
after() {
- rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME"
+ _after
}
+
it_creates_repo_for_new_chroots() {
+ require network sudo || return 0
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
sudo -EH librechroot run test -r /repo/repo.db
}
@@ -43,7 +46,9 @@ it_displays_help_and_fails_with_0_args() {
[[ "$(sed 1q $tmpdir/stderr)" =~ Usage:.* ]]
}
+# requires sudo so we know it's not failing because it needs root
it_fails_for_unknown_commands() {
+ require sudo || return 0
sudo -EH librechroot phony >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
[[ $stat != 0 ]]
@@ -51,7 +56,9 @@ it_fails_for_unknown_commands() {
[[ -n "$(cat $tmpdir/stderr)" ]]
}
+# requires sudo so we know it's not failing because it needs root
it_fails_for_unknown_flags() {
+ require sudo || return 0
sudo -EH librechroot -q >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
[[ $stat != 0 ]]