This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Use separate referenes for windows in the path.append test
ClosedPublic

Authored by mstorsjo on Oct 22 2020, 3:39 AM.

Diff Detail

Event Timeline

mstorsjo created this revision.Oct 22 2020, 3:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2020, 3:39 AM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript
mstorsjo requested review of this revision.Oct 22 2020, 3:39 AM
ldionne requested changes to this revision.Feb 25 2021, 10:13 AM
ldionne added a subscriber: ldionne.
ldionne added inline comments.
libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
147

I'm not sure I understand, can you give me an example of why this fails on Windows with PathEq?

This revision now requires changes to proceed.Feb 25 2021, 10:13 AM
mstorsjo added inline comments.Feb 25 2021, 11:03 AM
libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
147

PathEq checks that the strings are literally identical, while path::operator== checks that the paths mean the same (i.e. tolerating both slash forms on windows).

When we test appending p2 to p1 on windows, we get the path p1\p2, but the test reference is p1/p2.

We can't just run make_preferred() on the reference and do a literal comparison either: If the original path is p1/p2 and we append p3, we get p1/p2\p3.

So this weakens the test a bit (it doesn't distinguish between p1/p2 and p1//p2 iirc either), but is a simple change to make. The alternative would be to ifdef the whole table and add duplicate references (or to add ref_posix, ref_windows in each table entry). Thinking of it now (3 months later), the last option actually sounds pretty good although it makes the patch messier.

mstorsjo updated this revision to Diff 326483.Feb 25 2021, 1:43 PM
mstorsjo retitled this revision from [libcxx] [test] Use path::operator== instead of PathEq in the path.append test to [libcxx] [test] Use separate referenes for windows in the path.append test.
mstorsjo edited the summary of this revision. (Show Details)

Adding more reviewers on this one too. (Contrary to the other patches, this one doesn't have one earlier LGTM though - but it's been updated according to what was discussed with Louis earlier.)

libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
147

To add some context here - I discussed this one with Louis outside of Phabricator back after this review, and we agreed that adding separate references for the expected result for both cases is the best way to go.

ldionne accepted this revision.Mar 4 2021, 7:58 AM

LGTM if we get rid of the expect macro.

libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
55–56

Let's use a function for this:

MultiStringType const& expected_result(AppendOperatorTestcase const& tc) {
#if defined(_WIN32)
  return tc. expect_windows;
#else
  return tc.expect_posix;
#endif
};

Then, use expected_result(TC) below instead of TC.expect. WDYT? Feel free to make it a member function if you prefer.

This revision is now accepted and ready to land.Mar 4 2021, 7:58 AM
mstorsjo added inline comments.Mar 4 2021, 1:18 PM
libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
55–56

That sounds good, thanks, will do. I'll go with a member function in this case, not that it really matters.