def compile_example(directory, f): """Run the Souffle example in directory 'directory'. The test file is named f. Returns the exit code of the compilation command.""" print("Testing", directory) global tests_compiled, tests_compiled_successfully, libpath tests_compiled = tests_compiled + 1 savedir = os.getcwd() os.chdir(directory) code, output = run_command(["cc", "-x", "c", "-E", "-P", "-undef", "-nostdinc", f]) if code != 0: raise Exception("Error " + str(code) + " running cpp") with open(f + ".tmp", "w") as tmp: tmp.write(output) options = ConversionOptions() options.relationPrefix = directory.replace("/", "::") + "::souffle::" options.toDNF = True convert(f + ".tmp", "souffle", options) if code == 0: code, _ = run_command(["ddlog", "-i", "souffle.dl", "-L", libpath]) if code == 0: run_command(["rm", f + ".tmp"]) tests_compiled_successfully = tests_compiled_successfully + 1 else: print("Error compiling", directory + "/" + f) os.chdir(savedir) return code
def compile_example(directory, f): """Run the Souffle example in directory 'directory'. The test file is named f.""" print "Testing " + directory global tests_compiled, tests_compiled_successfully, libpath tests_compiled = tests_compiled + 1 savedir = os.getcwd() os.chdir(directory) code, output = run_command(["cc", "-x", "c", "-E", "-P", "-undef", "-nostdinc++", f]) if code != 0: raise Exception("Error " + str(code) + " running cpp") with open(f + ".tmp", "w") as tmp: tmp.write(output) convert(f + ".tmp", "souffle", directory.replace("/", ".") + ".souffle.") if code == 0: code, _ = run_command(["ddlog", "-i", "souffle.dl", "-L", libpath]) if code == 0: run_command(["rm", f + ".tmp"]) tests_compiled_successfully = tests_compiled_successfully + 1 os.chdir(savedir) return code