Changeset: 868f8401b36a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/868f8401b36a
Modified Files:
testing/Mtest.py.in
testing/Mz.py.in
Branch: Jan2022
Log Message:
Make quiet output (-q option) look like Mz.py output.
diffs (265 lines):
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1116,7 +1116,7 @@ def SkipTest(env, TST, EXT, REASON, leng
TSTDIR = env['TSTDIR']
TEXT = "Skipping test %s%s %s" % (TST, EXT, REASON)
if quiet:
- print("-", end='')
+ pass
elif verbose:
Warn(TEXT)
else:
@@ -1163,21 +1163,39 @@ def SkipTest(env, TST, EXT, REASON, leng
return td
### SkipTest(env, TST, EXT, REASON) #
-def find_test_dirs(thisdir) :
- testdirs = []
+def find_test_dirs(thisdir, recursive=True) :
thisdir = os.path.realpath(thisdir)
dirnme = os.path.basename(thisdir)
+ if not recursive and dirnme != TSTSUFF and
os.path.isdir(os.path.join(thisdir, TSTSUFF)):
+ return find_test_dirs(os.path.join(thisdir, TSTSUFF), recursive)
+ testdirs = []
dirlst = listdir(thisdir)
+ tstcnt = 0
if dirnme == TSTSUFF and "All" in dirlst and
os.path.isfile(os.path.join(thisdir,"All")):
- testdirs.append(os.path.dirname(thisdir))
- for d in dirlst:
- d = os.path.join(thisdir,d)
- if os.path.isdir(d):
- testdirs = testdirs + find_test_dirs(d)
- return testdirs
+ try:
+ allf = openutf8(os.path.join(thisdir,"All"))
+ except IOError:
+ pass
+ else:
+ cnt = 0
+ for tc in allf:
+ tc = tc.strip()
+ if tc != '' and not tc.startswith('#'):
+ cnt += 1
+ if cnt > 0:
+ testdirs.append(os.path.dirname(thisdir))
+ tstcnt += cnt
+ if recursive:
+ for d in dirlst:
+ d = os.path.join(thisdir,d)
+ if os.path.isdir(d):
+ tst, cnt = find_test_dirs(d)
+ testdirs.extend(tst)
+ tstcnt += cnt
+ return testdirs, tstcnt
### find_test_dirs(thisdir) #
-def PerformDir(env, testdir, testlist, all_tests = False) :
+def PerformDir(env, testdir, testlist, all_tests, total_tests, test_progress) :
interrupted = False
td = 0
elem = None
@@ -1247,7 +1265,7 @@ def PerformDir(env, testdir, testlist, a
testlist = alltests
if not testlist:
Warn("No tests found in '%s`; skipping directory!" % TSTSRCDIR)
- return td, elem, max(FdOut, FdErr), interrupted
+ return td, elem, max(FdOut, FdErr), interrupted, test_progress
# find length of longest test name
length = 0
@@ -1287,7 +1305,7 @@ def PerformDir(env, testdir, testlist, a
Warn("database '%s` exists, but destroying it failed;
skipping tests in '%s`!" % (TSTDB, TSTSRCDIR))
#TODO:
# add "something" to HTML output
- return td, elem, max(FdOut, FdErr), interrupted
+ return td, elem, max(FdOut, FdErr), interrupted,
test_progress
if os.path.isabs(LogDBdir) and not os.path.exists(LogDBdir):
try:
os.makedirs(LogDBdir)
@@ -1295,7 +1313,7 @@ def PerformDir(env, testdir, testlist, a
Warn("creating database '%s` failed; skipping tests in
'%s`!" % (TSTDB, TSTSRCDIR))
#TODO:
# add "something" to HTML output
- return td, elem, max(FdOut, FdErr), interrupted
+ return td, elem, max(FdOut, FdErr), interrupted,
test_progress
if initdb:
import zipfile
try:
@@ -1304,7 +1322,7 @@ def PerformDir(env, testdir, testlist, a
Warn("initial database '%s` cannot be opened; skipping
tests in '%s`!" % (initdb, TSTSRCDIR))
#TODO:
# add "something" to HTML output
- return td, elem, max(FdOut, FdErr), interrupted
+ return td, elem, max(FdOut, FdErr), interrupted,
test_progress
try:
z.extractall(LogDBdir)
except KeyboardInterrupt:
@@ -1313,7 +1331,7 @@ def PerformDir(env, testdir, testlist, a
Warn("initial database '%s` cannot be extracted; skipping
tests in '%s`!" % (initdb, TSTSRCDIR))
#TODO:
# add "something" to HTML output
- return td, elem, max(FdOut, FdErr), interrupted
+ return td, elem, max(FdOut, FdErr), interrupted,
test_progress
z.close()
if not oneserver:
pSrvr =
ServerClass(splitcommand(env['exe']['mserver5'][1]) + ['--dbpath=%s' %
LogDBdir] + mserver5_opts, open(os.devnull, 'w'), open(os.devnull, 'w'),
par['TIMEOUT'], os.path.join(LogDBdir, '.started'))
@@ -1332,6 +1350,7 @@ def PerformDir(env, testdir, testlist, a
pSrvr = None
try:
for TST,COND in testlist:
+ test_progress += 1
if oneserver and (pSrvr is None or pSrvr.poll() is not None):
# restart server
inmem = single_in_memory
@@ -1374,7 +1393,7 @@ def PerformDir(env, testdir, testlist, a
tt, FtOut, FtErr, bodyline, reason =
0,F_SKIP,F_SKIP,None,"as the global timeout has been reached"
else:
os.environ['TST'] = TST
- tt, FtOut, FtErr, bodyline, reason, links = RunTest(env,
TST, COND, oktests, length, all_tests, pSrvr)
+ tt, FtOut, FtErr, bodyline, reason, links = RunTest(env,
TST, COND, oktests, length, all_tests, pSrvr, total_tests, test_progress)
alllinks.extend(links)
if tt:
t = "%7.3f" % tt
@@ -1464,10 +1483,10 @@ def PerformDir(env, testdir, testlist, a
except:
pass
- return td, elem, max(FdOut, FdErr, ssout, sserr), interrupted
+ return td, elem, max(FdOut, FdErr, ssout, sserr), interrupted,
test_progress
finally:
del sys.path[0]
-### PerformDir(env, testdir, testlist) #
+### PerformDir(env, testdir, testlist, all_tests, total_tests, test_progress) #
# this function is a slightly modified copy of the posixpath version
# the differences are the doubling of \'s in the replacement value
@@ -1853,7 +1872,7 @@ relcond = {
'last hugeint chained empty'),
}
-def RunTest(env, TST, COND, oktests, length, all_tests, pSrvr) :
+def RunTest(env, TST, COND, oktests, length, all_tests, pSrvr, total_tests,
test_progress) :
global setpgrp
Failed = F_SKIP
FailedOut = F_SKIP
@@ -2151,7 +2170,7 @@ def RunTest(env, TST, COND, oktests, len
TestErr.close()
t0 = time.time()
- tres = DoIt(env, SERVER, CALL, TST, EXT, TestOutFile, TestErrFile,
TIMEOUT, ME, length, nomito, threads, user, passwd, COND, all_tests, pSrvr)
+ tres = DoIt(env, SERVER, CALL, TST, EXT, TestOutFile, TestErrFile,
TIMEOUT, ME, length, nomito, threads, user, passwd, COND, all_tests, pSrvr,
total_tests, test_progress)
t1 = time.time()
TX = t1 - t0
if not quiet:
@@ -2670,11 +2689,20 @@ def mapi_ping(port) :
return False
### mapi_ping() #
-def DoIt(env, SERVER, CALL, TST, EXT, TestOutFile, TestErrFile, TIMEOUT, ME,
length, nomito, threads, user, passwd, COND, all_tests, PSRVR) :
+def progress(count, total, test):
+ perc = round((count/total) * 100) if total and count else 0
+ print('\r', ' '*(ttywidth or 100), end='', sep='')
+ s = '[{}/{}] ({}%) {}'.format(count, total, perc, test)
+ if len(s) > ttywidth:
+ test = test[len(s)-ttywidth:]
+ s = '[{}/{}] ({}%) {}'.format(count, total, perc, test)
+ print('\r', s, end='', sep='', flush=True)
+
+def DoIt(env, SERVER, CALL, TST, EXT, TestOutFile, TestErrFile, TIMEOUT, ME,
length, nomito, threads, user, passwd, COND, all_tests, PSRVR, total_tests,
test_progress) :
ATJOB2 = ""
print(file=sys.stderr, end='', flush=True)
if quiet:
- print(".", end='')
+ progress(test_progress, total_tests, os.path.join(env['TSTDIR'], TST +
EXT))
elif verbose:
print('%s%s (<=%d) ...' %
(prompt(), os.path.join(env['TSTDIR'], TST + EXT),
@@ -3841,19 +3869,18 @@ def main(argv) :
# WARNING
testlist = []
for d in dirlist:
- test_dirs = find_test_dirs(d)
+ test_dirs, test_count = find_test_dirs(d)
test_dirs.sort()
for t in test_dirs:
if t not in testdirs:
testdirs.append(t)
else:
for d in dirlist:
- if os.path.basename(d) == TSTSUFF and
os.path.isfile(os.path.join(d,"All")):
- testdirs.append(os.path.dirname(os.path.realpath(d)))
- elif os.path.isdir(os.path.join(d,TSTSUFF)) and
os.path.isfile(os.path.join(d,TSTSUFF,"All")):
- testdirs.append(os.path.realpath(d))
+ test_dirs, test_count = find_test_dirs(d, recursive=False)
+ if test_count == 0:
+ Warn("No tests found in '%s`; skipping directory!" % d)
else:
- Warn("No tests found in '%s`; skipping directory!" % d)
+ testdirs.extend(test_dirs)
if len(testdirs) > 1 and testlist:
testlist = []
@@ -3879,6 +3906,7 @@ def main(argv) :
#elif t in testlist:
# WARNING: tests in wrong order
i = i + 1
+ test_count = len(testlist)
if not env.get('NOCLEAN') and os.path.exists(os.path.join(TSTTRGBASE,
TSTPREF)):
try:
@@ -3950,6 +3978,7 @@ def main(argv) :
t_ = 0
body_good = []
body_bad = []
+ test_progress = 0
try:
if len(testdirs) == 1:
if testlist:
@@ -3959,7 +3988,7 @@ def main(argv) :
all_tests = True
if verbose:
print("\nRunning %s in directory %s.\n" % (tsts ,
testdirs[0]))
- t_, elem, diff, interrupted = PerformDir(env, testdirs[0],
testlist, all_tests)
+ t_, elem, diff, interrupted, test_progress = PerformDir(env,
testdirs[0], testlist, all_tests, test_count, test_progress)
if elem is not None:
if diff <= F_OK:
body_good.append(elem)
@@ -3969,7 +3998,7 @@ def main(argv) :
if verbose:
print("\nRunning all tests in directories %s.\n" %
str(testdirs))
for d in testdirs:
- t, elem, diff, interrupted = PerformDir(env, d, [], True)
+ t, elem, diff, interrupted, test_progress =
PerformDir(env, d, [], True, test_count, test_progress)
t_ = t_ + t
if elem is not None:
if diff <= F_OK:
@@ -4118,7 +4147,15 @@ VALUES (%s, '%s', '%s', '%s',
for f in Failure[x]:
what += " %s\n" % f
print(file=sys.stderr, end='', flush=True)
- if Failed:
+ if quiet:
+ if Failed:
+ prred('ERROR')
+ else:
+ prgreen('OK')
+ print()
+ print('failed={}, skipped={}'.format(Failed, len(Failure[F_SKIP])))
+ print('Ran {} tests in {:7.3f}s'.format(num_tests -
len(Failure[F_SKIP]), t_))
+ elif Failed:
print("""\
!ERROR: Testing FAILED %s (%d out of %d tests failed)
diff --git a/testing/Mz.py.in b/testing/Mz.py.in
--- a/testing/Mz.py.in
+++ b/testing/Mz.py.in
@@ -2672,7 +2672,7 @@ def main(argv) :
prgreen('OK')
print()
print('failed={}, skipped={}'.format(failed, skipped))
- print('Ran {} test in {:7.3f}s'.format(test_count - skipped, t_))
+ print('Ran {} tests in {:7.3f}s'.format(test_count - skipped, t_))
if verbose:
for TSTDIR, TST in FAILED_TESTS:
prred('ERROR\t')
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]