- Added other tests

- Driver can handle exceptions



git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@255 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2010-10-04 12:46:18 +07:00
parent 48e6ecb7ba
commit 54d1301a96
7 changed files with 71 additions and 40 deletions

@ -96,6 +96,8 @@ def run_py_test(testname):
'''Runs a python test, which executes code directly rather than queries'''
print "Running python test: \033[35;1m%s\033[0m" % testname
try:
expr=readfile('%s%s.python' % (tests_path,testname))
result=eval(expr,rels) #Evaluating the expression
@ -105,7 +107,8 @@ def run_py_test(testname):
if result==exp_result:
print "\033[32;1mTest passed\033[0m"
return True
else:
except:
pass
print "\033[31;1mERROR\033[0m"
print "\033[31;1m=====================================\033[0m"
print "Expected %s" % exp_result
@ -121,6 +124,14 @@ def run_test(testname):
The query will be executed both unoptimized and
optimized'''
print "Running test: \033[35;1m%s\033[0m" % testname
query=None;expr=None;o_query=None;o_expr=None
result_rel=None
result=None
o_result=None
try:
result_rel=relation.relation('%s%s.result' % (tests_path,testname))
query=readfile('%s%s.query' % (tests_path,testname)).strip()
@ -136,7 +147,8 @@ def run_test(testname):
if (o_result==result_rel) and (result==result_rel):
print "\033[32;1mTest passed\033[0m"
return True
else:
except:
pass
print "\033[31;1mERROR\033[0m"
print "Query: %s -> %s" % (query,expr)
print "Optimized query: %s -> %s" % (o_query,o_expr)
@ -147,12 +159,12 @@ def run_test(testname):
print result
print "\033[33;1mOptimized result\033[0m"
print o_result
print "\033[33;1mResult and optimized result match\033[0m", result==o_result
print "\033[33;1moptimized result match\033[0m", result_rel==o_result
print "\033[33;1mresult match \033[0m", result==result_rel
print "\033[31;1m=====================================\033[0m"
return False
if __name__ == '__main__':
print "-> Starting testsuite for relational"
load_relations()

@ -0,0 +1 @@
σ (len(name)==4)(peopleᐅᐊ skills)

@ -0,0 +1,12 @@
id,name,chief,age,skill
2,john,1,30,C
7,alia,1,28,C
1,carl,0,20,C++
2,john,1,30,PHP
7,alia,1,28,Python
3,dean,1,33,C++
7,alia,1,28,PHP
0,jack,0,22,Python
1,carl,0,20,Python
0,jack,0,22,C
1,carl,0,20,System Admin

@ -0,0 +1 @@
πname,phone(((πname,id(people)- π name,id(πid(σ i!=id and room==r(ρ id➡i,room➡r(person_room)*person_room)) ᐅᐊ people)) ᐅᐊ person_room) ᐅᐊ rooms)

@ -0,0 +1 @@
σ age<30and skill=='PHP' (people ᐅᐊ skills)

@ -0,0 +1,2 @@
id,name,chief,age,skill
7,alia,1,28,PHP