* * * * *
The case of the regression test regression, part IV
Like all bugs, it was a simple fix once identified—it was just identifying
the bug that was difficult. The bug [1] was due to a semantic change in an
API (Application Programming Interface). Lua [2] has a file interface that
includes a read() function, and the parameter it's given dictates how much to
read. One of the parameters is “a” (or “*a” if you are using Lua 5.1) that
indicates you want to read all possible data until the end-of-file is
reached.
I ended up writing my own read() function to deal with network activity. I
couldn't just open up a normal Lua file object with a network connection
because that doesn't work nicely with event driven programs. An earlier
version of my read() function had a different semantic meaning with “a”—it
just returned any buffered data. It was in a later change where I aligned the
semantics to match Lua's semantics, but forgot to change that bit of code in
the one component. And those semantic changes explain the behavior I was
seeing yesterday [3]. It only took what? A week? To find the culprit.
Now the regression test with the updated code runs as fast as the previous
version.
[1]
gopher://gopher.conman.org/0Phlog:2021/08/19.1
[2]
https://www.lua.org/
[3]
gopher://gopher.conman.org/0Phlog:2021/08/25.1
Email author at
[email protected]