- Added tests
- Driver can test on pure python code git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@266 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
19ac2aaacd
commit
3e2d33f1d5
@ -59,6 +59,9 @@ def execute_tests():
|
|||||||
q_bad=0
|
q_bad=0
|
||||||
q_good=0
|
q_good=0
|
||||||
q_tot=0
|
q_tot=0
|
||||||
|
ex_bad=0
|
||||||
|
ex_good=0
|
||||||
|
ex_tot=0
|
||||||
|
|
||||||
|
|
||||||
for i in os.listdir(tests_path):
|
for i in os.listdir(tests_path):
|
||||||
@ -74,6 +77,12 @@ def execute_tests():
|
|||||||
py_good+=1
|
py_good+=1
|
||||||
else:
|
else:
|
||||||
py_bad+=1
|
py_bad+=1
|
||||||
|
elif i.endswith('.exec'):
|
||||||
|
ex_tot+=1
|
||||||
|
if run_exec_test(i[:-5]):
|
||||||
|
ex_good+=1
|
||||||
|
else:
|
||||||
|
ex_bad+=1
|
||||||
print "\n\033[36;1mResume of the results\033[0m"
|
print "\n\033[36;1mResume of the results\033[0m"
|
||||||
|
|
||||||
print "\n\033[35;1mQuery tests\033[0m"
|
print "\n\033[35;1mQuery tests\033[0m"
|
||||||
@ -88,17 +97,62 @@ def execute_tests():
|
|||||||
if py_bad>0:
|
if py_bad>0:
|
||||||
print "\033[31;1mFailed tests count: %d\033[0m" % py_bad
|
print "\033[31;1mFailed tests count: %d\033[0m" % py_bad
|
||||||
|
|
||||||
print "\n\033[36;1mTotal results\033[0m"
|
print "\n\033[35;1mExecute Python tests\033[0m"
|
||||||
if q_bad+py_bad==0:
|
print "Total test count: %d" % ex_tot
|
||||||
print "\033[32;1mNo failed tests\033[0m"
|
print "Passed tests: %d" % ex_good
|
||||||
else:
|
if ex_bad>0:
|
||||||
print "\033[31;1mThere are %d failed tests\033[0m" % (py_bad+q_bad)
|
print "\033[31;1mFailed tests count: %d\033[0m" % ex_bad
|
||||||
|
|
||||||
|
|
||||||
def run_py_test(testname):
|
print "\n\033[36;1mTotal results\033[0m"
|
||||||
|
if q_bad+py_bad+ex_bad==0:
|
||||||
|
print "\033[32;1mNo failed tests\033[0m"
|
||||||
|
else:
|
||||||
|
print "\033[31;1mThere are %d failed tests\033[0m" % (py_bad+q_bad+ex_bad)
|
||||||
|
|
||||||
|
|
||||||
|
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: \033[35;1m%s\033[0m" % testname
|
print "Running python test: \033[35;1m%s\033[0m" % testname
|
||||||
|
|
||||||
|
glob=rels.copy()
|
||||||
|
exp_result={}
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
expr=readfile('%s%s.exec' % (tests_path,testname))
|
||||||
|
exec(expr,glob) #Evaluating the expression
|
||||||
|
|
||||||
|
expr=readfile('%s%s.exec' % (tests_path,testname))
|
||||||
|
exec(expr,glob) #Evaluating the expression
|
||||||
|
|
||||||
|
|
||||||
|
expr=readfile('%s%s.result' % (tests_path,testname))
|
||||||
|
exp_result=eval(expr,rels) #Evaluating the expression
|
||||||
|
|
||||||
|
|
||||||
|
if isinstance(exp_result,dict):
|
||||||
|
fields_ok=True
|
||||||
|
|
||||||
|
for i in exp_result:
|
||||||
|
fields_ok = fields_ok and glob[i]==exp_result[i]
|
||||||
|
|
||||||
|
if fields_ok:
|
||||||
|
print "\033[32;1mTest passed\033[0m"
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
print "\033[31;1mERROR\033[0m"
|
||||||
|
print "\033[31;1m=====================================\033[0m"
|
||||||
|
print "Expected %s" % exp_result
|
||||||
|
#print "Got %s" % result
|
||||||
|
print "\033[31;1m=====================================\033[0m"
|
||||||
|
return False
|
||||||
|
|
||||||
|
def run_py_test(testname):
|
||||||
|
'''Runs a python test, which evaluates expressions directly rather than queries'''
|
||||||
|
print "Running expression python test: \033[35;1m%s\033[0m" % testname
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
expr=readfile('%s%s.python' % (tests_path,testname))
|
expr=readfile('%s%s.python' % (tests_path,testname))
|
||||||
|
1
test/maxdate.query
Normal file
1
test/maxdate.query
Normal file
@ -0,0 +1 @@
|
|||||||
|
dates-πdate(σ d>date (ρdate➡d(dates)*dates))
|
2
test/maxdate.result
Normal file
2
test/maxdate.result
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
date
|
||||||
|
2008-12-12
|
7
test/rename_insert1.exec
Normal file
7
test/rename_insert1.exec
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
p1=people.rename({"id":"ido"})
|
||||||
|
people.insert((123,"lala",0,31))
|
||||||
|
|
||||||
|
print p1
|
||||||
|
print people
|
||||||
|
retval=people==p1
|
||||||
|
people.delete("id==123")
|
1
test/rename_insert1.result
Normal file
1
test/rename_insert1.result
Normal file
@ -0,0 +1 @@
|
|||||||
|
{'retval':False}
|
7
test/rename_insert2.exec
Normal file
7
test/rename_insert2.exec
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
p1=people.rename({"id":"ido"})
|
||||||
|
p1.insert((123,"lala",0,31))
|
||||||
|
|
||||||
|
print p1
|
||||||
|
print people
|
||||||
|
retval=people==p1
|
||||||
|
people.delete("id==123")
|
1
test/rename_insert2.result
Normal file
1
test/rename_insert2.result
Normal file
@ -0,0 +1 @@
|
|||||||
|
{'retval':False}
|
1
test/union4.query
Normal file
1
test/union4.query
Normal file
@ -0,0 +1 @@
|
|||||||
|
people ᑌ people ᑎ people
|
9
test/union4.result
Normal file
9
test/union4.result
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
id,name,chief,age
|
||||||
|
0,jack,0,22
|
||||||
|
1,carl,0,20
|
||||||
|
2,john,1,30
|
||||||
|
3,dean,1,33
|
||||||
|
4,eve,0,25
|
||||||
|
5,duncan,4,30
|
||||||
|
6,paul,4,30
|
||||||
|
7,alia,1,28
|
Loading…
x
Reference in New Issue
Block a user