Remove spaces
This commit is contained in:
parent
8ef54855d7
commit
20c921218b
108
driver.py
108
driver.py
@ -55,7 +55,7 @@ def load_relations():
|
|||||||
# Naming the relation
|
# Naming the relation
|
||||||
relname = i[:-4]
|
relname = i[:-4]
|
||||||
|
|
||||||
print ("Loading relation %s with name %s..." % (i, relname))
|
print("Loading relation %s with name %s..." % (i, relname))
|
||||||
|
|
||||||
rels[relname] = relation.Relation.load_csv('%s%s' % (examples_path, i))
|
rels[relname] = relation.Relation.load_csv('%s%s' % (examples_path, i))
|
||||||
print('done')
|
print('done')
|
||||||
@ -102,45 +102,45 @@ def execute_tests():
|
|||||||
else:
|
else:
|
||||||
f_bad += 1
|
f_bad += 1
|
||||||
|
|
||||||
print (colorize("Resume of the results", COLOR_CYAN))
|
print(colorize("Resume of the results", COLOR_CYAN))
|
||||||
|
|
||||||
print (colorize("Query tests", COLOR_MAGENTA))
|
print(colorize("Query tests", COLOR_MAGENTA))
|
||||||
print ("Total test count: %d" % q_tot)
|
print("Total test count: %d" % q_tot)
|
||||||
print ("Passed tests: %d" % q_good)
|
print("Passed tests: %d" % q_good)
|
||||||
if q_bad > 0:
|
if q_bad > 0:
|
||||||
print (colorize("Failed tests count: %d" % q_bad, COLOR_RED))
|
print(colorize("Failed tests count: %d" % q_bad, COLOR_RED))
|
||||||
|
|
||||||
print (colorize("Python tests", COLOR_MAGENTA))
|
print(colorize("Python tests", COLOR_MAGENTA))
|
||||||
print ("Total test count: %d" % py_tot)
|
print("Total test count: %d" % py_tot)
|
||||||
print ("Passed tests: %d" % py_good)
|
print("Passed tests: %d" % py_good)
|
||||||
if py_bad > 0:
|
if py_bad > 0:
|
||||||
print (colorize("Failed tests count: %d" % py_bad, COLOR_RED))
|
print(colorize("Failed tests count: %d" % py_bad, COLOR_RED))
|
||||||
|
|
||||||
print (colorize("Execute Python tests", COLOR_MAGENTA))
|
print(colorize("Execute Python tests", COLOR_MAGENTA))
|
||||||
print ("Total test count: %d" % ex_tot)
|
print("Total test count: %d" % ex_tot)
|
||||||
print ("Passed tests: %d" % ex_good)
|
print("Passed tests: %d" % ex_good)
|
||||||
if ex_bad > 0:
|
if ex_bad > 0:
|
||||||
print (colorize("Failed tests count: %d" % ex_bad, COLOR_RED))
|
print(colorize("Failed tests count: %d" % ex_bad, COLOR_RED))
|
||||||
|
|
||||||
print (colorize("Execute fail tests", COLOR_MAGENTA))
|
print(colorize("Execute fail tests", COLOR_MAGENTA))
|
||||||
print ("Total test count: %d" % f_tot)
|
print("Total test count: %d" % f_tot)
|
||||||
print ("Passed tests: %d" % f_good)
|
print("Passed tests: %d" % f_good)
|
||||||
if f_bad > 0:
|
if f_bad > 0:
|
||||||
print (colorize("Failed tests count: %d" % f_bad, COLOR_RED))
|
print(colorize("Failed tests count: %d" % f_bad, COLOR_RED))
|
||||||
|
|
||||||
print (colorize("Total results", COLOR_CYAN))
|
print(colorize("Total results", COLOR_CYAN))
|
||||||
if f_bad + q_bad + py_bad + ex_bad == 0:
|
if f_bad + q_bad + py_bad + ex_bad == 0:
|
||||||
print (colorize("No failed tests", COLOR_GREEN))
|
print(colorize("No failed tests", COLOR_GREEN))
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
print (colorize("There are %d failed tests" %
|
print(colorize("There are %d failed tests" %
|
||||||
(f_bad + py_bad + q_bad + ex_bad), COLOR_RED))
|
(f_bad + py_bad + q_bad + ex_bad), COLOR_RED))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
def run_exec_test(testname):
|
def run_exec_test(testname):
|
||||||
'''Runs a python test, which executes code directly rather than queries'''
|
'''Runs a python test, which executes code directly rather than queries'''
|
||||||
print ("Running python test: " + colorize(testname, COLOR_MAGENTA))
|
print("Running python test: " + colorize(testname, COLOR_MAGENTA))
|
||||||
|
|
||||||
glob = rels.copy()
|
glob = rels.copy()
|
||||||
exp_result = {}
|
exp_result = {}
|
||||||
@ -149,19 +149,19 @@ def run_exec_test(testname):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
exec(expr, glob) # Evaluating the expression
|
exec(expr, glob) # Evaluating the expression
|
||||||
print (colorize('Test passed', COLOR_GREEN))
|
print(colorize('Test passed', COLOR_GREEN))
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print (colorize('ERROR', COLOR_RED))
|
print(colorize('ERROR', COLOR_RED))
|
||||||
print (colorize('=====================================', COLOR_RED))
|
print(colorize('=====================================', COLOR_RED))
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
print (colorize('=====================================', COLOR_RED))
|
print(colorize('=====================================', COLOR_RED))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def run_py_test(testname):
|
def run_py_test(testname):
|
||||||
'''Runs a python test, which evaluates expressions directly rather than queries'''
|
'''Runs a python test, which evaluates expressions directly rather than queries'''
|
||||||
print ("Running expression python test: " +
|
print("Running expression python test: " +
|
||||||
colorize(testname, COLOR_MAGENTA))
|
colorize(testname, COLOR_MAGENTA))
|
||||||
exp_result = None
|
exp_result = None
|
||||||
result = None
|
result = None
|
||||||
@ -174,21 +174,21 @@ def run_py_test(testname):
|
|||||||
exp_result = eval(expr, rels)
|
exp_result = eval(expr, rels)
|
||||||
|
|
||||||
if result == exp_result:
|
if result == exp_result:
|
||||||
print (colorize('Test passed', COLOR_GREEN))
|
print(colorize('Test passed', COLOR_GREEN))
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
print (colorize('ERROR', COLOR_RED))
|
print(colorize('ERROR', COLOR_RED))
|
||||||
print (colorize('=====================================', COLOR_RED))
|
print(colorize('=====================================', COLOR_RED))
|
||||||
print ("Expected %s" % exp_result)
|
print("Expected %s" % exp_result)
|
||||||
print ("Got %s" % result)
|
print("Got %s" % result)
|
||||||
print (colorize('=====================================', COLOR_RED))
|
print(colorize('=====================================', COLOR_RED))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def run_fail_test(testname):
|
def run_fail_test(testname):
|
||||||
'''Runs a test, which executes a query that is supposed to fail'''
|
'''Runs a test, which executes a query that is supposed to fail'''
|
||||||
print ("Running fail test: " + colorize(testname, COLOR_MAGENTA))
|
print("Running fail test: " + colorize(testname, COLOR_MAGENTA))
|
||||||
|
|
||||||
query = readfile('%s%s.fail' % (tests_path, testname)).strip()
|
query = readfile('%s%s.fail' % (tests_path, testname)).strip()
|
||||||
test_succeed = True
|
test_succeed = True
|
||||||
@ -216,9 +216,9 @@ def run_fail_test(testname):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if test_succeed:
|
if test_succeed:
|
||||||
print (colorize('Test passed', COLOR_GREEN))
|
print(colorize('Test passed', COLOR_GREEN))
|
||||||
else:
|
else:
|
||||||
print (colorize('Test failed (by not raising any exception)', COLOR_RED))
|
print(colorize('Test failed (by not raising any exception)', COLOR_RED))
|
||||||
return test_succeed
|
return test_succeed
|
||||||
|
|
||||||
def run_test(testname):
|
def run_test(testname):
|
||||||
@ -228,7 +228,7 @@ def run_test(testname):
|
|||||||
testname.result
|
testname.result
|
||||||
The query will be executed both unoptimized and
|
The query will be executed both unoptimized and
|
||||||
optimized'''
|
optimized'''
|
||||||
print ("Running test: " + colorize(testname, COLOR_MAGENTA))
|
print("Running test: " + colorize(testname, COLOR_MAGENTA))
|
||||||
|
|
||||||
query = None
|
query = None
|
||||||
expr = None
|
expr = None
|
||||||
@ -254,32 +254,32 @@ def run_test(testname):
|
|||||||
c_result = eval(c_expr, rels)
|
c_result = eval(c_expr, rels)
|
||||||
|
|
||||||
if (o_result == result_rel) and (result == result_rel) and (c_result == result_rel):
|
if (o_result == result_rel) and (result == result_rel) and (c_result == result_rel):
|
||||||
print (colorize('Test passed', COLOR_GREEN))
|
print(colorize('Test passed', COLOR_GREEN))
|
||||||
return True
|
return True
|
||||||
except Exception as inst:
|
except Exception as inst:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
print (inst)
|
print(inst)
|
||||||
pass
|
pass
|
||||||
print (colorize('ERROR', COLOR_RED))
|
print(colorize('ERROR', COLOR_RED))
|
||||||
print ("Query: %s -> %s" % (query, expr))
|
print("Query: %s -> %s" % (query, expr))
|
||||||
print ("Optimized query: %s -> %s" % (o_query, o_expr))
|
print("Optimized query: %s -> %s" % (o_query, o_expr))
|
||||||
print (colorize('=====================================', COLOR_RED))
|
print(colorize('=====================================', COLOR_RED))
|
||||||
print (colorize("Expected result", COLOR_GREEN))
|
print(colorize("Expected result", COLOR_GREEN))
|
||||||
print (result_rel)
|
print(result_rel)
|
||||||
print (colorize("Result", COLOR_RED))
|
print(colorize("Result", COLOR_RED))
|
||||||
print (result)
|
print(result)
|
||||||
print (colorize("Optimized result", COLOR_RED))
|
print(colorize("Optimized result", COLOR_RED))
|
||||||
print (o_result)
|
print(o_result)
|
||||||
print (colorize("optimized result match %s" %
|
print(colorize("optimized result match %s" %
|
||||||
str(result_rel == o_result), COLOR_MAGENTA))
|
str(result_rel == o_result), COLOR_MAGENTA))
|
||||||
print (colorize("result match %s" %
|
print(colorize("result match %s" %
|
||||||
str(result == result_rel), COLOR_MAGENTA))
|
str(result == result_rel), COLOR_MAGENTA))
|
||||||
print (colorize('=====================================', COLOR_RED))
|
print(colorize('=====================================', COLOR_RED))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print ("-> Starting testsuite for relational")
|
print("-> Starting testsuite for relational")
|
||||||
load_relations()
|
load_relations()
|
||||||
print ("-> Starting tests")
|
print("-> Starting tests")
|
||||||
exit(execute_tests())
|
exit(execute_tests())
|
||||||
|
Loading…
Reference in New Issue
Block a user