Porting and Coverage Test
This week I spent time porting code to mac. One thing that took some time and annoyed me was overwriting a file atomically. Linux gets pretty close. What I did was open a file with O_TMPFILE, write all the data to it, use linkat to create a file (which has the complete data), then use rename to overwrite. There's very little time between linkat and rename. I tried using renameat/renameat2 with the unlinked file but got a cross device error (EXDEV). Looking at the man pages it appears that rename doesn't support unlinked files.
On mac it's not close. I write data to a file with tmp in the filename, then use rename to overwrite the original. I dislike that you can see the temporary file and that there will be partial data. However, the important part is the last step (using rename) is atomic. There should never be data loss.
After having the code run on mac I moved onto coverage and unit testing. I got line coverage up to 95% in the library, and a little over 90% in the rest of the code. I had to refactor the event system to test it properly but there were no major problems, the codebase is still small.
One last thing I worked on was improving GUI code when the window is too small to show all of the GUI.