Init Commit: Moved bproto to seperate repo
This commit is contained in:
59
test/compiler/backend/test_compiler_python.py
Normal file
59
test/compiler/backend/test_compiler_python.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import sys
|
||||
import pytest
|
||||
from compiler import BprotoCompiler
|
||||
sys.path.append('src/')
|
||||
|
||||
from errors import BprotoCompilerError
|
||||
from backend.rendering.pythonBackend import PythonBackendRenderer
|
||||
from backend.fsOutput import BackendFileSystemOutput
|
||||
|
||||
|
||||
@pytest.mark.skip()
|
||||
def test_compiler_python_against_ref():
|
||||
# Load Refernces
|
||||
with open("test/test_protocol.bproto") as f:
|
||||
source_text = f.read()
|
||||
|
||||
# Comile Stuff
|
||||
compiler = BprotoCompiler([
|
||||
PythonBackendRenderer(".")
|
||||
], "template")
|
||||
|
||||
try:
|
||||
output: BackendFileSystemOutput = compiler.compile(source_text, ".")
|
||||
except BprotoCompilerError:
|
||||
assert False, "This should run througth"
|
||||
|
||||
output.saveToDisk("test/backend_output/python")
|
||||
string_output = output.toString()
|
||||
|
||||
with open("test/reference/python/HCP_protocol_enum.py") as f:
|
||||
assert f.read() == string_output.get("HCP_protocol_enum.py")
|
||||
|
||||
with open("test/reference/python/HCP_protocol_bitfield.py") as f:
|
||||
assert f.read() == string_output.get("HCP_protocol_bitfield.py")
|
||||
|
||||
with open("test/reference/python/HCP_protocol_message_ids.py") as f:
|
||||
assert f.read() == string_output.get("HCP_protocol_message_ids.py")
|
||||
|
||||
with open("test/reference/python/HCP_protocol_packets.py") as f:
|
||||
assert f.read() == string_output.get("HCP_protocol_packets.py")
|
||||
|
||||
|
||||
def test_compiler_python_smoke_test():
|
||||
# Load Refernces
|
||||
with open("test/test_protocol.bproto") as f:
|
||||
source_text = f.read()
|
||||
|
||||
# Comile Stuff
|
||||
compiler = BprotoCompiler([
|
||||
PythonBackendRenderer(".")
|
||||
], "template")
|
||||
|
||||
try:
|
||||
output: BackendFileSystemOutput = compiler.compile(source_text, ".")
|
||||
except BprotoCompilerError:
|
||||
assert False, "This should run througth"
|
||||
|
||||
output.saveToDisk("test/backend_output/python")
|
||||
output.toString()
|
||||
Reference in New Issue
Block a user