Skip to content

Commit 3d777f9

Browse files
committed
tests/int: fix teardown in mounts_sshfs.bats
Function teardown assumes that every test case will call setup_sshfs. Currently, this assumption is true, but once a test case that won't call setup_sshfs is added (say because it has some extra "requires" or "skip"), it will break bats, so any bats invocation involving such a test case will end up hanging after the last test case is run. The reason is, we have set -u in helpers.bash to help catching the use of undefined variables. In the above scenario, such a variable is DIR, which is referenced in teardown but is only defined after a call to setup_sshfs. As a result, bash that is running the teardown function will exit upon seeing the first $DIR, and thus teardown_bundle won't be run. This, in turn, results in a stale recvtty process, which inherits bats' fd 3. Until that fd is closed, bats waits for test logs. Long story short, the fix is to - check if DIR is set before referencing it; - unset it after unmount. PS it is still not clear why there is no diagnostics about the failed teardown. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 80320b7 commit 3d777f9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/integration/mounts_sshfs.bats

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ function setup() {
88
}
99

1010
function teardown() {
11-
# Some distros do not have fusermount installed
12-
# as a dependency of fuse-sshfs, and good ol' umount works.
13-
fusermount -u "$DIR" || umount "$DIR"
11+
if [ -v DIR ]; then
12+
# Some distros do not have fusermount installed
13+
# as a dependency of fuse-sshfs, and good ol' umount works.
14+
fusermount -u "$DIR" || umount "$DIR"
15+
unset DIR
16+
fi
1417

1518
teardown_bundle
1619
}

0 commit comments

Comments
 (0)