[PATCH] D39203: [raw_fd_ostream] report actual error in error messages

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 14:30:21 PDT 2017


inglorion added a comment.

> Oh, do you think this is worth a unit test? It should be easy to add one for "file not found" or something, if you try creating a file in a directory that doesn't exist.

I would like to have a test for this, but after trying a few things for a couple of hours I decided to punt on that and try to ship the improvement without adding a test. The issue is that this change only applies to errors that happen after the file has been opened (errors during open were already reported back to the caller). That makes it harder to come up with a test that works reliably across operating systems. I tried opening the file and getting an fd, then passing the fd to the raw_fd_ostream constructor that takes one, closing the fd, then writing to the stream - but the result is that the test dies before ever reporting success or failure (on Windows). There are other things we could do, for example mocking the calls that actually interact with the filesystem, but that didn't really seem worth the effort. If you agree, I'd like to ship this without the test for now.


https://reviews.llvm.org/D39203





More information about the llvm-commits mailing list