def compile(path, file_filter): dir = os.path.dirname(path) text = open(path).read() maybe_xfail(text) base = os.path.splitext(path)[0] include_stdlib = False if path.endswith("include-stdlib.q"): include_stdlib = True c = Compiler(include_stdlib) try: c.urlparse(path) c.compile() failed_expectations = [] for root in c.roots: # Skip standard library: if "quarkc/lib/" in root.url: continue for ast in root.files: if ast.filename == "reflector": continue if file_filter(ast.filename): continue astname = os.path.splitext(ast.filename)[0] + ".astc" astpath = os.path.join(dir, astname) content = ast.pprint() expected = check_file(astpath, content) if content != expected: failed_expectations.append(astname) assert not failed_expectations, failed_expectations except (CompileError, ParseError), e: expected = base + ".err" computed = str(e).replace(os.path.dirname(path) + "/", "") assert_file(expected, computed)
def compile(path, file_filter): dir = os.path.dirname(path) text = open(path).read() maybe_xfail(text) base = os.path.splitext(path)[0] c = Compiler() try: c.urlparse(path) c.compile() failed_expectations = [] for root in c.roots: for ast in root.files: if ast.filename == "reflector": continue if file_filter(ast.filename): continue astname = os.path.splitext(ast.filename)[0] + ".astc" astpath = os.path.join(dir, astname) content = ast.pprint() expected = check_file(astpath, content) if content != expected: failed_expectations.append(astname) assert not failed_expectations, failed_expectations except (CompileError, ParseError), e: expected = base + ".err" computed = str(e).replace(os.path.dirname(path) + "/", "") assert_file(expected, computed)