From d05769b80ee8d71684b1e6eef97f75b7d4a51271 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 26 Dec 2017 08:04:54 -0500 Subject: [PATCH] fix up examples and use build log to get neat messages --- CMakeLists.txt | 1 + appveyor.yml | 31 +++++++++++-------------------- examples/assert.hpp | 2 +- examples/config.cpp | 10 +++++----- examples/functions.cpp | 8 ++++---- examples/multi_results.cpp | 2 +- examples/usertype.cpp | 4 ++-- examples/variables.cpp | 4 ++-- examples/variadic_args.cpp | 6 +++--- single/sol/sol.hpp | 4 ++-- single/sol/sol_forward.hpp | 4 ++-- 11 files changed, 34 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b80c1096..9a3b3c49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,6 +216,7 @@ if (TESTS OR TESTS_SINGLE OR EXAMPLES OR TESTS_EXAMPLES) # # Enable test harness for regular or single tests if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES) # enable ctest + message(STATUS "Testing enabled...") enable_testing() endif() # # Add tests here diff --git a/appveyor.yml b/appveyor.yml index f3f2a5d8..b20fdf3f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -31,24 +31,19 @@ image: - Visual Studio 2017 - Visual Studio 2015 +platform: +- x86 +- x64 + environment: matrix: - LUA_VERSION: 5.3.4 MINGW_VERSION: 6.3.0 - PARALLELISM: - LUA_VERSION: 5.3.4 MINGW_VERSION: 5.3.0 - PARALLELISM: - LUA_VERSION: 5.3.4 - PARALLELISM: -- /maxcpucount - LUA_VERSION: 5.2.4 - PARALLELISM: -- /maxcpucount - LUA_VERSION: 5.1.5 - PARALLELISM: -- /maxcpucount - -platform: -- x86 -- x64 matrix: allow_failures: @@ -90,11 +85,11 @@ init: - set arch= - if "%PLATFORM%"=="x64" (set arch= Win64) - echo %APPVEYOR_BUILD_WORKER_IMAGE% -- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (set CMAKE_GENERATOR=Visual Studio 15 2017%arch%) -- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (set CMAKE_GENERATOR=Visual Studio 14 2015%arch%) -- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2013" (set CMAKE_GENERATOR=Visual Studio 12 2013%arch%) -- if "%MINGW_VERSION%"=="5.3.0" (set CMAKE_GENERATOR=Ninja) -- if "%MINGW_VERSION%"=="6.3.0" (set CMAKE_GENERATOR=Ninja) +- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (set CMAKE_GENERATOR=Visual Studio 15 2017%arch%&&set parallelism=/maxcpucount&&set logger=/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll") +- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (set CMAKE_GENERATOR=Visual Studio 14 2015%arch%&&set parallelism=/maxcpucount&&set logger=/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll") +- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2013" (set CMAKE_GENERATOR=Visual Studio 12 2013%arch%&&set parallelism=/maxcpucount&&set logger=/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll") +- if "%MINGW_VERSION%"=="5.3.0" (set CMAKE_GENERATOR=Ninja%%set build_type=-DCMAKE_BUILD_TYPE=Release) +- if "%MINGW_VERSION%"=="6.3.0" (set CMAKE_GENERATOR=Ninja&&set build_type=-DCMAKE_BUILD_TYPE=Release) # print out useful information - ninja --version - cmake --version @@ -106,10 +101,6 @@ init: before_build: - set python_path=C:\Python36 - set mingw_path= -- set build_type= -- set parallelism= -- if "%CMAKE_GENERATOR%"=="MinGW Makefiles" (set build_type=-DCMAKE_BUILD_TYPE=Release) -- if "%CMAKE_GENERATOR%"=="Ninja" (set build_type=-DCMAKE_BUILD_TYPE=Release) - if "%MINGW_VERSION%"=="5.3.0" (set mingw_path=C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0) - if "%MINGW_VERSION%"=="6.3.0" ( if "%PLATFORM%"=="x64" (set mingw_path=C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1) else ( set mingw_path=C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1)) - if "%PLATFORM%"=="x64" (set python_path=C:\Python36-x64) @@ -123,8 +114,8 @@ before_build: # generates too much debug info for MinGW to handle # TODO: fix the damn compilation space and time already build_script: -- if NOT "%build_type%"=="-DCMAKE_BUILD_TYPE=Release" (cmake --build . --config Debug %PARALLELISM%) -- cmake --build . --config Release %PARALLELISM% +- if NOT "%build_type%"=="-DCMAKE_BUILD_TYPE=Release" (cmake --build . --config Debug -- %parallelism% %logger%) +- cmake --build . --config Release -- %parallelism% %logger% test_script: - if NOT "%build_type%"=="-DCMAKE_BUILD_TYPE=Release" (ctest -C Debug --output-on-failure) diff --git a/examples/assert.hpp b/examples/assert.hpp index a51b1ebf..2c189750 100644 --- a/examples/assert.hpp +++ b/examples/assert.hpp @@ -23,7 +23,7 @@ } \ } while (false) #else -# define m_c_assert(condition, message) do { (void)sizeof(condition); (void)sizeof(message); } while (false) +# define m_assert(condition, message) do { (void)sizeof(condition); (void)sizeof(message); } while (false) # define c_assert(condition) do { (void)sizeof(condition); } while (false) #endif diff --git a/examples/config.cpp b/examples/config.cpp index c7a1b983..e44bb079 100644 --- a/examples/config.cpp +++ b/examples/config.cpp @@ -20,18 +20,18 @@ struct config { }; int main() { - sol::state lua; + sol::state lua; config screen; // To use the file, uncomment here and make sure it is in local dir - //lua.script_file("config.lua"); + //lua.script_file("config.lua"); lua.script(R"( name = "Asus" width = 1920 height = 1080 )"); - screen.name = lua.get("name"); - screen.width = lua.get("width"); - screen.height = lua.get("height"); + screen.name = lua.get("name"); + screen.width = lua.get("width"); + screen.height = lua.get("height"); c_assert(screen.name == "Asus"); c_assert(screen.width == 1920); c_assert(screen.height == 1080); diff --git a/examples/functions.cpp b/examples/functions.cpp index 6851b8fd..c3c5da44 100644 --- a/examples/functions.cpp +++ b/examples/functions.cpp @@ -35,10 +35,10 @@ int main() { lua.set_function("mult_by_five", &multiplier::by_five); // assert that the functions work - lua.script("c_assert(my_add(10, 11) == 21)"); - lua.script("c_assert(my_mul(4.5, 10) == 45)"); - lua.script("c_assert(mult_by_ten(50) == 500)"); - lua.script("c_assert(mult_by_five(10) == 50)"); + lua.script("assert(my_add(10, 11) == 21)"); + lua.script("assert(my_mul(4.5, 10) == 45)"); + lua.script("assert(mult_by_ten(50) == 500)"); + lua.script("assert(mult_by_five(10) == 50)"); // using lambdas, functions can have state. int x = 0; diff --git a/examples/multi_results.cpp b/examples/multi_results.cpp index d3bc6219..9ff90453 100644 --- a/examples/multi_results.cpp +++ b/examples/multi_results.cpp @@ -21,7 +21,7 @@ int main() { lua.script("print('calling multi_tuple')"); lua.script("print(multi_tuple())"); lua.script("x, y = multi_tuple()"); - lua.script("c_assert(x == 10 and y == 'goodbye')"); + lua.script("assert(x == 10 and y == 'goodbye')"); auto multi = lua.get("multi_tuple"); int first; diff --git a/examples/usertype.cpp b/examples/usertype.cpp index b2899157..0117d98c 100644 --- a/examples/usertype.cpp +++ b/examples/usertype.cpp @@ -96,7 +96,7 @@ int main() { lua.script("v = vector.new()\n" "v = vector.new(12)\n" "v = vector.new(10, 10)\n" - "c_assert(not v:is_unit())\n"); + "assert(not v:is_unit())\n"); // You can even have C++-like member-variable-access // just pass is public member variables in the same style as functions @@ -108,7 +108,7 @@ int main() { "assert(not vars.low_gravity)\n" "vars.low_gravity = true\n" "local x = vars.low_gravity\n" - "c_assert(x)"); + "assert(x)"); std::cout << std::endl; diff --git a/examples/variables.cpp b/examples/variables.cpp index 04bb196f..c8f5b7fd 100644 --- a/examples/variables.cpp +++ b/examples/variables.cpp @@ -17,8 +17,8 @@ int main() { lua.set("y", "hello"); // assert values are as given - lua.script("c_assert(x == 10)"); - lua.script("c_assert(y == 'hello')"); + lua.script("assert(x == 10)"); + lua.script("assert(y == 'hello')"); // basic retrieval of a variable diff --git a/examples/variadic_args.cpp b/examples/variadic_args.cpp index 64b4dcdb..591558a2 100644 --- a/examples/variadic_args.cpp +++ b/examples/variadic_args.cpp @@ -32,9 +32,9 @@ int main() { // will error: not enough arguments //lua.script("x4 = v(1)"); - lua.script("c_assert(x == 50)"); - lua.script("c_assert(x2 == 600)"); - lua.script("c_assert(x3 == 21)"); + lua.script("assert(x == 50)"); + lua.script("assert(x2 == 600)"); + lua.script("assert(x3 == 21)"); lua.script("print(x)"); // 50 lua.script("print(x2)"); // 600 lua.script("print(x3)"); // 21 diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 185c6a1d..86657690 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2017-12-26 04:26:55.295046 UTC -// This header was generated with sol v2.19.0 (revision acade46) +// Generated 2017-12-26 13:03:03.527337 UTC +// This header was generated with sol v2.19.0 (revision 3fa176c) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP diff --git a/single/sol/sol_forward.hpp b/single/sol/sol_forward.hpp index a7cd982d..fa4e2426 100644 --- a/single/sol/sol_forward.hpp +++ b/single/sol/sol_forward.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2017-12-26 04:26:55.501596 UTC -// This header was generated with sol v2.19.0 (revision acade46) +// Generated 2017-12-26 13:03:03.719432 UTC +// This header was generated with sol v2.19.0 (revision 3fa176c) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP