In nofork mode, the location of a failed assertion within a test case is lost if that test case has a checked teardown fixture (even if that fixture function is empty).
Test case attached. Compiles for me on Linux with "gcc -o check-bug-99 check-bug-99.c -lcheck" and when executed, results in messages like:
(null)👎S:tc:will_fail:0: Assertion '0' failed
instead of the expected:
check-bug-99.c:7:F:tc:will_fail:0: Assertion '0' failed
I'm running this with check 0.9.14, having configured and built it myself with "--disable-subunit" passed to the configure script.
I'm running this on Linux (Fedora 20), x86_64.
Version 0.9.10 does not have this problem (perhaps because it didn't run the checked teardown functions after a test failure?)
It works in fork mode.
The reason why this happens is this: the end of the message sequence coming down the pipe is CK_MSG_LOC (location of failing test), CK_MSG_FAIL, CK_MSG_CTX (TEARDOWN). It is this final message that confuses things, because rcvmsg_update_ctx() updates rmsg->lastctx (which I suspect is the right thing for it to do), which is the ctx value used by the first 'if' body in construct_test_result() in its call to tr_set_loc_by_ctx()
I've toyed with various patches for this, but I'm unsure which fix is correct.
1) change construct_test_result() to initialise tr->ctx with rmsg->failctx instead of rmsg->lastctx, in first 'if';
2) change construct_test_result() to initialise tr->ctx with rmsg->failctx instead of rmsg->lastctx, in first 'if', but only if rmsg->failctx != CK_CTX_INVALID;
3) change rcvmsg_update_ctx() to not update rmsg->lastctx if rmsg->failctx != CK_CTX_INVALID.
I think fix (3) is wrong. I think fix (1) is right. I'm not sure if fix (2) is better than fix (1).
Thanks for this bug report and your analysis. After looking at the problem, I believe that the second solution is correct. (Actually, the first results in unit test failures).
The example you provided will be included with the fix as a unit test to verify this behavior in the future. Additionally, I'll put you in the AUTHORS file for the project.
Until Check 0.9.14 checked fixtures were disabled if Check was compiled without fork(), as they would not have worked properly. This was mostly resolved, however you pointed out an issue which was not caught.
Thanks for your interest in the project!