def test_emit(path, Backend): text = open(path).read() maybe_xfail(text) base = os.path.splitext(path)[0] comp = Compiler() comp.parse(os.path.basename(path), text) comp.compile() backend = Backend() comp.emit(backend) extbase = os.path.join(base, backend.ext) if not os.path.exists(extbase): os.makedirs(extbase) srcs = [] assertions = [] for name in backend.files: path = os.path.join(extbase, name) srcs.append(path) computed = backend.files[name] expected = check_file(path, computed) assertions.append((expected, computed)) for expected, computed in assertions: assert expected == computed assert len(backend.files) == len(walk(extbase, ".%s" % backend.ext)) BUILDERS[backend.ext](comp, extbase, srcs)