From d26f0ea0e5b01eaba826056a6c60e63435a84f82 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sat, 17 Feb 2018 21:38:29 -0500 Subject: [PATCH] Some test printouts to help us debug the MinGW x86 explosion --- .gitignore | 1 + .travis.yml | 33 +++++++--- cmake/Modules/FindCatch.cmake | 2 +- cmake/Modules/FindLuaBuild/LuaJIT.cmake | 7 +- cmake/Modules/FindToLuappBuild.cmake | 3 + scripts/run.osx.sh | 19 ++++++ tests/test_coroutines.cpp | 86 ++++++++++++------------- tests/test_usertypes.cpp | 13 ++++ 8 files changed, 111 insertions(+), 53 deletions(-) create mode 100644 scripts/run.osx.sh diff --git a/.gitignore b/.gitignore index 17d9b580..a4f12bc8 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,4 @@ scratch/ .idea/ cmake-build-debug/ cmake-build-relwithdebinfo/ +cmake-build-release/ diff --git a/.travis.yml b/.travis.yml index eb0c336e..16d6b04e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,8 +41,8 @@ script: matrix: fast_finish: true allow_failures: - - env: - - ALLOW_FAILURE=true + - os: osx + include: # GCC 4.9.x, 5.x, 6.x, 7.x - env: @@ -148,12 +148,29 @@ matrix: GCC_VERSION=7 PLATFORM=x64 CI=true - - - env: - - LUA_VERSION=luajit-2.1.0-beta3 - GCC_VERSION=7 - PLATFORM=x64 - CI=true + + # XCode / Mac builds + - os: osx + osx_image: xcode8.3 + env: + - LUA_VERSION=lua-5.3.4 + LLVM_VERSION=5.0.1 + before_install: + - brew update > /dev/null + - brew install zsh git ninja cmake python + script: + - ./scripts/run.osx.sh + + - os: osx + osx_image: xcode9.2 + env: + - LUA_VERSION=lua-5.3.4 + LLVM_VERSION=5.0.1 + before_install: + - brew update > /dev/null + - brew install zsh git ninja cmake python + script: + - ./scripts/run.osx.sh notifications: webhooks: diff --git a/cmake/Modules/FindCatch.cmake b/cmake/Modules/FindCatch.cmake index 2f8b2555..6af63a0c 100644 --- a/cmake/Modules/FindCatch.cmake +++ b/cmake/Modules/FindCatch.cmake @@ -70,7 +70,7 @@ add_library(${catch_lib} INTERFACE) target_include_directories(${catch_lib} INTERFACE ${catch_include_dirs}) if (MSVC) - target_add_compile_options(${catch_lib} INTERFACE + target_compile_options(${catch_lib} INTERFACE /D_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING) endif() diff --git a/cmake/Modules/FindLuaBuild/LuaJIT.cmake b/cmake/Modules/FindLuaBuild/LuaJIT.cmake index c8650bfe..b87d3a81 100644 --- a/cmake/Modules/FindLuaBuild/LuaJIT.cmake +++ b/cmake/Modules/FindLuaBuild/LuaJIT.cmake @@ -373,6 +373,11 @@ set_target_properties(${lualib} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES C INTERFACE_INCLUDE_DIRECTORIES "${LUA_JIT_SOURCE_DIR}") +if (CMAKE_DL_LIBS) + set_target_properties(${lualib} + PROPERTIES + INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}) +endif() if (XCODE) target_compile_options(${lualib} PUBLIC -pagezero_size 10000 -image_base 100000000) @@ -380,7 +385,7 @@ endif () # # Lua Executable add_executable(${luainterpreter} IMPORTED) -# Point EXE to fiel +# Add location pointing to executable set_target_properties(${luainterpreter} PROPERTIES IMPORTED_LOCATION "${LUA_JIT_EXE_FILE}") diff --git a/cmake/Modules/FindToLuappBuild.cmake b/cmake/Modules/FindToLuappBuild.cmake index 8c08b7b9..b10dcf3e 100644 --- a/cmake/Modules/FindToLuappBuild.cmake +++ b/cmake/Modules/FindToLuappBuild.cmake @@ -77,6 +77,9 @@ else() INTERFACE -Wno-noexcept-type PUBLIC -Wno-ignored-qualifiers -Wno-unused-parameter) endif() +if (CMAKE_DL_LIBS) + target_link_libraries(${toluapp_lib} PRIVATE ${CMAKE_DL_LIBS}) +endif() # add compatibility define target_compile_definitions(${toluapp_lib} PRIVATE COMPAT53_PREFIX=toluapp_compat53) diff --git a/scripts/run.osx.sh b/scripts/run.osx.sh new file mode 100644 index 00000000..c445d755 --- /dev/null +++ b/scripts/run.osx.sh @@ -0,0 +1,19 @@ +mkdir -p build-sol2/Debug +mkdir -p build-sol2/Release +cd build-sol2 + +echo "=== Compiler and tool variables ===" +ninja --version +cmake --version + +cd Debug + cmake ${SOL2_DIR} -G Xcode -DCMAKE_BUILD_TYPE=Debug -DLUA_VERSION="${LUA_VERSION}" -DCI=ON -DPLATFORM=${PLATFORM} -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DEXAMPLES_SINGLE=ON -DTESTS_SINGLE=ON + cmake --build . --config Debug + ctest --build-config Debug --output-on-failure +cd .. + +cd Release + cmake ${SOL2_DIR} -G Xcode -DCMAKE_BUILD_TYPE=Release -DLUA_VERSION="${LUA_VERSION}" -DCI=ON -DPLATFORM=${PLATFORM} -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DEXAMPLES_SINGLE=ON -DTESTS_SINGLE=ON + cmake --build . --config Release + ctest --build-config Release --output-on-failure +cd .. diff --git a/tests/test_coroutines.cpp b/tests/test_coroutines.cpp index e52e8973..8a234dc8 100644 --- a/tests/test_coroutines.cpp +++ b/tests/test_coroutines.cpp @@ -532,53 +532,53 @@ end } TEST_CASE("coroutines/yielding", "test that a sol2 bound function can yield when marked yieldable") { - sol::state lua; - lua.open_libraries(sol::lib::base, sol::lib::coroutine); - - int i = 0; - auto func = [&i]() { - ++i; - return i; - }; - - struct h { - int x = 500; - int func() const { - return x; - } - } hobj{}; - - lua["f"] = sol::yielding(func); - lua["g"] = sol::yielding([]() { return 300; }); - lua["h"] = sol::yielding(&h::func); - lua["hobj"] = &hobj; - - sol::string_view code = R"( - co1 = coroutine.create(f) - success1, value1 = coroutine.resume(co1) - co2 = coroutine.create(g) - success2, value2 = coroutine.resume(co2) - co3 = coroutine.create(function() - h(hobj) - end) - success3, value3 = coroutine.resume(co3) - )"; - - auto result = lua.safe_script(code); - REQUIRE(result.valid()); + sol::state lua; + lua.open_libraries(sol::lib::base, sol::lib::coroutine); - bool success1 = lua["success1"]; - int value1 = lua["value1"]; - REQUIRE(success1); + int i = 0; + auto func = [&i]() { + ++i; + return i; + }; + + struct h { + int x = 500; + int func() const { + return x; + } + } hobj{}; + + lua["f"] = sol::yielding(func); + lua["g"] = sol::yielding([]() { return 300; }); + lua["h"] = sol::yielding(&h::func); + lua["hobj"] = &hobj; + + sol::string_view code = R"( + co1 = coroutine.create(function () return f() end) + success1, value1 = coroutine.resume(co1) + co2 = coroutine.create(function () return g() end) + success2, value2 = coroutine.resume(co2) + co3 = coroutine.create(function() + h(hobj) + end) + success3, value3 = coroutine.resume(co3) + )"; + + auto result = lua.safe_script(code); + REQUIRE(result.valid()); + + bool success1 = lua["success1"]; + int value1 = lua["value1"]; + REQUIRE(success1); REQUIRE(value1 == 1); - bool success2 = lua["success2"]; - int value2 = lua["value2"]; - REQUIRE(success2); + bool success2 = lua["success2"]; + int value2 = lua["value2"]; + REQUIRE(success2); REQUIRE(value2 == 300); - bool success3 = lua["success3"]; - int value3 = lua["value3"]; - REQUIRE(success3); + bool success3 = lua["success3"]; + int value3 = lua["value3"]; + REQUIRE(success3); REQUIRE(value3 == 500); } diff --git a/tests/test_usertypes.cpp b/tests/test_usertypes.cpp index 51d8a3ea..c3e7ec1b 100644 --- a/tests/test_usertypes.cpp +++ b/tests/test_usertypes.cpp @@ -645,6 +645,7 @@ TEST_CASE("usertype/nonmember-functions", "let users set non-member functions th } giver& g = lua.get("t"); REQUIRE(g.a == 20); + std::cout << "----- end of 1" << std::endl; } TEST_CASE("usertype/unique-shared-ptr", "manage the conversion and use of unique and shared pointers ('unique usertypes')") { @@ -673,6 +674,7 @@ TEST_CASE("usertype/unique-shared-ptr", "manage the conversion and use of unique REQUIRE(moreref.use_count() == sharedintref.use_count()); } REQUIRE(preusecount == sharedint.use_count()); + std::cout << "----- end of 2" << std::endl; } TEST_CASE("regressions/one", "issue number 48") { @@ -691,18 +693,24 @@ TEST_CASE("regressions/one", "issue number 48") { REQUIRE(my_var_ref.boop == 1); REQUIRE(my_var_ptr->boop == 1); REQUIRE(std::addressof(my_var_ref) == my_var_ptr); + std::cout << "----- end of 3" << std::endl; } TEST_CASE("usertype/get-set-references", "properly get and set with std::ref semantics. Note that to get, we must not use Unqualified on the type...") { + std::cout << "----- in 4" << std::endl; sol::state lua; lua.new_usertype("vars", "boop", &vars::boop); vars var{}; vars rvar{}; + std::cout << "setting beep" << std::endl; lua.set("beep", var); + std::cout << "setting rbeep" << std::endl; lua.set("rbeep", std::ref(rvar)); + std::cout << "getting my_var" << std::endl; auto& my_var = lua.get("beep"); + std::cout << "setting rbeep" << std::endl; auto& ref_var = lua.get>("rbeep"); vars& proxy_my_var = lua["beep"]; std::reference_wrapper proxy_ref_var = lua["rbeep"]; @@ -719,6 +727,7 @@ TEST_CASE("usertype/get-set-references", "properly get and set with std::ref sem REQUIRE(std::addressof(proxy_ref_var.get()) == std::addressof(rvar)); REQUIRE(rvar.boop == 5); REQUIRE(rvar.boop == ref_var.boop); + std::cout << "----- end of 4" << std::endl; } TEST_CASE("usertype/private-constructible", "Check to make sure special snowflake types from Enterprise thingamahjongs work properly.") { @@ -749,6 +758,7 @@ TEST_CASE("usertype/private-constructible", "Check to make sure special snowflak int expectednumkilled = numkilled + 1; REQUIRE(expectednumsaved == factory_test::num_saved); REQUIRE(expectednumkilled == factory_test::num_killed); + std::cout << "----- end of 5" << std::endl; } TEST_CASE("usertype/const-pointer", "Make sure const pointers can be taken") { @@ -769,6 +779,7 @@ TEST_CASE("usertype/const-pointer", "Make sure const pointers can be taken") { lua.safe_script("x = b:foo(a)"); int x = lua["x"]; REQUIRE(x == 201); + std::cout << "----- end of 6" << std::endl; } TEST_CASE("usertype/overloading", "Check if overloading works properly for usertypes") { @@ -806,6 +817,7 @@ TEST_CASE("usertype/overloading", "Check if overloading works properly for usert REQUIRE((lua["c"] == bark_58)); auto result = lua.safe_script("r:func(1,2,'meow')", sol::script_pass_on_error); REQUIRE_FALSE(result.valid()); + std::cout << "----- end of 7" << std::endl; } TEST_CASE("usertype/overloading_values", "ensure overloads handle properly") { @@ -840,6 +852,7 @@ TEST_CASE("usertype/overloading_values", "ensure overloads handle properly") { REQUIRE(res3 == 524); REQUIRE(res4 == 524); + std::cout << "----- end of 8" << std::endl; } TEST_CASE("usertype/reference-and-constness", "Make sure constness compiles properly and errors out at runtime") {