コード例 #1
0
ファイル: test_compile.py プロジェクト: datawire/quark
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)
コード例 #2
0
ファイル: test_compile.py プロジェクト: bozzzzo/quark
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)
コード例 #3
0
ファイル: test_compile.py プロジェクト: turboza/quark
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)
コード例 #4
0
ファイル: test_parse.py プロジェクト: turboza/quark
def parse(path, file_filter):
    dir = os.path.dirname(path)
    text = open(path).read()
    maybe_xfail(text)
    c = Compiler()
    c.urlparse(path, recurse=False)
    for ast in c.roots[path].files:
        if file_filter(ast.filename): continue
        base = os.path.splitext(ast.filename)[0]
        assert_file(os.path.join(dir, base + ".ast"), ast.pprint())
        code = ast.code()
        assert_file(os.path.join(dir, base + ".code"), code)
        rtc = Compiler()
        rtc.urlparse(base + ".code", recurse=False)
        for f in rtc.roots[base + ".code"].files:
            if f.name == base + ".code":
                assert f.code() == code
                break
        else:
            assert False
コード例 #5
0
ファイル: test_parse.py プロジェクト: bozzzzo/quark
def parse(path, file_filter):
    dir = os.path.dirname(path)
    text = open(path).read()
    maybe_xfail(text)
    c = Compiler()
    c.urlparse(path, recurse=False)
    for ast in c.roots[path].files:
        if file_filter(ast.filename): continue
        base = os.path.splitext(ast.filename)[0]
        assert_file(os.path.join(dir, base + ".ast"), ast.pprint())
        code = ast.code()
        assert_file(os.path.join(dir, base + ".code"), code)
        rtc = Compiler()
        rtc.urlparse(base + ".code", recurse=False)
        for f in rtc.roots[base + ".code"].files:
            if f.name == base + ".code":
                assert f.code() == code
                break
        else:
            assert False
コード例 #6
0
ファイル: test_emit.py プロジェクト: datawire/quark
def get_dist(name):
    code = os.path.join(directory, name + ".q")
    cmp = Compiler()
    file = cmp.urlparse(code, recurse=False)
    name, ver = namever(file)
    return name
コード例 #7
0
def do_compile(output, path):
    text = open(path).read()
    for b in backends:
        maybe_xfail(text, b().ext)
    return path, compile(Compiler(), path, output, *backends)
コード例 #8
0
def get_dist(name):
    code = os.path.join(directory, name + ".q")
    cmp = Compiler()
    file = cmp.urlparse(code, recurse=False)
    name, ver = namever(file)
    return name