emusolutions / LAGraph

This is a library plus a test harness for collecting algorithms that use the GraphBLAS
Other
0 stars 0 forks source link

Make MMRead treat data folder as Immutable #17

Closed moonwatcher closed 1 year ago

moonwatcher commented 1 year ago

test_MMRead contains a subtest that (strangely) test MMWrite. That test seems to modify the comments.txt and comments_*.mtx files. At the end of test_MMRead those files go back to how they were checked into the repository but that means that a failure in test_MMRead can drag on ghost failures in other tests (specifically observed in test_minmax). If test_MMRead passes all is well, but if it doesn't it can be pretty weird...

This PR changes the test to write to temp files, opened r/w with tmpfile() and rewinded instead of opened separately for write then read.

The total effect is not changing the data directory and remove this spurious effect.

I also added build* to .gitignore since we build in build_lc and it makes the git diff... irritating...

moonwatcher commented 1 year ago

Just for completion sake, this implementation uses the tmpfile() method, this method opens up a temporary file, usually in /tmp, with some random name in r/w mode and deletes it when you close the file handler. its a little different than the original test that opened a file, read it with MMRead closed it than wrote it with some comments, closed it. opened it again and read it into a GrB_Matrix and compared. so its testing both MMRead and MMWrite, adding comments and making sure they don't change the resulting GrB_Matrix. This implementation does all this but without closing the file. The temp file is opened with r/w and then rewinded every time. This is nothing new, some other parts of test_MMRead use this same logic (I just replicated this pattern).

@jamesETsmith comment removed. You can merge it as you leisure.