Commit cc51dade authored by Daniel Tuulik's avatar Daniel Tuulik
Browse files

Update testqgen, add QGen Ada and C test

Update test invoking patten,
add root_model and language arguments
For now only one makefile is up to date with the new
test invoking pattern (test-aggregation3)
parent 0762e3e5
......@@ -6,7 +6,9 @@ GNATMAKE=gnatmake -gnat2012
GNATBIND=gnatbind
GNATLINK=gnatlink -lgcov -coverage
O=0
TESTQGEN=../testqgen.py
TESTQGEN_PARSE=../testqgen.py test-qgen-parse
TESTQGEN_ADA=../testqgen.py test-qgen-ada
TESTQGEN_C=../testqgen.py test-qgen-c
clean:
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.so *.ali gnat.cfg \
......
include ../shared.mk
ROOT_MODEL=system_structure.pr
all: test-ada test-llvm
edit:
......@@ -9,7 +11,13 @@ test-parse:
$(OPENGEODE) challenge.pr system_structure.pr --check
test-qgen-parse:
$(TESTQGEN) challenge.pr system_structure.pr
$(TESTQGEN_PARSE) $(ROOT_MODEL)
test-qgen-ada:
$(TESTQGEN_ADA) $(ROOT_MODEL)
test-qgen-c:
$(TESTQGEN_C) $(ROOT_MODEL)
test-ada: challenge.ali dataview-uniq.o | test_ada.o
$(GNATBIND) -n challenge.ali
......
......@@ -16,6 +16,8 @@ testsWork = {
'all': work1,
'test-parse' : work1,
'test-qgen-parse' : work1,
'test-qgen-ada' : work1,
'test-qgen-c' : work1,
'test-ada' : work1,
'test-c' : work1,
'test-llvm' : work1,
......
#!/usr/bin/env python2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
......@@ -14,15 +14,17 @@ import unittest
import difflib
import re
import string
import time
import test
__version__ = '1.0.0'
LOG = logging.getLogger(__name__)
def parse_args():
''' Parse command line arguments '''
parser = argparse.ArgumentParser(version=__version__)
parser.add_argument('files', metavar='file.pr', type=str, nargs='*',
help='SDL file(s)')
parser = argparse.ArgumentParser()
parser.add_argument('rule', metavar='Rule', type=str)
parser.add_argument('root_model', metavar='file.pr', type=str,
help='SDL root model')
parser.add_argument('-u', '--update', action='store_true')
return parser.parse_args()
......@@ -33,19 +35,6 @@ def init_logging(options):
handler_console = logging.StreamHandler()
handler_console.setFormatter(terminal_formatter)
LOG.addHandler(handler_console)
def getSizeFiles(list,size):
err = 0
files = [os.path.abspath(file) for file in list]
for file in files:
s = os.path.getsize(file)
if s > size:
err = 1
LOG.error(file+ " too large - size " + str(s))
else:
LOG.warning(file+ " size " + str(s))
return err
def diff(expected, actual, msg=None, count=1, case_sensitive=True,
update=None, silent=False, directory=''):
......@@ -123,26 +112,50 @@ def colored_unified_diff(a, b, fromfile='', tofile='',
yield line
def main():
options = parse_args()
init_logging(options)
start = time.time()
results = []
op = parse_args()
init_logging(op)
result = run_test(op)
print("%40s: %s" % (result[3], test.colorMe(result[0],
'[OK]' if result[0]==0 else '[FAILED]')))
results.append(result)
sys.stdout.write('\n')
elapsed = time.time() - start
return test.summarize(results, elapsed)
def run_test(op):
''' Call a SDL parser with the required arguments '''
jar_dir = os.environ.get('JAR_DIR')
jar_name = os.environ.get('JAR_NAME')
jar_path = os.path.join (jar_dir,jar_name)
for file in options.files:
#expected = file + '.out'
cmd = ['java', '-jar', jar_path, os.path.abspath(file)]
print (cmd)
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
errcode = proc.wait()
#diff(expected=expected, actual=proc.stdout)
return (errcode, stdout, stderr)
if op.rule == 'test-qgen-parse':
lang = 'xmi'
elif op.rule == 'test-qgen-ada':
lang = 'ada'
elif op.rule == 'test-qgen-c':
lang = 'c'
else:
# the importer crashes if any other value us used here,
# for now keep xmi as default value
lang = 'xmi'
#expected = file + '.out'
cmd = ['java', '-jar', jar_path, op.root_model,
'--language', lang]
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
errcode = proc.wait()
#diff(expected=expected, actual=proc.stdout
return (errcode, stdout, stderr, op.root_model, op.rule)
if __name__ == '__main__':
ret = main()
sys.exit(ret)
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