Separate output into its own module

This commit is contained in:
James Westman 2022-10-14 21:04:37 -05:00
parent 8cf793023d
commit a24f16109f
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
33 changed files with 407 additions and 291 deletions

View file

@ -1,6 +1,8 @@
import os, sys
from pythonfuzz.main import PythonFuzz
from blueprintcompiler.outputs.xml import XmlOutput
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
from blueprintcompiler import tokenizer, parser, decompiler, gir
@ -17,8 +19,9 @@ def fuzz(buf):
tokens = tokenizer.tokenize(blueprint)
ast, errors, warnings = parser.parse(tokens)
xml = XmlOutput()
if errors is None and len(ast.errors) == 0:
actual = ast.generate()
xml.emit(ast)
except CompilerBugError as e:
raise e
except PrintableError:

View file

@ -5,7 +5,7 @@
<signal name="activate" handler="click" object="button"/>
</object>
<object class="GtkButton" id="button">
<signal name="clicked" handler="on_button_clicked" swapped="true"/>
<signal name="clicked" handler="on_button_clicked" swapped="True"/>
<signal name="notify::visible" handler="on_button_notify_visible"/>
</object>
</interface>

View file

@ -28,6 +28,7 @@ from blueprintcompiler.completions import complete
from blueprintcompiler.errors import PrintableError, MultipleErrors, CompileError
from blueprintcompiler.tokenizer import Token, TokenType, tokenize
from blueprintcompiler import utils
from blueprintcompiler.outputs.xml import XmlOutput
class TestSamples(unittest.TestCase):
@ -56,7 +57,8 @@ class TestSamples(unittest.TestCase):
if len(warnings):
raise MultipleErrors(warnings)
actual = ast.generate()
xml = XmlOutput()
actual = xml.emit(ast)
if actual.strip() != expected.strip(): # pragma: no cover
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
print("\n".join(diff))