[py-svn] r7157 - py/dist/py/test
hpk at codespeak.net
hpk at codespeak.net
Fri Oct 29 17:10:30 CEST 2004
Author: hpk
Date: Fri Oct 29 17:10:30 2004
New Revision: 7157
Modified:
py/dist/py/test/run.py
Log:
nicer output for "py.test --session" mode (which is really nice, btw!)
Modified: py/dist/py/test/run.py
==============================================================================
--- py/dist/py/test/run.py (original)
+++ py/dist/py/test/run.py Fri Oct 29 17:10:30 2004
@@ -4,28 +4,28 @@
from py.__impl__.test.config import configbasename
import sys
-def waitfilechange():
+def checkpyfilechange(rootdir, statcache):
""" wait until project files are changed. """
- rootdir = py.test.config.getfirst('rootdir')
- rootdir = py.path.local(rootdir)
fil = py.path.checker(fnmatch='*.py')
rec = py.path.checker(dotfile=0)
- statcache = {}
+ changed = False
for path in rootdir.visit(fil, rec):
- statcache[path] = path.stat()
-
- print "waiting for file change below", str(rootdir)
- while 1:
- py.std.time.sleep(0.4)
- for path, cst in statcache.items():
- try:
- st = path.stat()
- except path.NotFound:
- return
+ oldstat = statcache.get(path, None)
+ try:
+ statcache[path] = curstat = path.stat()
+ except path.NotFound:
+ if oldstat:
+ del statcache[path]
+ print "# WARN: race condition on", path
+ else:
+ if oldstat:
+ if oldstat.st_mtime != curstat.st_mtime or \
+ oldstat.st_size != curstat.st_size:
+ changed = True
+ print "# MODIFIED", path
else:
- if st.st_mtime != cst.st_mtime or \
- st.st_size != cst.st_size:
- return
+ changed = True
+ return changed
class FailingCollector(py.test.collect.Collector):
def __init__(self, faileditems):
@@ -169,11 +169,18 @@
driver.run(fncollectors)
def session(args, filenames):
+ statcache = {}
+ failures = []
+ rootdir = py.path.local(py.test.config.getfirst('rootdir'))
+ l = len(str(rootdir))
while 1:
- failures = master(args, filenames)
- if not failures or not py.test.config.option.session:
- break
- while failures:
- print "session mode: %d failures remaining" % len(failures)
- waitfilechange()
+ while not checkpyfilechange(rootdir, statcache):
+ py.std.time.sleep(0.4)
+ if failures:
failures = failure_master(args, filenames, failures)
+ else:
+ failures = master(args, filenames)
+ print "#" * 60
+ print "# session mode: %d failures remaining" % len(failures)
+ print "# checking py files below %s" % rootdir
+ print "# ", "^" * l
More information about the pytest-commit
mailing list