This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Change ifstream constructor tests to handle read-only files.
ClosedPublic

Authored by STL_MSFT on Nov 17 2016, 1:36 PM.

Details

Summary

[libcxx] [test] Change ifstream constructor tests to handle read-only files.

Certain source control systems like to set the read-only bit on their files,
which interferes with opening "test.dat" for both input and output.
Fortunately, we can work around this without losing test coverage.
Now, the ifstream.cons tests have comments referring to the ofstream.cons tests.
There, we're creating writable files (not checked into source control),
where the ifstream constructor tests will succeed.

Diff Detail

Event Timeline

STL_MSFT updated this revision to Diff 78413.Nov 17 2016, 1:36 PM
STL_MSFT retitled this revision from to [libcxx] [test] Change ifstream constructor tests to handle read-only files..
STL_MSFT updated this object.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
EricWF edited edge metadata.Nov 17 2016, 11:15 PM

I really dislike this change. I'm afraid that these changes allow the tests to silently fail for reasons other than test.dat being read only. For example if test.dat ever gets deleted, or if libc++'s remote test-harness fails to copy the input file to the remote host.

I'm not sure how to work around your read-only VCS issue though... Do you have any other ideas?

My changes to the ofstream.cons tests preserve the test coverage (as they already contain the machinery to create writable files).

Would you like it if I removed the "if (fs) { stuff }" blocks from the ifstream.cons tests entirely, and changed the comments to say things along the lines of "for basic_ifstream(const char *, ios_base::openmode) tests, we need writable files, so see BLAH"?

STL_MSFT updated this revision to Diff 78589.Nov 18 2016, 3:16 PM
STL_MSFT updated this object.
STL_MSFT edited edge metadata.

Instead of skipping failures to open, just have comments pointing to the ofstream.cons tests where this coverage has moved.

As yet another alternative, I could keep the ios_base::openmode tests in ifstream.cons, but use ios_base::binary instead of ios_base::out.

EricWF accepted this revision.Dec 10 2016, 6:45 PM
EricWF edited edge metadata.

LGTM. Thanks for working on this.

This revision is now accepted and ready to land.Dec 10 2016, 6:45 PM
STL_MSFT closed this revision.Dec 12 2016, 12:03 PM