Commit b065169e authored by Pietro Abate's avatar Pietro Abate
Browse files

Fix unit tests

Check all unit tests results against the version of cduce in master.
Many signature are syntactically different because of more liberal
use of parenthesis.
parent 032c4286
val book : Book
val count : [ Any* ] -> Int
val doc : Bib
val distinct_values : X1 -> X1 where X1 = [ Any* ]
val distinct_values : [ Any* ] -> [ Any* ]
val member : Pair -> Bool
val q4x : <results>[ <result>[ Any ]* ]
val q4p : <results>[ <result>[ Any ]* ]
......@@ -11,11 +11,10 @@ val amazon : <reviews>[ <entry>[ <title>[ 'Data on the Web' ]
val q5x : <books-with-prices>[ ]
val q5p : <books-with-prices>[ (<book-with-price>[ <title>[ 'Data on the Web' ]
<price-amazon>[ '34.95' ]
X1 ] |
<price-bn>String ] |
<book-with-price>[ <title>[ 'Advanced Programming in the Unix environment' ]
<price-amazon>[ '65.95' ]
X1 ] |
<price-bn>String ] |
<book-with-price>[ <title>[ 'TCP/IP Illustrated' ]
<price-amazon>[ '65.95' ]
X1 ])* ] where
X1 = <price-bn>String
<price-bn>String ])* ]
val doc : Bib
val order : X1 -> X1 where X1 = [ Any* ]
val passe : X1 -> X1 where X1 = [ Any* ]
val order : [ Any* ] -> [ Any* ]
val passe : [ Any* ] -> [ Any* ]
val q7p : <bib>[ Any* ]
val q7x : <bib>[ Any* ]
val f : 102--* -> 92--* & 111 -> 101 & 110 -> 100 & 109 -> 99 & 108 -> 98 &
107 -> 97 & 106 -> 96 & 105 -> 95 & 104 -> 94 & 103 -> 93 &
102 -> 92 & *--101 -> 91
val f : (102--* -> 92--*) & (111 -> 101) & (110 -> 100) & (109 -> 99) &
(108 -> 98) & (107 -> 97) & (106 -> 96) & (105 -> 95) & (104 -> 94) &
(103 -> 93) & (102 -> 92) & (*--101 -> 91)
val summary : Content -> [ Block* ]
val format : Text -> [ Flow* ] &
([ (Section | Box)* ] | Section | Box) -> [ Block* ]
val format : (Text -> [ Flow* ]) &
(Section | Box | [ (Section | Box)* ] -> [ Block* ])
val box : [ Flow* ] -> [ Block* ]
val content : Content
val fname : Latin1
......
val sort2 : FPerson -> Woman & MPerson -> Man
val sort : FPerson -> Woman & MPerson -> Man
val sort2 : (FPerson -> Woman) & (MPerson -> Man)
val sort : (FPerson -> Woman) & (MPerson -> Man)
val base : Person
val split : MCitizen -> CMan & FCitizen -> CWoman & FPerson -> Woman &
MPerson -> Man
val split : (MCitizen -> CMan) & (FCitizen -> CWoman) & (FPerson -> Woman) &
(MPerson -> Man)
val bib1 : Bib
val authors2 : (Book | { year=Int title=String authors=X1 }) -> X1 where
X1 = [ String+ ]
val extract : [ ([ Char* ] | Author)+ ] -> [ String+ ]
val authors : Book -> [ Author+ ] & Intern -> [ String+ ]
val authors2 : { year=Int title=String authors=[ String+ ] } |
Book -> [ String+ ]
val extract : [ (Author | [ Char* ])+ ] -> [ String+ ]
val authors : (Book -> [ Author+ ]) & (Intern -> [ String+ ])
val intern : Bib -> [ Intern* ]
val flatten_bib : [ Book* ] -> Flat
val chair_books : Bib -> [ <book>[ Title Year Author* Chair_auth Author* ]* ]
......@@ -3,16 +3,24 @@
#Expected: file containing the expected result
#Input: input files. always appended at the end of the $Cmd string
#Cmd: command to be run
#Type: tpye of the input/output format. Available text
#Printer: printer to display differences. Available text
Name: misc
Group: misc
Input: misc/*.cd
Exclude: misc/bugs_prod.cd misc/html2latex.cd misc/eval_concat.cd misc/list.cd misc/xhtml-categ.cd
Cmd: cduce -c --verbose -I misc
Cmd: ../cduce -c --verbose -I misc
Name: stdlib
Group: stdlib
Input: stdlib/list/*.cd
Cmd: ../cduce -c --verbose -I stdlib/list
Name: xsltmark
Group: xsltmark
Input: xsltmark/identity.cd
Cmd: ../cduce -c --verbose -I xsltmark
Name: cql
Group: cql
Input: cql/TREE/*.cd cql/XMP/*.cd
Cmd: ../cduce -c --verbose -I cql/TREE -I cql/XMP
......@@ -13,6 +13,33 @@ import cStringIO
import glob
from sets import Set
class _TextTestResult(unittest._TextTestResult):
def __init__(self, stream, descriptions, verbosity):
unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
def _exc_info_to_string(self, err, test):
return ""
def addSuccess(self, test):
unittest.TestResult.addSuccess(self, test)
self.stream.writeln('[ OK ]')
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
self.stream.writeln('[ ERROR ] \n%s' % test.longDescription())
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
self.stream.writeln('[ FAILED ] \n%s' % test.longDescription())
class TextTestRunner(unittest.TextTestRunner):
def __init__(self, verbosity=1):
unittest.TextTestRunner.__init__(self, stream=sys.stderr,
verbosity=verbosity)
def _makeResult(self):
return _TextTestResult(self.stream, self.descriptions, self.verbosity)
def diff_aux(expectedfile,resultfile,parser):
if filecmp.cmp(expectedfile,resultfile) :
return True
......@@ -68,8 +95,9 @@ def test_application(self,expected_file,cmd,diff):
output_file = "tmp/%s.cdi" % uid
output = open(output_file,'w')
print ' '.join(cmd)
p = Popen(cmd, stdout=output)
#print ' '.join(cmd)
devnull = open(os.devnull, 'wb')
p = Popen(cmd, stdout=output, stderr=devnull)
p.communicate()
d = diff(expected_file,output_file)
output.close()
......@@ -81,7 +109,8 @@ def maketest(test) :
comment = test['Comment'] if 'Comment' in test else None
expected = test['Expected'] if 'Expected' in test else None
exclude = map(lambda s: set(glob.glob(s)),test['Exclude'].split(' ')) if 'Exclude' in test else [set()]
inputfiles = set(glob.glob(test['Input'])) - set.union(*exclude)
globset = map(lambda s: set(glob.glob(s)),test['Input'].split(' '))
inputfiles = set.union(*globset) - set.union(*exclude)
cmd = test['Cmd'].split(' ')
difftype = diff_text
if expected is not None :
......@@ -91,18 +120,14 @@ def maketest(test) :
if os.path.isdir(expected) and len(inputfiles) > 1 :
expected = "%s" % (expected)
else :
print "1"
print "Expected must identify a directory"
exit(-1)
else :
if len(inputfiles) == 1 :
expected = "_tests/%si" % infile
else :
expected = "_tests"
expected = "_tests"
expected = expected
l = []
print inputfiles
for infile in inputfiles :
cmdline = cmd + [ infile ]
expectedfile = "%s/%si" % (expected,infile)
......@@ -147,9 +172,13 @@ class CDuceTests(unittest.TestCase):
self.comment = comment
self.expected = expected
self.cmd = cmd
self.infile = infile
self.difftype = diff_text
def shortDescription(self):
return "%s / %s" % (self.name,self.infile)
def longDescription(self):
if self.comment :
return "Description = " + self.comment + "\n" + ("Cmd = ") + " ".join(self.cmd) + "\nExpected file = %s" % self.expected + "\n"
else :
......@@ -169,7 +198,7 @@ def main():
verbose = args.verbose
unittest.TextTestRunner(verbosity=args.verbose).run(suite(args.inputfile[0],args.runtest,args.rungroup))
TextTestRunner(verbosity=args.verbose).run(suite(args.inputfile[0],args.runtest,args.rungroup))
if __name__ == '__main__':
main()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment