X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=wvtest.py;h=cc68601ccd6b5c95ab24546887ebf2f0f31f1258;hb=33d395fd4ab47aa3b4aa9094e5b220c519d6fc3f;hp=833cfc403c6fddef36a3ff8dca2f7a94f2f9551c;hpb=10e716e069f0fc9b461b6f9e6410c992f2a0c089;p=bup.git diff --git a/wvtest.py b/wvtest.py index 833cfc4..cc68601 100755 --- a/wvtest.py +++ b/wvtest.py @@ -73,6 +73,10 @@ if __name__ != '__main__': # we're imported as a module return text + def WVMSG(message): + ''' Issues a notification. ''' + return _result(message, traceback.extract_stack()[-3], 'ok') + def WVPASS(cond = True): ''' Counts a test failure unless cond is true. ''' return _check(cond, _code()) @@ -121,6 +125,8 @@ if __name__ != '__main__': # we're imported as a module else: return _check(False, 'EXCEPT(%s)' % _code()) + def wvfailure_count(): + return _fails def _check_unfinished(): if _registered: @@ -145,9 +151,31 @@ def _run_in_chdir(path, func, *args, **kwargs): sys.path = oldpath +if sys.version_info >= (2,6,0): + _relpath = os.path.relpath; +else: + # Implementation for Python 2.5, taken from CPython (tag v2.6, + # file Lib/posixpath.py, hg-commit 95fff5a6a276). Update + # ./LICENSE When this code is eventually removed. + def _relpath(path, start=os.path.curdir): + if not path: + raise ValueError("no path specified") + + start_list = os.path.abspath(start).split(os.path.sep) + path_list = os.path.abspath(path).split(os.path.sep) + + # Work out how much of the filepath is shared by start and path. + i = len(os.path.commonprefix([start_list, path_list])) + + rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:] + if not rel_list: + return curdir + return os.path.join(*rel_list) + + def _runtest(fname, f): mod = inspect.getmodule(f) - relpath = os.path.relpath(mod.__file__, os.getcwd()).replace('.pyc', '.py') + relpath = _relpath(mod.__file__, os.getcwd()).replace('.pyc', '.py') print print 'Testing "%s" in %s:' % (fname, relpath) sys.stdout.flush()