GNOME Bugzilla – Bug 684956
Test programs shall report pass/fail with exit status
Last modified: 2012-10-18 13:29:16 UTC
Most of the test programs in libsigc++2/tests print a lot of text and exit with exit status 0 unconditionally. This is not how test programs executed by 'make check' shall behave. Preferably they shall not print anything if the test passes. More importantly their exit status shall not be 0 if the test fails.
Created attachment 225263 [details] [review] patch: Improve some test cases. This patch shows how the test cases test_accum_iter, test_accumulated and test_cpp11_lambda can be improved. (test_cpp11_lambda was fairly good. It's only slightly improved.) I'll leave the patch here for others to comment on it. If it's accepted, or I get no comments within a week or two, I will push it, and probably later change more test cases.
I've changed all test cases in the master branch. What was previously written to std::cout is now written to an std::ostringstream, and compared with the expected results. I have tested with gcc 4.6.3 and gcc 4.7.2 on a PC with Ubuntu 12.04. I've assumed that the results of all test cases except test_size are implementation-independent. If this assumption is wrong, 'make check' will fail with another compiler and/or another type of processor. I don't expect that to happen, but I can't rule it out.