From 8493cfb0f1f758be0595dea8063e4bd1ec786cff Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 1 Nov 2015 22:18:47 +0100 Subject: [PATCH 1/5] fix .coverragerc omits seems like they need a */ prefix also: exclude everything below support/ - this is 3rd party stuff. --- .coveragerc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.coveragerc b/.coveragerc index 7c4ccf9e1..0ae90754e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,10 +2,10 @@ branch = True source = borg omit = - borg/__init__.py - borg/__main__.py - borg/_version.py - borg/support/*.py + */borg/__init__.py + */borg/__main__.py + */borg/_version.py + */borg/support/* [report] exclude_lines = From d7b6cc352726405fd81bf6ff6cef969bde16f8f0 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 1 Nov 2015 22:36:18 +0100 Subject: [PATCH 2/5] fix .coverragerc path as the cwd is in toxworkdir, .coveragerc is in ../ --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index c260b5063..a000e1af2 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,6 @@ changedir = {toxworkdir} deps = -rrequirements.d/development.txt attic -commands = py.test --cov=borg --benchmark-skip --pyargs {posargs:borg.testsuite} +commands = py.test --cov=borg --cov-config=../.coveragerc --benchmark-skip --pyargs {posargs:borg.testsuite} # fakeroot -u needs some env vars: passenv = * From 35280e9a6507c90c224c7e67e10919fad396a7ca Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 1 Nov 2015 23:06:52 +0100 Subject: [PATCH 3/5] label platform code, exclude freebsd and unknown platform from coverage measurement this coverage configuration is mostly for travis and there we only can test linux and darwin. --- .coveragerc | 2 ++ borg/platform.py | 8 ++++---- borg/xattr.py | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.coveragerc b/.coveragerc index 0ae90754e..065ae4337 100644 --- a/.coveragerc +++ b/.coveragerc @@ -10,6 +10,8 @@ omit = [report] exclude_lines = pragma: no cover + pragma: freebsd only + pragma: unknown platform only def __repr__ raise AssertionError raise NotImplementedError diff --git a/borg/platform.py b/borg/platform.py index caa3b4edc..1bc8ee5e4 100644 --- a/borg/platform.py +++ b/borg/platform.py @@ -1,12 +1,12 @@ import sys -if sys.platform.startswith('linux'): +if sys.platform.startswith('linux'): # pragma: linux only from .platform_linux import acl_get, acl_set, API_VERSION -elif sys.platform.startswith('freebsd'): +elif sys.platform.startswith('freebsd'): # pragma: freebsd only from .platform_freebsd import acl_get, acl_set, API_VERSION -elif sys.platform == 'darwin': +elif sys.platform == 'darwin': # pragma: darwin only from .platform_darwin import acl_get, acl_set, API_VERSION -else: +else: # pragma: unknown platform only API_VERSION = 2 def acl_get(path, item, st, numeric_owner=False): diff --git a/borg/xattr.py b/borg/xattr.py index ded6d752d..9c80c3263 100644 --- a/borg/xattr.py +++ b/borg/xattr.py @@ -36,7 +36,7 @@ def _check(rv, path=None): raise OSError(get_errno(), path) return rv -if sys.platform.startswith('linux'): +if sys.platform.startswith('linux'): # pragma: linux only libc.llistxattr.argtypes = (c_char_p, c_char_p, c_size_t) libc.llistxattr.restype = c_ssize_t libc.flistxattr.argtypes = (c_int, c_char_p, c_size_t) @@ -100,7 +100,7 @@ if sys.platform.startswith('linux'): func = libc.lsetxattr _check(func(path, name, value, len(value) if value else 0, 0), path) -elif sys.platform == 'darwin': +elif sys.platform == 'darwin': # pragma: darwin only libc.listxattr.argtypes = (c_char_p, c_char_p, c_size_t, c_int) libc.listxattr.restype = c_ssize_t libc.flistxattr.argtypes = (c_int, c_char_p, c_size_t) @@ -166,7 +166,7 @@ elif sys.platform == 'darwin': flags = XATTR_NOFOLLOW _check(func(path, name, value, len(value) if value else 0, 0, flags), path) -elif sys.platform.startswith('freebsd'): +elif sys.platform.startswith('freebsd'): # pragma: freebsd only EXTATTR_NAMESPACE_USER = 0x0001 libc.extattr_list_fd.argtypes = (c_int, c_int, c_char_p, c_size_t) libc.extattr_list_fd.restype = c_ssize_t @@ -247,7 +247,7 @@ elif sys.platform.startswith('freebsd'): func = libc.extattr_set_link _check(func(path, EXTATTR_NAMESPACE_USER, name, value, len(value) if value else 0), path) -else: +else: # pragma: unknown platform only def listxattr(path, *, follow_symlinks=True): return [] From ff6627105721bb5946324bc94f1b5aa261012e9d Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 1 Nov 2015 23:20:32 +0100 Subject: [PATCH 4/5] only measure coverage for borgbackup code, not for tests --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index 065ae4337..815959684 100644 --- a/.coveragerc +++ b/.coveragerc @@ -6,6 +6,7 @@ omit = */borg/__main__.py */borg/_version.py */borg/support/* + */borg/testsuite/* [report] exclude_lines = From 23a3e3b0680e99bb690af07dc38c3800390f59da Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 1 Nov 2015 23:22:04 +0100 Subject: [PATCH 5/5] do not measure coverage for fuse.py it's always at 0% although we do have fuse tests. guess one can't measure such code with coverage.py. --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index 815959684..077e3e6f4 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,6 +5,7 @@ omit = */borg/__init__.py */borg/__main__.py */borg/_version.py + */borg/fuse.py */borg/support/* */borg/testsuite/*