tests: Return 77 when skipping tests

77 is the special value meaning that the test was skipped. Both meson
make check will display the information correctly.

Note that the test is currently executed directly in check-local. So add
a workaround to ignore the 77 error code and exit 0 instead in that
case.
This commit is contained in:
Benjamin Berg 2021-09-01 12:27:33 +02:00 committed by Bastien Nocera
parent fbbcb0c03f
commit 46ed299451
2 changed files with 6 additions and 4 deletions

View file

@ -105,7 +105,9 @@ if UP_BUILD_TESTS
check-local: upowerd
# To launch a single test
# env GI_TYPELIB_PATH=$(top_builddir)/libupower-glib:$(GI_TYPELIB_PATH) LD_LIBRARY_PATH=$(top_builddir)/libupower-glib/.libs:$(LD_LIBRARY_PATH) top_builddir=$(top_builddir) $(srcdir)/linux/integration-test -v Tests.test_bluetooth_le_mouse
env GI_TYPELIB_PATH=$(top_builddir)/libupower-glib:$(GI_TYPELIB_PATH) LD_LIBRARY_PATH=$(top_builddir)/libupower-glib/.libs:$(LD_LIBRARY_PATH) top_builddir=$(top_builddir) $(srcdir)/linux/integration-test -v
env GI_TYPELIB_PATH=$(top_builddir)/libupower-glib:$(GI_TYPELIB_PATH) LD_LIBRARY_PATH=$(top_builddir)/libupower-glib/.libs:$(LD_LIBRARY_PATH) top_builddir=$(top_builddir) $(srcdir)/linux/integration-test -v; \
res=$$?; test $$res -eq 77 && res=0; \
exit $$res
endif
endif

View file

@ -34,20 +34,20 @@ try:
from gi.repository import UPowerGlib
except ImportError as e:
sys.stderr.write('Skipping tests, PyGobject not available for Python 3, or missing GI typelibs: %s\n' % str(e))
sys.exit(0)
sys.exit(77)
try:
gi.require_version('UMockdev', '1.0')
from gi.repository import UMockdev
except ImportError:
sys.stderr.write('Skipping tests, umockdev not available (https://github.com/martinpitt/umockdev)\n')
sys.exit(0)
sys.exit(77)
try:
import dbusmock
except ImportError:
sys.stderr.write('Skipping tests, python-dbusmock not available (http://pypi.python.org/pypi/python-dbusmock).\n')
sys.exit(0)
sys.exit(77)
UP = 'org.freedesktop.UPower'