summaryrefslogtreecommitdiff
path: root/test/librechroot-test.sh
diff options
context:
space:
mode:
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 ]]