Changeset: 191ccb6d8840 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=191ccb6d8840 Modified Files: sql/odbc/samples/Tests/odbcsample1.SQL.sh sql/odbc/samples/Tests/testgetinfo.SQL.sh testing/Mz.py.in testing/sqltest.py Branch: default Log Message:
handle diff stable out on executable tests diffs (98 lines): diff --git a/sql/odbc/samples/Tests/odbcsample1.SQL.sh b/sql/odbc/samples/Tests/odbcsample1.SQL.sh --- a/sql/odbc/samples/Tests/odbcsample1.SQL.sh +++ b/sql/odbc/samples/Tests/odbcsample1.SQL.sh @@ -16,4 +16,4 @@ Debug = EOF export ODBCINI -Mlog -x "odbcsample1 MonetDB-Test" +eval odbcsample1 MonetDB-Test diff --git a/sql/odbc/samples/Tests/testgetinfo.SQL.sh b/sql/odbc/samples/Tests/testgetinfo.SQL.sh --- a/sql/odbc/samples/Tests/testgetinfo.SQL.sh +++ b/sql/odbc/samples/Tests/testgetinfo.SQL.sh @@ -16,4 +16,4 @@ Debug = EOF export ODBCINI -Mlog -x "testgetinfo MonetDB-Test" +eval testgetinfo MonetDB-Test diff --git a/testing/Mz.py.in b/testing/Mz.py.in --- a/testing/Mz.py.in +++ b/testing/Mz.py.in @@ -1195,13 +1195,27 @@ def RunTest(env, test, oktests, pSrvr): TestErrFile = TST+".test.err" t0 = time.time() - #if CALL == 'sqltest' or CALL == 'maltest': - # # TODO make TestOutFile optional - # exit_code, reason = RunSQLLogicTest(env, (TST + EXT), TestOutFile, TestErrFile, is_reqtest=is_reqtest, has_reqtests=has_reqtests, lsql= CALL == 'sqltest', username=user, password=passwd) - #else: tres = DoIt(env, SERVER, CALL, TST, EXT, TestOutFile, TestErrFile, STIMEOUT, CTIMEOUT, TIMEOUT, MAPIsockets, nomito, threads, user, passwd, COND, pSrvr) exit_code = transform_str_return_code(tres) + if CALL == 'other': + # check if executable type test produced output, if so match against .stable.out + if exit_code == F_OK and os.path.getsize(TestOutFile) > 0: + stable_file = TST + '.stable.out' + if os.path.exists(stable_file): + from MonetDBtesting.sqltest import diff + try: + res = diff(stable_file, TestOutFile) + except Exception as e: + exit_code = F_ERROR + with open(TestErrFile, 'a') as f: + f.write(repr(e)) + else: + if res: + exit_code = F_ERROR + with open(TestErrFile, 'a') as f: + f.write(res) + t1 = time.time() TX = t1 - t0 @@ -1615,10 +1629,6 @@ def RunIt(cmd, onechild, TestIn, TestOut TestIn = process.PIPE else: TestInput = None - #TestOut.write(Prompt(cmd)) - #TestOut.flush() - #TestErr.write(Prompt(cmd)) - #TestErr.flush() if procdebug: print('RunIt: starting process "%s"\n' % '" "'.join(cmd)) setpgrp = True @@ -1837,7 +1847,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te ClntErr = openutf8(TestErrFile, 'a') if SERVER not in ["MAL", "SQL"] or pSrvr.started: - if CALL == "other": + if CALL == "other": cmd = [os.path.join(".", TST + EXT), TST] returncode = RunIt(cmd, False, "", ClntOut, ClntErr, CTIMEOUT) elif CALL == "python": diff --git a/testing/sqltest.py b/testing/sqltest.py --- a/testing/sqltest.py +++ b/testing/sqltest.py @@ -97,6 +97,21 @@ def filter_matching_blocks(a: [str] = [] red_b+=b[min_size:] return red_a, red_b +def diff(stable_file, test_file): + diff = None + filter_fn = filter_lines_starting_with(['--', '#', 'stdout of test', 'stderr of test', 'MAPI']) + with open(stable_file) as fstable: + stable = list(filter(filter_fn, fstable.read().split('\n'))) + with open(test_file) as ftest: + test = list(filter(filter_fn, ftest.read().split('\n'))) + a, b = filter_matching_blocks(stable, test) + diff = list(difflib.unified_diff(a, b, fromfile='stable', tofile='test')) + if len(diff) > 0: + diff = '\n'.join(diff) + else: + diff = None + return diff + class PyMonetDBConnectionContext(object): def __init__(self, username='monetdb', password='monetdb', _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list