Commit c462756b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 89d48dfc
......@@ -100,14 +100,14 @@ def test_join():
wcfs.join(zurl, autostart=False)
wc = wcfs._start(zurl)
xdefer(wc.close)
defer(wc.close)
assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs/zurl") == zurl
assert os.path.isdir(wc.mountpoint + "/head")
assert os.path.isdir(wc.mountpoint + "/head/bigfile")
wc2 = wcfs.join(zurl, autostart=False)
xdefer(wc2.close)
defer(wc2.close)
assert wc2.mountpoint == wc.mountpoint
# test that join(autostart=y) works.
......@@ -118,7 +118,7 @@ def test_join_autostart():
wcfs.join(zurl, autostart=False)
wc = wcfs.join(zurl, autostart=True)
xdefer(wc.close)
defer(wc.close)
assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs/zurl") == zurl
assert os.path.isdir(wc.mountpoint + "/head")
......@@ -162,7 +162,7 @@ class DFile:
# tDB provides database/wcfs testing environment.
#
# Database root and wcfs connection are represented by .root and .wc correspondingly
# Database root and wcfs connection are represented by .root and .wc correspondingly.
#
# The primary way to access wcfs is by opening BigFiles and Watches.
# A BigFile opened under tDB is represented as tFile - see .open for details.
......@@ -175,7 +175,7 @@ class DFile:
#
# tDB must be explicitly closed once no longer used.
#
# Raw files on wcfs can be accessed with ._path/._read/._stat/._open
# Raw files on wcfs can be accessed with ._path/._read/._stat/._open .
#
# XXX print -> t.trace/debug() + t.verbose depending on py.test -v -v ?
class tDB:
......@@ -451,7 +451,7 @@ class tFile:
# - see "7.2) for all registered client@at watchers ..."
#
# pinokByWLink: {} tWatchLink -> {} blk -> at.
# pinokByWLink can be None - in that case it is computed automatically.
# pinokByWLink can be omitted - in that case it is computed only automatically.
@func
def assertBlk(t, blk, dataok, pinokByWLink=None):
#print('assertBlk #%d' % blk)
......@@ -1149,8 +1149,8 @@ def _expectPin(twlink, ctx, zf, expect): # -> []tSrvReq
@func
def test_wcfs():
t = tDB()
xdefer(t.close)
xdefer(t.dump_history)
defer(t.close)
defer(t.dump_history)
t.root['!file'] = nonfile = Persistent()
t.root['zfile'] = zf = ZBigFile(blksize)
......@@ -1473,7 +1473,7 @@ def tidtime(tid):
@func
def test_tidtime_notrough():
t = tDB()
xdefer(t.close)
defer(t.close)
atprev = t.commit()
for i in range(10):
......@@ -1540,6 +1540,7 @@ def dump_history(t):
# whether and which an assert in the test failed.
#
# XXX merge into defer?
_defer = defer # original golang.defer
def xdefer(f):
# hack - imitate as if defer called from under xdefer was called directly by caller func
fgo = inspect.currentframe().f_back.f_back
......@@ -1555,4 +1556,8 @@ def _xdefer(f):
except:
traceback.print_exception(exc_type, exc_value, exc_traceback)
raise
defer(_)
_defer(_)
# replace defer with xdefer
defer = xdefer
del xdefer
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment