diff --git a/appveyor.yml b/appveyor.yml index 5e8110ac26..b8ebe79a07 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,9 +19,16 @@ install: platform: - Win32 - x64 -configuration: Release +configuration: + - Release + - ReleaseTests build: project: openrct2.proj +test_script: +- ps: >- + if ($env:configuration -eq "ReleaseTests") { + msbuild openrct2.proj /t:test /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" + } artifacts: - path: .\artifacts\openrct2-portable*.zip name: OpenRCT2-portable diff --git a/openrct2.common.props b/openrct2.common.props index 10103679d6..64d144e987 100644 --- a/openrct2.common.props +++ b/openrct2.common.props @@ -1,8 +1,108 @@ + + ..\..\ + Debug + Release + + + + $(DefaultPlatformToolset) $(UCRTVersion) + + MultiByte + + $(SolutionDir)bin\ + $(SolutionDir)obj\$(ProjectName)\$(Config)_$(Platform)\ + $(ProjectName) + + true + + + false + true + + + + + 4091;%(DisableSpecificWarnings) + Level3 + OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreaded + true + 4013 + true + /utf-8 + + + imm32.lib;version.lib;winmm.lib;crypt32.lib;%(AdditionalDependencies) + openrct2-libs-vs2015-x86.lib;%(AdditionalDependencies) + openrct2-libs-vs2015-x64.lib;%(AdditionalDependencies) + /OPT:NOLBR /ignore:4099 %(AdditionalOptions) + + + + + Disabled + true + DEBUG;%(PreprocessorDefinitions) + false + + + true + UseFastLinkTimeCodeGeneration + + + + + Full + true + true + + + false + %(PreprocessorDefinitions) + Speed + + + true + true + true + + + + + __TEST__;%(PreprocessorDefinitions) + + + + + NDEBUG;__TEST__;%(PreprocessorDefinitions) + + + + + + + NO_RCT2;%(PreprocessorDefinitions) + + + + + + + $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) + $(SolutionDir)lib;$(LibraryPath) + + + + + + PerMonitorHighDPIAware + + diff --git a/openrct2.proj b/openrct2.proj index 8917009a18..ee68eea4b4 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -55,7 +55,6 @@ OpenRCT2-$(Version)$(VersionExtra)-windows-$(Platform.ToLower()) - Configuration=$(Configuration) $(SlnProperties);Platform=$(Platform) $(SlnProperties);OPENRCT2_CL_ADDITIONALOPTIONS=$(OPENRCT2_CL_ADDITIONALOPTIONS) @@ -65,6 +64,8 @@ https://github.com/OpenRCT2/Dependencies/releases/download/v$(TargetLibsVersion)/openrct2-libs-vs2015.zip $(RootDir)lib\ $(LibsPath)libversion + 1.8.0 + https://github.com/google/googletest/archive/release-$(GtestVersion).zip @@ -122,6 +123,7 @@ $(LibsPath)openrct2-libs-vs2015.zip + $(LibsPath)gtest.zip @@ -129,15 +131,26 @@ + + + + + + + + + + $(SlnProperties);Configuration=$(Configuration) + @@ -169,15 +182,33 @@ + + $(SlnProperties);Configuration=$(Configuration) + + + $(SlnProperties);Configuration=$(Configuration) + + + + DebugTests + ReleaseTests + $(SlnProperties);Configuration=$(Configuration) + + + + - + + + + diff --git a/openrct2.sln b/openrct2.sln index a9f6803221..df162fe6a2 100644 --- a/openrct2.sln +++ b/openrct2.sln @@ -7,6 +7,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2", "openrct2.vcxpro EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpaint", "test\testpaint\testpaint.vcxproj", "{57E60BA1-FB76-4316-909E-C1449C142327}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "test\tests\tests.vcxproj", "{62B020FA-E4FB-4C6E-B32A-DC999470F155}" + ProjectSection(ProjectDependencies) = postProject + {D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F} + EndProjectSection +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2202A816-377D-4FA0-A7AF-7D4105F8A4FB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{480B577D-4E4A-4757-9A42-28A9AD33E6B0}" @@ -15,24 +20,51 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 + DebugTests|Win32 = DebugTests|Win32 + DebugTests|x64 = DebugTests|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 + ReleaseTests|Win32 = ReleaseTests|Win32 + ReleaseTests|x64 = ReleaseTests|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|x64.ActiveCfg = Debug|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|x64.Build.0 = Debug|x64 + {D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|Win32.ActiveCfg = DebugTests|Win32 + {D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|Win32.Build.0 = DebugTests|Win32 + {D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|x64.ActiveCfg = DebugTests|x64 + {D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|x64.Build.0 = DebugTests|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.ActiveCfg = Release|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.Build.0 = Release|x64 + {D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|Win32.ActiveCfg = ReleaseTests|Win32 + {D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|Win32.Build.0 = ReleaseTests|Win32 + {D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|x64.ActiveCfg = ReleaseTests|x64 + {D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|x64.Build.0 = ReleaseTests|x64 {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.ActiveCfg = Debug|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.Build.0 = Debug|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|x64.ActiveCfg = Debug|Win32 + {57E60BA1-FB76-4316-909E-C1449C142327}.DebugTests|Win32.ActiveCfg = Debug|Win32 + {57E60BA1-FB76-4316-909E-C1449C142327}.DebugTests|x64.ActiveCfg = Debug|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Release|Win32.ActiveCfg = Release|Win32 - {57E60BA1-FB76-4316-909E-C1449C142327}.Release|Win32.Build.0 = Release|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Release|x64.ActiveCfg = Release|Win32 + {57E60BA1-FB76-4316-909E-C1449C142327}.ReleaseTests|Win32.ActiveCfg = Release|Win32 + {57E60BA1-FB76-4316-909E-C1449C142327}.ReleaseTests|x64.ActiveCfg = Release|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|Win32.ActiveCfg = DebugTests|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|x64.ActiveCfg = DebugTests|x64 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|Win32.ActiveCfg = DebugTests|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|Win32.Build.0 = DebugTests|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|x64.ActiveCfg = DebugTests|x64 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|x64.Build.0 = DebugTests|x64 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|Win32.ActiveCfg = ReleaseTests|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|x64.ActiveCfg = ReleaseTests|x64 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|Win32.ActiveCfg = ReleaseTests|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|Win32.Build.0 = ReleaseTests|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|x64.ActiveCfg = ReleaseTests|x64 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|x64.Build.0 = ReleaseTests|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -40,5 +72,6 @@ Global GlobalSection(NestedProjects) = preSolution {D24D94F6-2A74-480C-B512-629C306CE92F} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB} {57E60BA1-FB76-4316-909E-C1449C142327} = {480B577D-4E4A-4757-9A42-28A9AD33E6B0} + {62B020FA-E4FB-4C6E-B32A-DC999470F155} = {480B577D-4E4A-4757-9A42-28A9AD33E6B0} EndGlobalSection EndGlobal diff --git a/openrct2.vcxproj b/openrct2.vcxproj index 2e3bfde9eb..098d5abc10 100644 --- a/openrct2.vcxproj +++ b/openrct2.vcxproj @@ -1,5 +1,8 @@  + + .\ + Debug @@ -9,6 +12,14 @@ Debug x64 + + DebugTests + Win32 + + + DebugTests + x64 + Release Win32 @@ -17,7 +28,48 @@ Release x64 + + ReleaseTests + Win32 + + + ReleaseTests + x64 + + + {D24D94F6-2A74-480C-B512-629C306CE92F} + openrct2 + openrct2 + + + Application + + + + DynamicLibrary + + + StaticLibrary + + + + + USE_BREAKPAD;%(PreprocessorDefinitions) + __NOENTRYPOINT__;%(PreprocessorDefinitions) + + + + + $(IntDir)\%(RelativeDir) + $(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions) + + + Console + + + + @@ -535,186 +587,6 @@ - - {D24D94F6-2A74-480C-B512-629C306CE92F} - openrct2 - openrct2 - - - - - DynamicLibrary - true - MultiByte - - - Application - false - true - MultiByte - - - Application - true - MultiByte - - - false - true - MultiByte - - - - - - - - - - - - $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) - $(SolutionDir)lib;$(LibraryPath) - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\ - - - - $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) - $(SolutionDir)lib;$(LibraryPath) - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\ - - - $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) - $(SolutionDir)lib;$(LibraryPath) - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\ - - $(ProjectName) - - - $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) - $(SolutionDir)lib;$(LibraryPath) - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\ - $(ProjectName) - - - - USE_BREAKPAD;%(PreprocessorDefinitions) - - - - - 4091;%(DisableSpecificWarnings) - Level3 - Disabled - true - DEBUG;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - true - $(IntDir)\%(RelativeDir) - 4013 - false - true - $(OPENRCT2_CL_ADDITIONALOPTIONS) - - - true - openrct2-libs-vs2015-x86.lib;imm32.lib;version.lib;winmm.lib;crypt32.lib;%(AdditionalDependencies) - UseFastLinkTimeCodeGeneration - /OPT:NOLBR /ignore:4099 %(AdditionalOptions) - - - - - 4091;%(DisableSpecificWarnings) - Level3 - Full - true - true - - MultiThreaded - 4013 - - false - NO_RCT2;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;%(PreprocessorDefinitions) - $(IntDir)\%(RelativeDir) - true - Speed - true - $(OPENRCT2_CL_ADDITIONALOPTIONS) - - - true - true - true - openrct2-libs-vs2015-x86.lib;imm32.lib;version.lib;winmm.lib;crypt32.lib;%(AdditionalDependencies) - /ignore:4099 %(AdditionalOptions) - Windows - - - PerMonitorHighDPIAware - - - - - 4091;%(DisableSpecificWarnings) - Level3 - Disabled - true - DEBUG;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - true - $(IntDir)\%(RelativeDir) - 4013 - false - true - $(OPENRCT2_CL_ADDITIONALOPTIONS) - - - true - openrct2-libs-vs2015-x64.lib;imm32.lib;version.lib;winmm.lib;crypt32.lib;%(AdditionalDependencies) - UseFastLinkTimeCodeGeneration - /OPT:NOLBR /ignore:4099 %(AdditionalOptions) - Console - - - PerMonitorHighDPIAware - - - - - 4091;%(DisableSpecificWarnings) - Level3 - Full - true - true - - MultiThreaded - 4013 - - false - OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;%(PreprocessorDefinitions) - $(IntDir)\%(RelativeDir) - true - Speed - true - $(OPENRCT2_CL_ADDITIONALOPTIONS) - - - true - true - true - openrct2-libs-vs2015-x64.lib;imm32.lib;version.lib;winmm.lib;crypt32.lib;%(AdditionalDependencies) - /ignore:4099 %(AdditionalOptions) - Windows - - - PerMonitorHighDPIAware - - + - \ No newline at end of file diff --git a/src/core/Guard.cpp b/src/core/Guard.cpp index 2b6518aa39..031e8841d5 100644 --- a/src/core/Guard.cpp +++ b/src/core/Guard.cpp @@ -78,7 +78,12 @@ namespace Guard char *bufend = (char *)strchr(buffer, 0); vsnprintf(bufend, sizeof(buffer) - (bufend - buffer), message, args); } - int result = MessageBox(nullptr, buffer, OPENRCT2_NAME, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION); +#ifdef __TEST__ + // Abort if we are building for testing + abort(); +#else + // Show message box if we are not building for testing + int result = MessageBoxA(nullptr, buffer, OPENRCT2_NAME, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION); if (result == IDABORT) { #ifdef USE_BREAKPAD @@ -88,6 +93,7 @@ namespace Guard assert(false); #endif } +#endif #else assert(false); #endif diff --git a/src/platform/windows.c b/src/platform/windows.c index bdeb7abd57..8fda6936cd 100644 --- a/src/platform/windows.c +++ b/src/platform/windows.c @@ -52,7 +52,7 @@ utf8 **windows_get_command_line_args(int *outNumArgs); static HMODULE _dllModule = NULL; -#ifdef NO_RCT2 +#if defined(NO_RCT2) && !defined(__NOENTRYPOINT__) /** * Windows entry point to OpenRCT2 without a console window. diff --git a/test/tests/sawyercoding_test.cpp b/test/tests/sawyercoding_test.cpp index 107e2dca4c..52a8e7779a 100644 --- a/test/tests/sawyercoding_test.cpp +++ b/test/tests/sawyercoding_test.cpp @@ -1,3 +1,6 @@ +// Make MSVC shut up about M_PI +#include + extern "C" { #include "util/sawyercoding.h" } diff --git a/test/tests/tests.cpp b/test/tests/tests.cpp new file mode 100644 index 0000000000..4190c4fa39 --- /dev/null +++ b/test/tests/tests.cpp @@ -0,0 +1,13 @@ +// This serves as the entry point when building for MSVC which compiles gtest +// directly into the test binary. +#ifdef _MSC_VER + +#include + +int main(int argc, char * * argv) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + +#endif diff --git a/test/tests/tests.vcxproj b/test/tests/tests.vcxproj new file mode 100644 index 0000000000..3e42ab8e4a --- /dev/null +++ b/test/tests/tests.vcxproj @@ -0,0 +1,57 @@ + + + + ..\..\ + $(SolutionDir)lib\googletest\googletest + + + + DebugTests + Win32 + + + ReleaseTests + Win32 + + + DebugTests + x64 + + + ReleaseTests + x64 + + + + {62B020FA-E4FB-4C6E-B32A-DC999470F155} + tests + tests + + + Application + + + + $(SolutionDir)bin\tests\ + $(GtestDir);$(GtestDir)\include;$(SolutionDir)src;$(IncludePath) + $(SolutionDir)bin;$(LibraryPath) + + + + openrct2.lib;%(AdditionalDependencies) + Console + + + + + + + + + + + + + + + \ No newline at end of file