Commit c462756b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 89d48dfc
...@@ -100,14 +100,14 @@ def test_join(): ...@@ -100,14 +100,14 @@ def test_join():
wcfs.join(zurl, autostart=False) wcfs.join(zurl, autostart=False)
wc = wcfs._start(zurl) wc = wcfs._start(zurl)
xdefer(wc.close) defer(wc.close)
assert wc.mountpoint == testmntpt assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs/zurl") == zurl assert readfile(wc.mountpoint + "/.wcfs/zurl") == zurl
assert os.path.isdir(wc.mountpoint + "/head") assert os.path.isdir(wc.mountpoint + "/head")
assert os.path.isdir(wc.mountpoint + "/head/bigfile") assert os.path.isdir(wc.mountpoint + "/head/bigfile")
wc2 = wcfs.join(zurl, autostart=False) wc2 = wcfs.join(zurl, autostart=False)
xdefer(wc2.close) defer(wc2.close)
assert wc2.mountpoint == wc.mountpoint assert wc2.mountpoint == wc.mountpoint
# test that join(autostart=y) works. # test that join(autostart=y) works.
...@@ -118,7 +118,7 @@ def test_join_autostart(): ...@@ -118,7 +118,7 @@ def test_join_autostart():
wcfs.join(zurl, autostart=False) wcfs.join(zurl, autostart=False)
wc = wcfs.join(zurl, autostart=True) wc = wcfs.join(zurl, autostart=True)
xdefer(wc.close) defer(wc.close)
assert wc.mountpoint == testmntpt assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs/zurl") == zurl assert readfile(wc.mountpoint + "/.wcfs/zurl") == zurl
assert os.path.isdir(wc.mountpoint + "/head") assert os.path.isdir(wc.mountpoint + "/head")
...@@ -162,7 +162,7 @@ class DFile: ...@@ -162,7 +162,7 @@ class DFile:
# tDB provides database/wcfs testing environment. # 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. # 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. # A BigFile opened under tDB is represented as tFile - see .open for details.
...@@ -175,7 +175,7 @@ class DFile: ...@@ -175,7 +175,7 @@ class DFile:
# #
# tDB must be explicitly closed once no longer used. # 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 ? # XXX print -> t.trace/debug() + t.verbose depending on py.test -v -v ?
class tDB: class tDB:
...@@ -451,7 +451,7 @@ class tFile: ...@@ -451,7 +451,7 @@ class tFile:
# - see "7.2) for all registered client@at watchers ..." # - see "7.2) for all registered client@at watchers ..."
# #
# pinokByWLink: {} tWatchLink -> {} blk -> at. # 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 @func
def assertBlk(t, blk, dataok, pinokByWLink=None): def assertBlk(t, blk, dataok, pinokByWLink=None):
#print('assertBlk #%d' % blk) #print('assertBlk #%d' % blk)
...@@ -1149,8 +1149,8 @@ def _expectPin(twlink, ctx, zf, expect): # -> []tSrvReq ...@@ -1149,8 +1149,8 @@ def _expectPin(twlink, ctx, zf, expect): # -> []tSrvReq
@func @func
def test_wcfs(): def test_wcfs():
t = tDB() t = tDB()
xdefer(t.close) defer(t.close)
xdefer(t.dump_history) defer(t.dump_history)
t.root['!file'] = nonfile = Persistent() t.root['!file'] = nonfile = Persistent()
t.root['zfile'] = zf = ZBigFile(blksize) t.root['zfile'] = zf = ZBigFile(blksize)
...@@ -1473,7 +1473,7 @@ def tidtime(tid): ...@@ -1473,7 +1473,7 @@ def tidtime(tid):
@func @func
def test_tidtime_notrough(): def test_tidtime_notrough():
t = tDB() t = tDB()
xdefer(t.close) defer(t.close)
atprev = t.commit() atprev = t.commit()
for i in range(10): for i in range(10):
...@@ -1540,6 +1540,7 @@ def dump_history(t): ...@@ -1540,6 +1540,7 @@ def dump_history(t):
# whether and which an assert in the test failed. # whether and which an assert in the test failed.
# #
# XXX merge into defer? # XXX merge into defer?
_defer = defer # original golang.defer
def xdefer(f): def xdefer(f):
# hack - imitate as if defer called from under xdefer was called directly by caller func # hack - imitate as if defer called from under xdefer was called directly by caller func
fgo = inspect.currentframe().f_back.f_back fgo = inspect.currentframe().f_back.f_back
...@@ -1555,4 +1556,8 @@ def _xdefer(f): ...@@ -1555,4 +1556,8 @@ def _xdefer(f):
except: except:
traceback.print_exception(exc_type, exc_value, exc_traceback) traceback.print_exception(exc_type, exc_value, exc_traceback)
raise 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