Hdl21 icon indicating copy to clipboard operation
Hdl21 copied to clipboard

Don't Test Against Netlist String Literals

Open dan-fritchman opened this issue 1 year ago • 0 comments

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)
  • Still run netlisting
    • Just don't check the literal output
    • Maybe just check that, like, it's not empty?

dan-fritchman avatar May 30 '23 23:05 dan-fritchman