This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Recover no-exceptions XFAILs
ClosedPublic

Authored by rmaprath on Sep 14 2016, 6:59 AM.

Details

Summary

When we added support for the no-exceptions build of libc++, all the tests that used exceptions got a blanket XFAIL for the no-exceptions variety.

Previously, we tried to fix-up these tests with an elaborate setjmp/longjmp hackery (see D14653), which was rejected on the grounds of being too complicated / obtrusive.

The current patch is a representative fix that does the most obvious thing instead: use pre-processor macros to exclude just the bits of the test that use exceptions. Unlike in the previous patch, this means we are not trying to associate / verify a particular behaviour of the no-exceptions library with respect to exceptional situations (like calling abort). Here we simply save the parts of the test that has nothing to do with exceptions, I think this is a fair compromise.

We could also split the test file into two; one that uses exceptions and one that does not, though I can't think of any added benefits of that approach.

If this patch is approved I'll go ahead and update the rest of the tests (~150) to follow the same.

Diff Detail

Event Timeline

rmaprath updated this revision to Diff 71347.Sep 14 2016, 6:59 AM
rmaprath updated this revision to Diff 71349.
rmaprath retitled this revision from to [libcxx] Recover no-exceptions XFAILs.
rmaprath updated this object.
rmaprath added reviewers: EricWF, mclow.lists.
rmaprath added a subscriber: cfe-commits.

(Added more context)

mclow.lists edited edge metadata.Sep 14 2016, 9:33 AM

What an awful test. I wonder who wrote such a steaming pile. Probably me.

What an awful test. I wonder who wrote such a steaming pile. Probably me.

I think I've thrown quite a lot of XFAILs like this in the past, just to get the no-exceptions build passing. Now I've got to clean them up one by one :)

Are you OK with this way of fixing them?

Cheers,

/ Asiri

EricWF accepted this revision.Sep 15 2016, 1:57 AM
EricWF edited edge metadata.

This approach looks great. I don't think we need to split things up into separate files. This is exactly how test_macros.h should be used.

Feel free to convert as many tests as possible. I've been doing the same to anything I work on.

test/std/re/re.alg/re.alg.search/grep.pass.cpp
25

I prefer putting the #if on the inside of the function so you don't also have to #ifdef it out in main() below.

This revision is now accepted and ready to land.Sep 15 2016, 1:57 AM
rmaprath added inline comments.Sep 15 2016, 2:28 AM
test/std/re/re.alg/re.alg.search/grep.pass.cpp
25

Thanks. That's much better.

I'll convert as much tests as possible and submit and overall patch for a final review.

Looks like patch was not committed.

Looks like patch was not committed.

Need to replicate this to as many tests as possible (~150). I was hoping to do all that and upload another diff for a final review, couldn't get to it I'm afraid. Hope to do this very very soon.

Sorry for the delay.

/ Asiri

EricWF added a comment.Oct 4 2016, 3:03 PM

Feel free to send them in 10-20 at a time. It'll be much faster to review that way.

rmaprath updated this revision to Diff 73661.Oct 5 2016, 9:57 AM
rmaprath edited edge metadata.

First batch of XFAIL fixes.

I've changed some XFAILs to UNSUPPORTED where the test is all about exception handling. In other cases, I've used the test macro TEST_HAS_NO_EXCEPTIONS to conditionally exclude those parts that test
exception handling behaviour.

@EricWF: I can create a separate review if necessary, thought I'll re-use this review for the first batch, will be opening new reviews for the follow-ups.

/ Asiri

EricWF added a comment.Oct 5 2016, 3:32 PM

First batch of XFAIL fixes.

I've changed some XFAILs to UNSUPPORTED where the test is all about exception handling. In other cases, I've used the test macro TEST_HAS_NO_EXCEPTIONS to conditionally exclude those parts that test
exception handling behaviour.

The changes look great! Thanks for the patch.

The only suggestion I have is using TEST_THROW to guard a single throw statement. TEST_THROW will abort if it's executed in a no-exceptions build, which is better than silently passing over code that should throw. See the inline comments for example usage.

@EricWF: I can create a separate review if necessary, thought I'll re-use this review for the first batch, will be opening new reviews for the follow-ups.

Sounds good to me. This batch LGTM but I can't re-approve this review. Please commit w/ requested inline changes and then close this revision.

/ Asiri

test/std/thread/futures/futures.async/async.pass.cpp
76 ↗(On Diff #73661)

To guard a single throw x; consider using TEST_THROW(x). This way the test will abort ungracefully if it tries to evaluate a throw at runtime.

test/std/thread/futures/futures.promise/move_ctor.pass.cpp
23 ↗(On Diff #73661)

Nit: I prefer including test_macros.h as the first support header.

test/std/thread/futures/futures.promise/set_value_const.pass.cpp
28 ↗(On Diff #73661)

Nit: Use TEST_THROW

test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
36 ↗(On Diff #73661)

Nit: TEST_THROW

rmaprath updated this revision to Diff 73759.Oct 6 2016, 4:13 AM

Final patch to be committed, with all the remaining comments addressed.

rmaprath closed this revision.Oct 6 2016, 6:11 AM

Committed as r283441.

Thanks!