diff --git a/CMakeLists.txt b/CMakeLists.txt index 81b64d256..b04b2a5ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 2.6) project (core C) +enable_testing() + add_subdirectory (../dependencies "${CMAKE_CURRENT_BINARY_DIR}/dependencies") add_subdirectory (src eressea) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 951245cab..4a0287d56 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,24 +1,65 @@ cmake_minimum_required(VERSION 2.6) project (eressea C) -set (CORE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "Eressea Core headers") +set (ERESSEA_LIBRARY ${PROJECT_NAME} CACHE INTERNAL "Eressea Core Library") +set (ERESSEA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "Eressea Core headers") find_package (Lua51 REQUIRED) +find_package (ToLua REQUIRED) find_package (LibXml2 REQUIRED) find_package (Curses REQUIRED) find_package (SQLite3 REQUIRED) -include_directories (${CORE_INCLUDE_DIR}) +set (ERESSEA_LIBRARIES + ${BSON_LIBRARIES} + ${CUTEST_LIBRARIES} + ${CRITBIT_LIBRARIES} + ${QUICKLIST_LIBRARIES} + ${CRYPTO_LIBRARIES} + ${INIPARSER_LIBRARIES} + ${LUA_LIBRARIES} + ${LIBXML2_LIBRARIES} + ${SQLITE3_LIBRARIES} + ${CURSES_LIBRARIES} + CACHE STRING "Eressea Libraries" +) + +include_directories (${ERESSEA_INCLUDE_DIR}) include_directories (${CRITBIT_INCLUDE_DIR}) include_directories (${CRYPTO_INCLUDE_DIR}) include_directories (${QUICKLIST_INCLUDE_DIR}) include_directories (${CUTEST_INCLUDE_DIR}) include_directories (${LUA_INCLUDE_DIR}) +include_directories (${TOLUA_INCLUDE_DIR}) include_directories (${LIBXML2_INCLUDE_DIR}) include_directories (${BSON_INCLUDE_DIR}) include_directories (${INIPARSER_INCLUDE_DIR}) -add_library(${PROJECT_NAME} +set (TEST_SRC + tests.c + tests_test.c + gamecode/economy_test.c + gamecode/laws_test.c + gamecode/market_test.c + kernel/battle_test.c + kernel/building_test.c + kernel/curse_test.c + kernel/equipment_test.c + kernel/item_test.c + kernel/magic_test.c + kernel/move_test.c + kernel/pool_test.c + kernel/reports_test.c + kernel/ship_test.c + kernel/spellbook_test.c + kernel/spell_test.c + util/base36_test.c + util/bsdstring_test.c + util/functions_test.c + util/umlaut_test.c +) + +set (LIB_SRC attributes/alliance.c attributes/attributes.c attributes/fleechance.c @@ -57,13 +98,10 @@ add_library(${PROJECT_NAME} gamecode/creation.c gamecode/creport.c gamecode/economy.c - gamecode/economy_test.c gamecode/give.c gamecode/items.c gamecode/laws.c - gamecode/laws_test.c gamecode/market.c - gamecode/market_test.c gamecode/monster.c gamecode/randenc.c gamecode/report.c @@ -83,48 +121,36 @@ add_library(${PROJECT_NAME} kernel/alchemy.c kernel/alliance.c kernel/battle.c - kernel/battle_test.c kernel/binarystore.c kernel/build.c kernel/building.c - kernel/building_test.c kernel/calendar.c kernel/command.c kernel/config.c kernel/connection.c kernel/curse.c - kernel/curse_test.c kernel/equipment.c - kernel/equipment_test.c kernel/faction.c kernel/group.c kernel/item.c - kernel/item_test.c kernel/magic.c - kernel/magic_test.c kernel/message.c kernel/move.c - kernel/move_test.c kernel/names.c kernel/order.c kernel/pathfinder.c kernel/plane.c kernel/player.c kernel/pool.c - kernel/pool_test.c kernel/race.c kernel/region.c kernel/reports.c - kernel/reports_test.c kernel/resources.c kernel/save.c kernel/ship.c - kernel/ship_test.c kernel/skill.c kernel/spellbook.c - kernel/spellbook_test.c kernel/spell.c - kernel/spell_test.c kernel/sqlite.c kernel/teleport.c kernel/terrain.c @@ -141,7 +167,6 @@ add_library(${PROJECT_NAME} modules/wormhole.c modules/xecmd.c modules/xmas.c - tests_test.c triggers/changefaction.c triggers/changerace.c triggers/clonedied.c @@ -158,9 +183,7 @@ add_library(${PROJECT_NAME} triggers/unitmessage.c util/attrib.c util/base36.c - util/base36_test.c util/bsdstring.c - util/bsdstring_test.c util/console.c util/crmessage.c util/dice.c @@ -168,7 +191,6 @@ add_library(${PROJECT_NAME} util/event.c util/filereader.c util/functions.c - util/functions_test.c util/goodies.c util/language.c util/listbox.c @@ -184,7 +206,14 @@ add_library(${PROJECT_NAME} util/strings.c util/translation.c util/umlaut.c - util/umlaut_test.c util/unicode.c util/xml.c ) + +add_library(${ERESSEA_LIBRARY} ${LIB_SRC}) +target_link_libraries(${ERESSEA_LIBRARY} ${ERESSEA_LIBRARIES}) + +add_executable(${PROJECT_NAME}_test ${TEST_SRC}) +target_link_libraries(${PROJECT_NAME}_test ${ERESSEA_LIBRARY}) + +add_test(${PROJECT_NAME} ${PROJECT_NAME}_test) diff --git a/src/tests.c b/src/tests.c index 67df8c8ba..e5cf76a91 100644 --- a/src/tests.c +++ b/src/tests.c @@ -5,27 +5,7 @@ #include #include "tests.h" -#include "tests_test.c" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include #include #include #include @@ -221,3 +201,7 @@ void test_create_world(void) locale_setstring(default_locale, "boat", "boat"); st_register(stype); } + +int main(int argc, char ** argv) { + return RunAllTests(); +} diff --git a/src/tests.h b/src/tests.h index ebf1434ae..2b6b91cce 100644 --- a/src/tests.h +++ b/src/tests.h @@ -1,8 +1,31 @@ +#ifndef ERESSEA_TESTS_H +#define ERESSEA_TESTS_H #ifdef __cplusplus extern "C" { #endif + #include + + CuSuite *get_tests_suite(void); + CuSuite *get_economy_suite(void); + CuSuite *get_laws_suite(void); + CuSuite *get_market_suite(void); + CuSuite *get_battle_suite(void); + CuSuite *get_building_suite(void); + CuSuite *get_curse_suite(void); + CuSuite *get_equipment_suite(void); + CuSuite *get_item_suite(void); + CuSuite *get_magic_suite(void); + CuSuite *get_move_suite(void); + CuSuite *get_pool_suite(void); + CuSuite *get_reports_suite(void); + CuSuite *get_ship_suite(void); + CuSuite *get_spellbook_suite(void); + CuSuite *get_spell_suite(void); + CuSuite *get_base36_suite(void); + CuSuite *get_bsdstring_suite(void); + CuSuite *get_functions_suite(void); + CuSuite *get_umlaut_suite(void); -#ifndef DISABLE_TESTS void test_cleanup(void); struct terrain_type * test_create_terrain(const char * name, unsigned int flags); @@ -16,10 +39,8 @@ extern "C" { struct ship * test_create_ship(struct region * r, const struct ship_type * stype); struct item_type * test_create_itemtype(const char ** names); int RunAllTests(void); -#else -#define RunAllTests() 0 -#endif #ifdef __cplusplus } #endif +#endif