fuzz: Test more of the code

This commit is contained in:
James Westman 2023-09-28 20:12:23 -05:00
parent 78acb2fe51
commit f5822898ca

View file

@ -7,15 +7,18 @@ from blueprintcompiler.outputs.xml import XmlOutput
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
from blueprintcompiler import decompiler, gir, parser, tokenizer, utils from blueprintcompiler import gir, parser, tokenizer
from blueprintcompiler.completions import complete from blueprintcompiler.completions import complete
from blueprintcompiler.errors import ( from blueprintcompiler.errors import CompilerBugError, PrintableError
CompileError, from blueprintcompiler.lsp import LanguageServer
CompilerBugError,
MultipleErrors,
PrintableError, def assert_ast_doesnt_crash(text, tokens, ast):
) for i in range(len(text)):
from blueprintcompiler.tokenizer import Token, TokenType, tokenize ast.get_docs(i)
for i in range(len(text)):
list(complete(LanguageServer(), ast, tokens, i))
ast.get_document_symbols()
@PythonFuzz @PythonFuzz
@ -29,6 +32,7 @@ def fuzz(buf):
xml = XmlOutput() xml = XmlOutput()
if errors is None and ast is not None: if errors is None and ast is not None:
xml.emit(ast) xml.emit(ast)
assert_ast_doesnt_crash(blueprint, tokens, ast)
except CompilerBugError as e: except CompilerBugError as e:
raise e raise e
except PrintableError: except PrintableError: