From f32038482725b6166aaa6b45a2cf7b211939e3a0 Mon Sep 17 00:00:00 2001 From: finefoot <33361833+finefoot@users.noreply.github.com> Date: Sun, 19 Apr 2020 22:24:11 +0200 Subject: [PATCH] Fix testing of unsuccessful mount --- src/borg/testsuite/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/borg/testsuite/__init__.py b/src/borg/testsuite/__init__.py index 2f4a0f070..5068a1411 100644 --- a/src/borg/testsuite/__init__.py +++ b/src/borg/testsuite/__init__.py @@ -18,6 +18,7 @@ from ..xattr import get_all from ..platform import get_flags from ..helpers import umount +from ..helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR from .. import platform # Note: this is used by borg.selftest, do not use or import py.test functionality here. @@ -253,6 +254,14 @@ def fuse_mount(self, location, mountpoint=None, *options, **kwargs): # mount a read-only repo. kwargs['fork'] = True self.cmd('mount', location, mountpoint, *options, **kwargs) + if kwargs.get('exit_code', EXIT_SUCCESS) == EXIT_ERROR: + # If argument `exit_code = EXIT_ERROR`, then this call + # is testing the behavior of an unsuccessful mount and + # we must not continue, as there is no mount to work + # with. The test itself has already failed or succeeded + # with the call to `self.cmd`, above. + yield + return self.wait_for_mountstate(mountpoint, mounted=True) yield umount(mountpoint)