martinmoene / lest

A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)
Boost Software License 1.0
390 stars 45 forks source link

Build fails due to missing <io.h> header in contrib/lest_expect_abort #39

Closed furkanusta closed 7 years ago

furkanusta commented 7 years ago

Hi, I've just cloned the library and tried to run make test, but by default it builds contrib files and in lest_expect_abort.hpp there is header included and it is missing in my system. I am using gcc 6.2.1 in Fedora 24.

And if I comment add_subdirectory(contrib) line in CMakeFiles, I get

The following tests FAILED: 8 - 04-c++03 (Failed) 9 - 14-module-cpp03 (Failed) 10 - 01-basic (Failed) 11 - 02-basic (Failed) 12 - 03-decompose (Failed) 13 - 05-select (Failed) 14 - 06-approx (Failed) 15 - 07-udt (Failed) 19 - 11-auto-reg (Failed) 20 - 15-extract-function (Failed) 21 - 15-extract-lambda (Failed) 22 - 15-extract-template-function (Failed) 23 - 12-module (Failed) 24 - 13-module-auto-reg (Failed) Errors while running CTest

I am not sure if contrib files are necessary, or am I doing some kind of mistake.

martinmoene commented 7 years ago

Hi @furkanusta,

The contrib files are not necessary for normal usage of lest, in fact I'm not sure if what's in there now is a good idea at all.

The examples that fail, do so to demonstrate the usage of things, for example:

example>"04-c++03.exe" --pass
04-c++03.cpp:33: passed: character: a() < b() for 'a' < 'b'
04-c++03.cpp:34: failed: character: b() < a() for 'b' < 'a'
04-c++03.cpp:39: passed: integral: x() != y() for 3 != 7
04-c++03.cpp:40: failed: integral: x() == y() for 3 == 7
04-c++03.cpp:45: passed: real: pi() != e() for 3.14 != 2.72
04-c++03.cpp:46: failed: real: pi() != pi() for 3.14 != 3.14
04-c++03.cpp:51: passed: mixed real, integral: pi() != x() for 3.14 != 3
04-c++03.cpp:52: failed: mixed real, integral: pi() == x() for 3.14 == 3
04-c++03.cpp:57: passed: mixed integral, real: x() != pi() for 3 != 3.14
04-c++03.cpp:58: failed: mixed integral, real: x() == pi() for 3 == 3.14
04-c++03.cpp:63: passed: boolean: t() == t() for true == true
04-c++03.cpp:64: failed: boolean: t() == f() for true == false
04-c++03.cpp:73: passed: pointer: ptr() == (void*)NULL for 0 == 0
04-c++03.cpp:74: failed: pointer: ptr() != (void*)NULL for 0 != 0
04-c++03.cpp:81: passed: class object pointer: &a == &a for 0x75f3f7 == 0x75f3f7
04-c++03.cpp:82: failed: class object pointer: &a == &b for 0x75f3f7 == 0x75f3f6
04-c++03.cpp:87: passed: std::string: std_world > std_hello for "world" > "hello"
04-c++03.cpp:88: failed: std::string: std_world < std_hello for "world" < "hello"
04-c++03.cpp:93: passed: C-string: world > std_hello for "world" > "hello"
04-c++03.cpp:94: failed: C-string: world < std_hello for "world" < "hello"
04-c++03.cpp:100: passed: single evaluation: 1 == ++n for 1 == 1
04-c++03.cpp:106: failed: duplicate evaluation: 2 == ++n for 2 == 1
11 out of 12 selected tests failed.

What counts for lest's usage is that the tests in folder test do pass and it looks like they do in your case and you're doing it right.

Hope this helps, Martin

furkanusta commented 7 years ago

Thanks for the response.

So, if I am not going to use contrib functionality, then it doesn't matter if those tests fail? and, I don't know CMake much but it might be better to put contrib as a submodule and enable it via a flag or something like that.

martinmoene commented 7 years ago

Indeed looks like a good idea to disable contrib ate default. CMake does provide facilities for that and I'll add that. Thanks!

martinmoene commented 7 years ago

Handled in issue #40.