Hdl21
Hdl21 copied to clipboard
Don't Test Against Netlist String Literals
This comes up from time to time, notably in #44.
We do something like:
some_hdl21_thing = h.Something()
h.netlist(some_hdl21_thing, dest)
# OK great! Now check we got "the expected" netlist:
assert "thing \n" in dest
...And then, some time later, we get stuff like so:
FAIL FAIL FAIL
assert "thing \n" in "thing \n" # <= now there's two spaces there
i.e.
- There are many degrees of freedom in netlist-text
- VLSIR (tools) every so often makes a non-semantic change among them - i.e. adding or remove whitespace or line-breaks
- (Notably in #44 - such changes were actually surprisingly semantic-relevant)
The tests should instead probably be:
- Make sure the HDL21 stuff converts to VLSIR, i.e. survives
to_proto
- Do all the checks against the VLSIR stuff
- I.e. all those assertions should be like
assert isinstance(h.to_proto(thing), vlsir.Thing)
- I.e. all those assertions should be like
- Still run netlisting
- Just don't check the literal output
- Maybe just check that, like, it's not empty?