mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
fix up examples and use build log to get neat messages
This commit is contained in:
parent
3fa176c5ef
commit
d05769b80e
|
@ -216,6 +216,7 @@ if (TESTS OR TESTS_SINGLE OR EXAMPLES OR TESTS_EXAMPLES)
|
||||||
# # Enable test harness for regular or single tests
|
# # Enable test harness for regular or single tests
|
||||||
if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES)
|
if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES)
|
||||||
# enable ctest
|
# enable ctest
|
||||||
|
message(STATUS "Testing enabled...")
|
||||||
enable_testing()
|
enable_testing()
|
||||||
endif()
|
endif()
|
||||||
# # Add tests here
|
# # Add tests here
|
||||||
|
|
31
appveyor.yml
31
appveyor.yml
|
@ -31,24 +31,19 @@ image:
|
||||||
- Visual Studio 2017
|
- Visual Studio 2017
|
||||||
- Visual Studio 2015
|
- Visual Studio 2015
|
||||||
|
|
||||||
|
platform:
|
||||||
|
- x86
|
||||||
|
- x64
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- LUA_VERSION: 5.3.4
|
- LUA_VERSION: 5.3.4
|
||||||
MINGW_VERSION: 6.3.0
|
MINGW_VERSION: 6.3.0
|
||||||
PARALLELISM:
|
|
||||||
- LUA_VERSION: 5.3.4
|
- LUA_VERSION: 5.3.4
|
||||||
MINGW_VERSION: 5.3.0
|
MINGW_VERSION: 5.3.0
|
||||||
PARALLELISM:
|
|
||||||
- LUA_VERSION: 5.3.4
|
- LUA_VERSION: 5.3.4
|
||||||
PARALLELISM: -- /maxcpucount
|
|
||||||
- LUA_VERSION: 5.2.4
|
- LUA_VERSION: 5.2.4
|
||||||
PARALLELISM: -- /maxcpucount
|
|
||||||
- LUA_VERSION: 5.1.5
|
- LUA_VERSION: 5.1.5
|
||||||
PARALLELISM: -- /maxcpucount
|
|
||||||
|
|
||||||
platform:
|
|
||||||
- x86
|
|
||||||
- x64
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
@ -90,11 +85,11 @@ init:
|
||||||
- set arch=
|
- set arch=
|
||||||
- if "%PLATFORM%"=="x64" (set arch= Win64)
|
- if "%PLATFORM%"=="x64" (set arch= Win64)
|
||||||
- echo %APPVEYOR_BUILD_WORKER_IMAGE%
|
- 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 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%)
|
- 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%)
|
- 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)
|
- 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)
|
- if "%MINGW_VERSION%"=="6.3.0" (set CMAKE_GENERATOR=Ninja&&set build_type=-DCMAKE_BUILD_TYPE=Release)
|
||||||
# print out useful information
|
# print out useful information
|
||||||
- ninja --version
|
- ninja --version
|
||||||
- cmake --version
|
- cmake --version
|
||||||
|
@ -106,10 +101,6 @@ init:
|
||||||
before_build:
|
before_build:
|
||||||
- set python_path=C:\Python36
|
- set python_path=C:\Python36
|
||||||
- set mingw_path=
|
- 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%"=="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 "%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)
|
- if "%PLATFORM%"=="x64" (set python_path=C:\Python36-x64)
|
||||||
|
@ -123,8 +114,8 @@ before_build:
|
||||||
# generates too much debug info for MinGW to handle
|
# generates too much debug info for MinGW to handle
|
||||||
# TODO: fix the damn compilation space and time already
|
# TODO: fix the damn compilation space and time already
|
||||||
build_script:
|
build_script:
|
||||||
- if NOT "%build_type%"=="-DCMAKE_BUILD_TYPE=Release" (cmake --build . --config Debug %PARALLELISM%)
|
- if NOT "%build_type%"=="-DCMAKE_BUILD_TYPE=Release" (cmake --build . --config Debug -- %parallelism% %logger%)
|
||||||
- cmake --build . --config Release %PARALLELISM%
|
- cmake --build . --config Release -- %parallelism% %logger%
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- if NOT "%build_type%"=="-DCMAKE_BUILD_TYPE=Release" (ctest -C Debug --output-on-failure)
|
- if NOT "%build_type%"=="-DCMAKE_BUILD_TYPE=Release" (ctest -C Debug --output-on-failure)
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
#else
|
#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)
|
# define c_assert(condition) do { (void)sizeof(condition); } while (false)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -20,18 +20,18 @@ struct config {
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
sol::state lua;
|
sol::state lua;
|
||||||
config screen;
|
config screen;
|
||||||
// To use the file, uncomment here and make sure it is in local dir
|
// 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"(
|
lua.script(R"(
|
||||||
name = "Asus"
|
name = "Asus"
|
||||||
width = 1920
|
width = 1920
|
||||||
height = 1080
|
height = 1080
|
||||||
)");
|
)");
|
||||||
screen.name = lua.get<std::string>("name");
|
screen.name = lua.get<std::string>("name");
|
||||||
screen.width = lua.get<int>("width");
|
screen.width = lua.get<int>("width");
|
||||||
screen.height = lua.get<int>("height");
|
screen.height = lua.get<int>("height");
|
||||||
c_assert(screen.name == "Asus");
|
c_assert(screen.name == "Asus");
|
||||||
c_assert(screen.width == 1920);
|
c_assert(screen.width == 1920);
|
||||||
c_assert(screen.height == 1080);
|
c_assert(screen.height == 1080);
|
||||||
|
|
|
@ -35,10 +35,10 @@ int main() {
|
||||||
lua.set_function("mult_by_five", &multiplier::by_five);
|
lua.set_function("mult_by_five", &multiplier::by_five);
|
||||||
|
|
||||||
// assert that the functions work
|
// assert that the functions work
|
||||||
lua.script("c_assert(my_add(10, 11) == 21)");
|
lua.script("assert(my_add(10, 11) == 21)");
|
||||||
lua.script("c_assert(my_mul(4.5, 10) == 45)");
|
lua.script("assert(my_mul(4.5, 10) == 45)");
|
||||||
lua.script("c_assert(mult_by_ten(50) == 500)");
|
lua.script("assert(mult_by_ten(50) == 500)");
|
||||||
lua.script("c_assert(mult_by_five(10) == 50)");
|
lua.script("assert(mult_by_five(10) == 50)");
|
||||||
|
|
||||||
// using lambdas, functions can have state.
|
// using lambdas, functions can have state.
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
|
@ -21,7 +21,7 @@ int main() {
|
||||||
lua.script("print('calling multi_tuple')");
|
lua.script("print('calling multi_tuple')");
|
||||||
lua.script("print(multi_tuple())");
|
lua.script("print(multi_tuple())");
|
||||||
lua.script("x, y = 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<sol::function>("multi_tuple");
|
auto multi = lua.get<sol::function>("multi_tuple");
|
||||||
int first;
|
int first;
|
||||||
|
|
|
@ -96,7 +96,7 @@ int main() {
|
||||||
lua.script("v = vector.new()\n"
|
lua.script("v = vector.new()\n"
|
||||||
"v = vector.new(12)\n"
|
"v = vector.new(12)\n"
|
||||||
"v = vector.new(10, 10)\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
|
// You can even have C++-like member-variable-access
|
||||||
// just pass is public member variables in the same style as functions
|
// just pass is public member variables in the same style as functions
|
||||||
|
@ -108,7 +108,7 @@ int main() {
|
||||||
"assert(not vars.low_gravity)\n"
|
"assert(not vars.low_gravity)\n"
|
||||||
"vars.low_gravity = true\n"
|
"vars.low_gravity = true\n"
|
||||||
"local x = vars.low_gravity\n"
|
"local x = vars.low_gravity\n"
|
||||||
"c_assert(x)");
|
"assert(x)");
|
||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ int main() {
|
||||||
lua.set("y", "hello");
|
lua.set("y", "hello");
|
||||||
|
|
||||||
// assert values are as given
|
// assert values are as given
|
||||||
lua.script("c_assert(x == 10)");
|
lua.script("assert(x == 10)");
|
||||||
lua.script("c_assert(y == 'hello')");
|
lua.script("assert(y == 'hello')");
|
||||||
|
|
||||||
|
|
||||||
// basic retrieval of a variable
|
// basic retrieval of a variable
|
||||||
|
|
|
@ -32,9 +32,9 @@ int main() {
|
||||||
// will error: not enough arguments
|
// will error: not enough arguments
|
||||||
//lua.script("x4 = v(1)");
|
//lua.script("x4 = v(1)");
|
||||||
|
|
||||||
lua.script("c_assert(x == 50)");
|
lua.script("assert(x == 50)");
|
||||||
lua.script("c_assert(x2 == 600)");
|
lua.script("assert(x2 == 600)");
|
||||||
lua.script("c_assert(x3 == 21)");
|
lua.script("assert(x3 == 21)");
|
||||||
lua.script("print(x)"); // 50
|
lua.script("print(x)"); // 50
|
||||||
lua.script("print(x2)"); // 600
|
lua.script("print(x2)"); // 600
|
||||||
lua.script("print(x3)"); // 21
|
lua.script("print(x3)"); // 21
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2017-12-26 04:26:55.295046 UTC
|
// Generated 2017-12-26 13:03:03.527337 UTC
|
||||||
// This header was generated with sol v2.19.0 (revision acade46)
|
// This header was generated with sol v2.19.0 (revision 3fa176c)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2017-12-26 04:26:55.501596 UTC
|
// Generated 2017-12-26 13:03:03.719432 UTC
|
||||||
// This header was generated with sol v2.19.0 (revision acade46)
|
// This header was generated with sol v2.19.0 (revision 3fa176c)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
||||||
|
|
Loading…
Reference in New Issue
Block a user