diff --git a/CMakeLists.txt b/CMakeLists.txt index 92569e959..dcf9419ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,12 +32,3 @@ else (WIN32) endif (WIN32) add_definitions(-DUNITY_BUILD) -set (TESTS_SRCS - ../server/src/tests.c - ../external/cutest/CuTest.c -) -add_executable (tests ${LIB_SRCS} ${TESTS_SRCS}) -if (WIN32) -else (WIN32) - target_link_libraries (tests tolua xml2 ncurses lua5.1 pthread) -endif (WIN32) diff --git a/all.sln b/all.sln index 27ea4b261..12c4ad782 100644 --- a/all.sln +++ b/all.sln @@ -12,15 +12,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "external", "..\external\ext EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "amalgamation-eressea", "src\eressea.vcproj", "{AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "amalgamation-basic", "..\example\src\example.vcproj", "{4A17DAEE-2261-4E2C-96F6-BA4132A09551}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "..\server\src\tests.vcproj", "{228B8781-480F-4608-BA14-1EB82581EADE}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "amalgamation-example", "..\example\src\example.vcproj", "{4A17DAEE-2261-4E2C-96F6-BA4132A09551}" EndProject Global - GlobalSection(SubversionScc) = preSolution - Svn-Managed = True - Manager = AnkhSVN - Subversion Support for Visual Studio - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 @@ -47,12 +41,12 @@ Global {4A17DAEE-2261-4E2C-96F6-BA4132A09551}.Debug|Win32.ActiveCfg = Debug|Win32 {4A17DAEE-2261-4E2C-96F6-BA4132A09551}.Debug|Win32.Build.0 = Debug|Win32 {4A17DAEE-2261-4E2C-96F6-BA4132A09551}.Release|Win32.ActiveCfg = Release|Win32 - {228B8781-480F-4608-BA14-1EB82581EADE}.Debug|Win32.ActiveCfg = Debug|Win32 - {228B8781-480F-4608-BA14-1EB82581EADE}.Debug|Win32.Build.0 = Debug|Win32 - {228B8781-480F-4608-BA14-1EB82581EADE}.Release|Win32.ActiveCfg = Release|Win32 - {228B8781-480F-4608-BA14-1EB82581EADE}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(SubversionScc) = preSolution + Svn-Managed = True + Manager = AnkhSVN - Subversion Support for Visual Studio + EndGlobalSection EndGlobal diff --git a/src/eressea.vcproj b/src/eressea.vcproj index 22aa7a419..777ec9943 100644 --- a/src/eressea.vcproj +++ b/src/eressea.vcproj @@ -462,6 +462,26 @@ /> + + + + + + + + @@ -540,6 +560,10 @@ RelativePath="..\..\server\src\build\stdafx.h" > + + diff --git a/src/main.c b/src/main.c index 20902ea21..b1b19afff 100644 --- a/src/main.c +++ b/src/main.c @@ -12,6 +12,8 @@ #include #include +#include + static const char * luafile = "setup.lua"; static const char * entry_point = NULL; static const char * inifile = "eressea.ini"; @@ -48,14 +50,16 @@ usage(const char * prog, const char * arg) "-v : verbosity level\n" "-C : run in interactive mode\n" "--color : force curses to use colors even when not detected\n" + "--tests : run testsuite\n" "--help : help\n", prog); return -1; } static int -parse_args(int argc, char **argv) +parse_args(int argc, char **argv, int *exitcode) { int i; + int run_tests = 0; for (i=1;i!=argc;++i) { if (argv[i][0]!='-') { @@ -70,6 +74,10 @@ parse_args(int argc, char **argv) /* force the editor to have colors */ force_color = 1; } + else if (strcmp(argv[i]+2, "tests")==0) { + /* force the editor to have colors */ + run_tests = 1; + } else if (strcmp(argv[i]+2, "help")==0) { return usage(argv[0], NULL); } @@ -93,12 +101,20 @@ parse_args(int argc, char **argv) verbosity = atoi(argv[++i]); break; case 'h': - return usage(argv[0], NULL); + usage(argv[0], NULL); + return 1; default: - return usage(argv[0], argv[i]); + *exitcode = -1; + usage(argv[0], argv[i]); + return 1; } } + if (run_tests) { + *exitcode = RunAllTests(); + return 1; + } + return 0; } @@ -226,7 +242,7 @@ extern void bind_eressea(struct lua_State * L); int main(int argc, char ** argv) { static int write_csv = 0; - int err; + int err, result = 0; setup_signal_handler(); @@ -234,9 +250,9 @@ int main(int argc, char ** argv) locale_init(); parse_config(inifile); - err = parse_args(argc, argv); + err = parse_args(argc, argv, &result); if (err) { - return err; + return result; } #ifdef CRTDBG diff --git a/src/server.c b/src/server.c index 990687e29..04e8faba2 100644 --- a/src/server.c +++ b/src/server.c @@ -18,4 +18,4 @@ #include "bindings.c" #include "monsters.c" #include "main.c" - +#include "tests.c"