mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 10:22:52 +01:00
tests: execute each test separately by CTest
Disabled by default because empty test suites fail and would cause Travis to fail. There can be empty test suites when testing with no data.
This commit is contained in:
parent
a9f8f27b21
commit
9e8a96ab7e
@ -22,7 +22,7 @@ set(CTEST_BUILD_NAME "experimental_script-${SHORT_COMMIT}")
|
|||||||
ctest_start("Experimental")
|
ctest_start("Experimental")
|
||||||
ctest_configure(
|
ctest_configure(
|
||||||
OPTIONS
|
OPTIONS
|
||||||
"-DBUILD_VIEWER=1;-DBUILD_TESTS=1;-DTEST_COVERAGE=1;-DRW_VERBOSE_DEBUG_MESSAGES=0"
|
"-DBUILD_VIEWER=1;-DBUILD_TESTS=1;-DTEST_COVERAGE=1;-DRW_VERBOSE_DEBUG_MESSAGES=1;-DSEPERATE_TEST_SUITES=1"
|
||||||
)
|
)
|
||||||
ctest_build()
|
ctest_build()
|
||||||
ctest_test()
|
ctest_test()
|
||||||
|
@ -19,3 +19,4 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(TEST_COVERAGE "Enable coverage analysis (implies CMAKE_BUILD_TYPE=Debug)")
|
option(TEST_COVERAGE "Enable coverage analysis (implies CMAKE_BUILD_TYPE=Debug)")
|
||||||
|
option(SEPERATE_TEST_SUITES "Add each test suite as seperate test")
|
||||||
|
@ -4,43 +4,46 @@
|
|||||||
|
|
||||||
find_package(Boost COMPONENTS filesystem unit_test_framework system REQUIRED)
|
find_package(Boost COMPONENTS filesystem unit_test_framework system REQUIRED)
|
||||||
|
|
||||||
|
set(TESTS
|
||||||
|
Animation
|
||||||
|
Archive
|
||||||
|
Buoyancy
|
||||||
|
Character
|
||||||
|
Chase
|
||||||
|
Config
|
||||||
|
Cutscene
|
||||||
|
Data
|
||||||
|
FileIndex
|
||||||
|
GameData
|
||||||
|
GameWorld
|
||||||
|
Input
|
||||||
|
Items
|
||||||
|
Lifetime
|
||||||
|
LoaderDFF
|
||||||
|
LoaderIPL
|
||||||
|
Logger
|
||||||
|
Menu
|
||||||
|
Object
|
||||||
|
ObjectData
|
||||||
|
Pickup
|
||||||
|
Renderer
|
||||||
|
RWBStream
|
||||||
|
SaveGame
|
||||||
|
ScriptMachine
|
||||||
|
State
|
||||||
|
Text
|
||||||
|
TrafficDirector
|
||||||
|
Vehicle
|
||||||
|
VisualFX
|
||||||
|
Weapon
|
||||||
|
World
|
||||||
|
ZoneData
|
||||||
|
)
|
||||||
|
|
||||||
set(TEST_SOURCES
|
set(TEST_SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
test_Globals.cpp
|
test_Globals.cpp
|
||||||
test_Animation.cpp
|
|
||||||
test_Archive.cpp
|
|
||||||
test_Buoyancy.cpp
|
|
||||||
test_Character.cpp
|
|
||||||
test_Chase.cpp
|
|
||||||
test_Cutscene.cpp
|
|
||||||
test_Config.cpp
|
|
||||||
test_Data.cpp
|
|
||||||
test_FileIndex.cpp
|
|
||||||
test_GameData.cpp
|
|
||||||
test_GameWorld.cpp
|
|
||||||
test_Globals.hpp
|
test_Globals.hpp
|
||||||
test_Items.cpp
|
|
||||||
test_Input.cpp
|
|
||||||
test_Lifetime.cpp
|
|
||||||
test_Loaderdff.cpp
|
|
||||||
test_LoaderIPL.cpp
|
|
||||||
test_Logger.cpp
|
|
||||||
test_Menu.cpp
|
|
||||||
test_Object.cpp
|
|
||||||
test_ObjectData.cpp
|
|
||||||
test_Pickup.cpp
|
|
||||||
test_Renderer.cpp
|
|
||||||
test_RWBStream.cpp
|
|
||||||
test_SaveGame.cpp
|
|
||||||
test_ScriptMachine.cpp
|
|
||||||
test_State.cpp
|
|
||||||
test_Text.cpp
|
|
||||||
test_TrafficDirector.cpp
|
|
||||||
test_Vehicle.cpp
|
|
||||||
test_VisualFX.cpp
|
|
||||||
test_Weapon.cpp
|
|
||||||
test_World.cpp
|
|
||||||
test_ZoneData.cpp
|
|
||||||
|
|
||||||
# Hack in rwgame sources until there's a per-target test suite
|
# Hack in rwgame sources until there's a per-target test suite
|
||||||
"${CMAKE_SOURCE_DIR}/rwgame/GameConfig.cpp"
|
"${CMAKE_SOURCE_DIR}/rwgame/GameConfig.cpp"
|
||||||
@ -48,7 +51,13 @@ set(TEST_SOURCES
|
|||||||
"${CMAKE_SOURCE_DIR}/rwgame/GameInput.cpp"
|
"${CMAKE_SOURCE_DIR}/rwgame/GameInput.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(run_tests ${TEST_SOURCES})
|
foreach(TEST ${TESTS})
|
||||||
|
list(APPEND TEST_SOURCES "test_${TEST}.cpp")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_executable(run_tests
|
||||||
|
${TEST_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
target_compile_definitions(run_tests
|
target_compile_definitions(run_tests
|
||||||
PRIVATE
|
PRIVATE
|
||||||
@ -77,6 +86,23 @@ target_link_libraries(run_tests
|
|||||||
${Boost_SYSTEM_LIBRARY}
|
${Boost_SYSTEM_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_test(NAME UnitTests
|
if(SEPERATE_TEST_SUITES)
|
||||||
COMMAND "$<TARGET_FILE:run_tests>"
|
foreach(TEST ${TESTS})
|
||||||
)
|
add_test(
|
||||||
|
NAME "${TEST}"
|
||||||
|
COMMAND "$<TARGET_FILE:run_tests>" "-t" "${TEST}Tests"
|
||||||
|
)
|
||||||
|
set_tests_properties("${TEST}"
|
||||||
|
PROPERTIES
|
||||||
|
TIMEOUT 15
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
add_test(NAME UnitTests
|
||||||
|
COMMAND "$<TARGET_FILE:run_tests>"
|
||||||
|
)
|
||||||
|
set_tests_properties(UnitTests
|
||||||
|
PROPERTIES
|
||||||
|
TIMEOUT 60
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <MenuSystem.hpp>
|
#include <MenuSystem.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(MenuUnitTests)
|
BOOST_AUTO_TEST_SUITE(MenuTests)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(menu_test_click) {
|
BOOST_AUTO_TEST_CASE(menu_test_click) {
|
||||||
bool clickered = false;
|
bool clickered = false;
|
||||||
|
@ -3,30 +3,30 @@
|
|||||||
#include <objects/InstanceObject.hpp>
|
#include <objects/InstanceObject.hpp>
|
||||||
#include "test_Globals.hpp"
|
#include "test_Globals.hpp"
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(ObjectUnitTests)
|
BOOST_AUTO_TEST_SUITE(ObjectTests)
|
||||||
|
|
||||||
#if 0 // Tests disabled as object damage logic is unclear
|
#if 0 // Tests disabled as object damage logic is unclear
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(instance_test_damage)
|
BOOST_AUTO_TEST_CASE(instance_test_damage)
|
||||||
{
|
{
|
||||||
std::shared_ptr<ObjectData> object(new ObjectData);
|
std::shared_ptr<ObjectData> object(new ObjectData);
|
||||||
InstanceObject inst(Global::get().e,
|
InstanceObject inst(Global::get().e,
|
||||||
glm::vec3(0.f, 0.f, 0.f),
|
glm::vec3(0.f, 0.f, 0.f),
|
||||||
glm::quat(), nullptr,
|
glm::quat(), nullptr,
|
||||||
glm::vec3(1.f),
|
glm::vec3(1.f),
|
||||||
object, nullptr, nullptr
|
object, nullptr, nullptr
|
||||||
);
|
);
|
||||||
GameObject::DamageInfo dmg;
|
GameObject::DamageInfo dmg;
|
||||||
dmg.type = GameObject::DamageInfo::Bullet;
|
dmg.type = GameObject::DamageInfo::Bullet;
|
||||||
dmg.hitpoints = 50.f;
|
dmg.hitpoints = 50.f;
|
||||||
|
|
||||||
// Set object to undamagable.
|
// Set object to undamagable.
|
||||||
object->flags = 0;
|
object->flags = 0;
|
||||||
|
|
||||||
BOOST_CHECK( ! inst.takeDamage(dmg) );
|
BOOST_CHECK( ! inst.takeDamage(dmg) );
|
||||||
|
|
||||||
BOOST_CHECK( inst.takeDamage(dmg) );
|
BOOST_CHECK( inst.takeDamage(dmg) );
|
||||||
|
|
||||||
BOOST_CHECK( inst.getHealth() < 0.f );
|
BOOST_CHECK( inst.getHealth() < 0.f );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,17 +34,17 @@ BOOST_AUTO_TEST_CASE(instance_test_destroy)
|
|||||||
{
|
{
|
||||||
std::shared_ptr<ObjectData> object(new ObjectData);
|
std::shared_ptr<ObjectData> object(new ObjectData);
|
||||||
InstanceObject inst(Global::get().e,
|
InstanceObject inst(Global::get().e,
|
||||||
glm::vec3(0.f, 0.f, 0.f),
|
glm::vec3(0.f, 0.f, 0.f),
|
||||||
glm::quat(), nullptr,
|
glm::quat(), nullptr,
|
||||||
glm::vec3(1.f),
|
glm::vec3(1.f),
|
||||||
object, nullptr, nullptr
|
object, nullptr, nullptr
|
||||||
);
|
);
|
||||||
GameObject::DamageInfo dmg;
|
GameObject::DamageInfo dmg;
|
||||||
dmg.type = GameObject::DamageInfo::Bullet;
|
dmg.type = GameObject::DamageInfo::Bullet;
|
||||||
dmg.hitpoints = inst.getHealth() + 1.f;
|
dmg.hitpoints = inst.getHealth() + 1.f;
|
||||||
|
|
||||||
BOOST_CHECK( inst.takeDamage(dmg) );
|
BOOST_CHECK( inst.takeDamage(dmg) );
|
||||||
|
|
||||||
BOOST_CHECK( inst.getHealth() < 0.f );
|
BOOST_CHECK( inst.getHealth() < 0.f );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user