60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
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()
|