Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/build_cmake_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ jobs:
--build build-windows-${{ matrix.BUILD_CONFIGURATION }}-${{ matrix.BUILD_PLATFORM }} \
--config ${{ matrix.BUILD_CONFIGURATION }}

- name: Run tests
shell: bash
working-directory: build-windows-${{ matrix.BUILD_CONFIGURATION }}-${{ matrix.BUILD_PLATFORM }}
run: |
ctest -C "${{ matrix.BUILD_CONFIGURATION }}"

build_linux:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -140,3 +146,9 @@ jobs:
cmake \
--build build-${{ matrix.COMPILER }}-${{ matrix.BUILD_CONFIGURATION }} \
--config ${{ matrix.BUILD_CONFIGURATION }}

- name: Run tests
shell: bash
working-directory: build-${{ matrix.COMPILER }}-${{ matrix.BUILD_CONFIGURATION }}
run: |
ctest -C "${{ matrix.BUILD_CONFIGURATION }}"
15 changes: 10 additions & 5 deletions .github/workflows/build_msbuild_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,26 @@ jobs:

# NOTE: We could simply run All.sln, but it makes it far more obvious in the Github output when it's broken up across its solutions.
- name: Build third party dependencies
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{matrix.BUILD_CONFIGURATION}}" /p:Platform="${{matrix.BUILD_PLATFORM}}" /p:NO_CLIENT_ASSETS="1" ThirdParty.sln

- name: Build client
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{matrix.BUILD_CONFIGURATION}}" /p:Platform="${{matrix.BUILD_PLATFORM}}" /p:NO_CLIENT_ASSETS="1" Client.sln

- name: Build server
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{matrix.BUILD_CONFIGURATION}}" /p:Platform="${{matrix.BUILD_PLATFORM}}" /p:NO_CLIENT_ASSETS="1" Server.sln

- name: Build tools
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{matrix.BUILD_CONFIGURATION}}" /p:Platform="${{matrix.BUILD_PLATFORM}}" /p:NO_CLIENT_ASSETS="1" Tools.sln

- name: Build client tools
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{matrix.BUILD_CONFIGURATION}}" /p:Platform="${{matrix.BUILD_PLATFORM}}" /p:NO_CLIENT_ASSETS="1" ClientTools.sln

- name: Build tests
run: msbuild /p:Configuration="${{matrix.BUILD_CONFIGURATION}}" /p:Platform="${{matrix.BUILD_PLATFORM}}" /p:NO_CLIENT_ASSETS="1" Tests.sln

- name: Run tests
shell: pwsh
working-directory: "bin/${{matrix.BUILD_PLATFORM}}/${{matrix.BUILD_CONFIGURATION}}"
run: |
.\client-tests.exe
.\server-tests.exe
1 change: 0 additions & 1 deletion .github/workflows/build_msbuild_client_tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ jobs:
uses: microsoft/setup-msbuild@v2

- name: Build tools
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{matrix.BUILD_CONFIGURATION}}" /p:Platform="${{matrix.BUILD_PLATFORM}}" ClientTools.sln
1 change: 0 additions & 1 deletion .github/workflows/build_msbuild_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ jobs:
uses: microsoft/setup-msbuild@v2

- name: Build server
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{matrix.BUILD_CONFIGURATION}}" /p:Platform="${{matrix.BUILD_PLATFORM}}" Server.sln
1 change: 0 additions & 1 deletion .github/workflows/build_msbuild_tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ jobs:
uses: microsoft/setup-msbuild@v2

- name: Build tools
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{matrix.BUILD_CONFIGURATION}}" /p:Platform="${{matrix.BUILD_PLATFORM}}" Tools.sln
2 changes: 0 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
# as needed from within All.sln; this ensures they're built first so they won't build again during
# CodeQL monitoring.
- name: Build third party dependencies
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{env.BUILD_CONFIGURATION}}" /p:Platform="${{env.BUILD_PLATFORM}}" ThirdParty.sln

# Initializes the CodeQL tools for scanning.
Expand All @@ -53,7 +52,6 @@ jobs:
build-mode: manual

- name: Build all
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /p:Configuration="${{env.BUILD_CONFIGURATION}}" /p:Platform="${{env.BUILD_PLATFORM}}" /p:NO_CLIENT_ASSETS="1" All.sln

- name: Perform CodeQL Analysis
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@
path = deps/argparse
url = https://github.com/p-ranav/argparse
shallow = true
[submodule "deps/googletest"]
path = deps/googletest
url = https://github.com/google/googletest
shallow = true
44 changes: 44 additions & 0 deletions All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,23 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_deps", "_deps", "{E91CF97D
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fetch-argparse", "deps\fetch-and-build-wrappers\fetch-argparse.vcxproj", "{61A124FB-035E-4560-8499-198C6299B7DA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fetch-googletest", "deps\fetch-and-build-wrappers\fetch-googletest.vcxproj", "{D4F3D338-A7EF-430C-AD99-2FC6A591A711}"
ProjectSection(ProjectDependencies) = postProject
{1F14357D-E06A-48A1-B39A-74082F381FC0} = {1F14357D-E06A-48A1-B39A-74082F381FC0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client-tests", "Client\tests\client-tests.vcxproj", "{F1626769-3D40-4524-912E-4B0780393B37}"
ProjectSection(ProjectDependencies) = postProject
{D4F3D338-A7EF-430C-AD99-2FC6A591A711} = {D4F3D338-A7EF-430C-AD99-2FC6A591A711}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4E7D8CAB-AF8E-4790-96EF-F3715830E3CF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server-tests", "Server\tests\server-tests.vcxproj", "{642EEED1-6C69-4888-9EC6-BEC40A46080B}"
ProjectSection(ProjectDependencies) = postProject
{D4F3D338-A7EF-430C-AD99-2FC6A591A711} = {D4F3D338-A7EF-430C-AD99-2FC6A591A711}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down Expand Up @@ -565,6 +582,30 @@ Global
{61A124FB-035E-4560-8499-198C6299B7DA}.Release|Win32.Build.0 = Release|Win32
{61A124FB-035E-4560-8499-198C6299B7DA}.Release|x64.ActiveCfg = Release|x64
{61A124FB-035E-4560-8499-198C6299B7DA}.Release|x64.Build.0 = Release|x64
{D4F3D338-A7EF-430C-AD99-2FC6A591A711}.Debug|Win32.ActiveCfg = Debug|Win32
{D4F3D338-A7EF-430C-AD99-2FC6A591A711}.Debug|Win32.Build.0 = Debug|Win32
{D4F3D338-A7EF-430C-AD99-2FC6A591A711}.Debug|x64.ActiveCfg = Debug|x64
{D4F3D338-A7EF-430C-AD99-2FC6A591A711}.Debug|x64.Build.0 = Debug|x64
{D4F3D338-A7EF-430C-AD99-2FC6A591A711}.Release|Win32.ActiveCfg = Release|Win32
{D4F3D338-A7EF-430C-AD99-2FC6A591A711}.Release|Win32.Build.0 = Release|Win32
{D4F3D338-A7EF-430C-AD99-2FC6A591A711}.Release|x64.ActiveCfg = Release|x64
{D4F3D338-A7EF-430C-AD99-2FC6A591A711}.Release|x64.Build.0 = Release|x64
{F1626769-3D40-4524-912E-4B0780393B37}.Debug|Win32.ActiveCfg = Debug|Win32
{F1626769-3D40-4524-912E-4B0780393B37}.Debug|Win32.Build.0 = Debug|Win32
{F1626769-3D40-4524-912E-4B0780393B37}.Debug|x64.ActiveCfg = Debug|x64
{F1626769-3D40-4524-912E-4B0780393B37}.Debug|x64.Build.0 = Debug|x64
{F1626769-3D40-4524-912E-4B0780393B37}.Release|Win32.ActiveCfg = Release|Win32
{F1626769-3D40-4524-912E-4B0780393B37}.Release|Win32.Build.0 = Release|Win32
{F1626769-3D40-4524-912E-4B0780393B37}.Release|x64.ActiveCfg = Release|x64
{F1626769-3D40-4524-912E-4B0780393B37}.Release|x64.Build.0 = Release|x64
{642EEED1-6C69-4888-9EC6-BEC40A46080B}.Debug|Win32.ActiveCfg = Debug|Win32
{642EEED1-6C69-4888-9EC6-BEC40A46080B}.Debug|Win32.Build.0 = Debug|Win32
{642EEED1-6C69-4888-9EC6-BEC40A46080B}.Debug|x64.ActiveCfg = Debug|x64
{642EEED1-6C69-4888-9EC6-BEC40A46080B}.Debug|x64.Build.0 = Debug|x64
{642EEED1-6C69-4888-9EC6-BEC40A46080B}.Release|Win32.ActiveCfg = Release|Win32
{642EEED1-6C69-4888-9EC6-BEC40A46080B}.Release|Win32.Build.0 = Release|Win32
{642EEED1-6C69-4888-9EC6-BEC40A46080B}.Release|x64.ActiveCfg = Release|x64
{642EEED1-6C69-4888-9EC6-BEC40A46080B}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -614,6 +655,9 @@ Global
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {74CB367B-7B41-43B6-9DEE-D4070362E0F8}
{E91CF97D-F613-4B2E-9DEE-0A90C6A6EB5A} = {C8016DCD-4286-4BD2-9C78-F1E6D9D0555B}
{61A124FB-035E-4560-8499-198C6299B7DA} = {6EEB718D-CCE4-446E-A0BE-172669B7BC98}
{D4F3D338-A7EF-430C-AD99-2FC6A591A711} = {6EEB718D-CCE4-446E-A0BE-172669B7BC98}
{F1626769-3D40-4524-912E-4B0780393B37} = {4E7D8CAB-AF8E-4790-96EF-F3715830E3CF}
{642EEED1-6C69-4888-9EC6-BEC40A46080B} = {4E7D8CAB-AF8E-4790-96EF-F3715830E3CF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D9937074-3E07-4102-9EF1-BE6E87CF35E4}
Expand Down
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(CXX_SCAN_FOR_MODULES OFF)
# Config
option(OPENKO_BUILD_SERVERS "Build the server projects (default on)" ON)
option(OPENKO_COMPILE_WARNINGS_AS_ERROR "Enable treating warnings as errors (default on)" ON)
option(OPENKO_BUILD_TESTS "Build the test projects (default on)" ON)

# Define the bin directory; defaults to repo/bin
set(OPENKO_BIN_DIR "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Directory for final binaries")
Expand All @@ -31,6 +32,7 @@ endif()
message(STATUS "OpenKO feature: OPENKO_BUILD_SERVERS - ${OPENKO_BUILD_SERVERS}")
message(STATUS "OpenKO feature: OPENKO_COMPILE_WARNINGS_AS_ERROR - ${OPENKO_COMPILE_WARNINGS_AS_ERROR}")
message(STATUS "OpenKO feature: OPENKO_BIN_DIR - ${OPENKO_BIN_DIR}")
message(STATUS "OpenKO feature: OPENKO_BUILD_TESTS - ${OPENKO_BUILD_TESTS}")

if(WIN32)
message(STATUS "OpenKO feature: _WIN32_WINNT - ${_WIN32_WINNT}")
Expand Down Expand Up @@ -114,3 +116,18 @@ if(OPENKO_BUILD_SERVERS)
add_subdirectory(Server/ItemManager)
add_subdirectory(Server/VersionManager)
endif()

if(OPENKO_BUILD_TESTS)
include(CTest)

set(CMAKE_FOLDER "Tests/_deps")
add_subdirectory(deps/googletest-cmake)

set(CMAKE_FOLDER "Tests")
add_subdirectory(Server/tests)

# TODO: Client builds via CMake (even just for MSVC for now)
#if(MSVC)
# add_subdirectory(Client/tests)
#endif()
endif()
11 changes: 11 additions & 0 deletions Client/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NOTE: Unused - no CMake client builds currently.
add_executable(client-tests
hello_test.cpp)

target_link_libraries(client-tests PRIVATE
gtest
gtest_main)

add_test(
NAME ClientTests
COMMAND client-tests)
77 changes: 77 additions & 0 deletions Client/tests/client-tests.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="hello_test.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{f1626769-3d40-4524-912e-4b0780393b37}</ProjectGuid>
<RootNamespace>clienttests</RootNamespace>
</PropertyGroup>
<Import Project="..\..\props\platform_root.props" />
<PropertyGroup Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<Import Project="$(PropsDir)googletest.props" />
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp23</LanguageStandard>
<MinimalRebuild>false</MinimalRebuild>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<Link>
<AdditionalDependencies>gtest_main.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
6 changes: 6 additions & 0 deletions Client/tests/client-tests.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="hello_test.cpp" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions Client/tests/hello_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <gtest/gtest.h>

// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
}
11 changes: 11 additions & 0 deletions Server/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
add_executable(server-tests
hello_test.cpp)

target_link_libraries(server-tests PRIVATE
gtest
gtest_main
shared-server)

add_test(
NAME server-tests
COMMAND server-tests)
9 changes: 9 additions & 0 deletions Server/tests/hello_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <gtest/gtest.h>

// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
}
Loading