def main(args): opt = parse_options(args) osutils.mkdir_p("logs") abspath = os.path.abspath("logs") name = opt.file if opt.query: if opt.catalog is None: raise Exception("--query also requires a --catalog") with open(opt.query, 'r') as f: qt = f.read() target_alg = CCAlgebra(emit_print=EMIT_FILE) if opt.platform == 'grappa': target_alg = GrappaAlgebra(emit_print=EMIT_FILE) ClangProcessor(FromFileCatalog.load_from_file(opt.catalog))\ .write_source_code(qt, name, target_alg=target_alg) if opt.platform == 'grappa': runner = GrappalangRunner() runner.run(name, abspath) elif opt.platform == 'clang': try: runner = ClangRunner() runner.run(name, abspath) except subprocess.CalledProcessError as e: print 'clang runner for %s failed' % (name) print e.output raise
def main(args): opt = parse_options(args) osutils.mkdir_p("logs") abspath = os.path.abspath("logs") name = opt.file if opt.query: if opt.catalog is None: raise Exception("--query also requires a --catalog") with open(opt.query, 'r') as f: qt = f.read() target_alg = CCAlgebra(emit_print=EMIT_FILE) if opt.platform == 'grappa': target_alg = GrappaAlgebra(emit_print=EMIT_FILE) ClangProcessor(FromFileCatalog.load_from_file(opt.catalog))\ .write_source_code(qt, name, target_alg=target_alg) if opt.platform == 'grappa': runner = GrappalangRunner() runner.run(name, abspath) elif opt.platform == 'cpp': try: runner = ClangRunner() runner.run(name, abspath) except subprocess.CalledProcessError as e: print 'cpp runner for %s failed' % (name) print e.output raise
def main(args): opt = parse_options(args) osutils.mkdir_p("logs") abspath = os.path.abspath("logs") name = opt.file if opt.platform == 'grappa': runner = GrappalangRunner() runner.run(name, abspath) elif opt.platform == 'clang': try: runner = ClangRunner() runner.run(name, abspath) except subprocess.CalledProcessError as e: print 'clang runner for %s failed' % (name) print e.output raise
def checkstore(name, testplatform, trustedplatform=SqliteRunner("testqueries"), tmppath="tmp"): # noqa """ @param name: name of query @param tmppath: existing directory for temporary files """ osutils.mkdir_p(tmppath) abstmppath = os.path.abspath(tmppath) testplatform.run(name, abstmppath) trustedplatform.run(name, abstmppath) testoutfn = name expectedfn = "%s/%s.sqlite.csv" %(abstmppath, name) print "test: %s" % (name) verify_store(testoutfn, expectedfn, False)
def checkquery(name, tmppath="tmp", querypath="testqueries"): """ @param name: name of query @param tmppath: existing directory for temporary files """ osutils.mkdir_p(tmppath) envir = os.environ.copy() # cpp -> exe exe_name = './%s.exe' % (name) subprocess.check_call(['make', exe_name], env=envir) # run cpp testoutfn = '%s/%s.out' % (tmppath, name) with open(testoutfn, 'w') as outs: try: subprocess.check_call([exe_name], stdout=outs, env=envir) except subprocess.CalledProcessError as e1: # try again, this time collecting all output to print it try: subprocess.check_call([exe_name], stderr=subprocess.STDOUT, env=envir) raise e1 # just in case this doesn't fail again except subprocess.CalledProcessError as e2: print "see executable %s" % (os.path.abspath(exe_name)) print subprocess.check_output(['ls', '-l', exe_name], env=envir) print subprocess.check_output(['cat', '%s.cpp' % (name)], env=envir) raise Exception('(Process output below)\n'+e2.output+'\n(end process output)') querycode = readquery("%s/%s.sql" % (querypath,name)) querystr = make_query(name, querycode) # run sql conn = sqlite3.connect(testdbname()) c = conn.cursor() expectedfn = '%s/%s.sqlite.csv' % (tmppath, name) with open(expectedfn, 'w') as csvfile: wr = csv.writer(csvfile, delimiter=' ') for row in c.execute(querystr): wr.writerow(list(row)) print "test: %s" % (name) verify(testoutfn, expectedfn, False)
def checkstore(name, testplatform, trustedplatform=SqliteRunner("testqueries"), tmppath="tmp"): # noqa """ @param name: name of query @param tmppath: existing directory for temporary files """ osutils.mkdir_p(tmppath) abstmppath = os.path.abspath(tmppath) testplatform.run(name, abstmppath) trustedplatform.run(name, abstmppath) testoutfn = name expectedfn = "%s/%s.sqlite.csv" % (abstmppath, name) print "test: %s" % (name) verify_store(testoutfn, expectedfn, False)