mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Begin incorporating Python unit tests into build
We now build a separate APE binary for each test so they can run in parallel. We've got 148 tests running fast and stable so far.
This commit is contained in:
parent
51904e2687
commit
b5f743cdc3
121 changed files with 4995 additions and 4767 deletions
57
third_party/python/Parser/asdl_c.py
vendored
57
third_party/python/Parser/asdl_c.py
vendored
|
@ -1269,41 +1269,68 @@ class ChainOfVisitors:
|
|||
v.visit(object)
|
||||
v.emit("", 0)
|
||||
|
||||
common_msg = "/* File automatically generated by %s. */\n\n"
|
||||
|
||||
def main(srcfile, dump_module=False):
|
||||
argv0 = sys.argv[0]
|
||||
components = argv0.split(os.sep)
|
||||
argv0 = os.sep.join(components[-2:])
|
||||
auto_gen_msg = common_msg % argv0
|
||||
mod = asdl.parse(srcfile)
|
||||
if dump_module:
|
||||
print('Parsed Module:')
|
||||
print(mod)
|
||||
if not asdl.check(mod):
|
||||
sys.exit(1)
|
||||
|
||||
if H_FILE:
|
||||
with open(H_FILE, "w") as f:
|
||||
f.write(auto_gen_msg)
|
||||
f.write('#include "asdl.h"\n\n')
|
||||
f.write("\
|
||||
#ifndef COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_PYTHON_AST_H_\n\
|
||||
#define COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_PYTHON_AST_H_\n\
|
||||
#include \"third_party/python/Include/asdl.h\"\n\
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)\n\
|
||||
COSMOPOLITAN_C_START_\n\
|
||||
/* clang-format off */\n\
|
||||
/* File automatically generated by %s. */\n\
|
||||
\n\
|
||||
" % argv0)
|
||||
c = ChainOfVisitors(TypeDefVisitor(f),
|
||||
StructVisitor(f),
|
||||
PrototypeVisitor(f),
|
||||
)
|
||||
c.visit(mod)
|
||||
f.write("PyObject* PyAST_mod2obj(mod_ty t);\n")
|
||||
f.write("mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n")
|
||||
f.write("int PyAST_Check(PyObject* obj);\n")
|
||||
f.write("\
|
||||
PyObject* PyAST_mod2obj(mod_ty t);\n\
|
||||
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n\
|
||||
int PyAST_Check(PyObject* obj);\n\
|
||||
\n\
|
||||
COSMOPOLITAN_C_END_\n\
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */\n\
|
||||
#endif /* COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_PYTHON_AST_H_ */\n")
|
||||
|
||||
if C_FILE:
|
||||
with open(C_FILE, "w") as f:
|
||||
f.write(auto_gen_msg)
|
||||
f.write('#include <stddef.h>\n')
|
||||
f.write('\n')
|
||||
f.write('#include "Python.h"\n')
|
||||
f.write('#include "%s-ast.h"\n' % mod.name)
|
||||
f.write('\n')
|
||||
f.write("static PyTypeObject AST_type;\n")
|
||||
f.write('\
|
||||
#include "third_party/python/Include/%s-ast.h"\n\
|
||||
#include "third_party/python/Include/abstract.h"\n\
|
||||
#include "third_party/python/Include/boolobject.h"\n\
|
||||
#include "third_party/python/Include/descrobject.h"\n\
|
||||
#include "third_party/python/Include/dictobject.h"\n\
|
||||
#include "third_party/python/Include/listobject.h"\n\
|
||||
#include "third_party/python/Include/longobject.h"\n\
|
||||
#include "third_party/python/Include/modsupport.h"\n\
|
||||
#include "third_party/python/Include/object.h"\n\
|
||||
#include "third_party/python/Include/objimpl.h"\n\
|
||||
#include "third_party/python/Include/pyerrors.h"\n\
|
||||
#include "third_party/python/Include/pythonrun.h"\n\
|
||||
#include "third_party/python/Include/tupleobject.h"\n\
|
||||
#include "third_party/python/Include/yoink.h"\n\
|
||||
/* clang-format off */\n\
|
||||
\n\
|
||||
PYTHON_PROVIDE("_ast");\n\
|
||||
\n\
|
||||
/* File automatically generated by %s. */\n\
|
||||
\n\
|
||||
static PyTypeObject AST_type;\n\
|
||||
' % (mod.name, argv0))
|
||||
v = ChainOfVisitors(
|
||||
PyTypesDeclareVisitor(f),
|
||||
PyTypesVisitor(f),
|
||||
|
|
4
third_party/python/Parser/metagrammar.c
vendored
4
third_party/python/Parser/metagrammar.c
vendored
|
@ -146,7 +146,7 @@ static label labels[19] = {
|
|||
{7, 0},
|
||||
{8, 0},
|
||||
};
|
||||
static grammar _PyParser_Grammar = {
|
||||
static grammar _PyParser_Grammarz = {
|
||||
6,
|
||||
dfas,
|
||||
{19, labels},
|
||||
|
@ -156,7 +156,7 @@ static grammar _PyParser_Grammar = {
|
|||
grammar *
|
||||
meta_grammar(void)
|
||||
{
|
||||
return &_PyParser_Grammar;
|
||||
return &_PyParser_Grammarz;
|
||||
}
|
||||
|
||||
grammar *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue