Skip to content

Commit

Permalink
Add good old tests to CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jun 2, 2024
1 parent 10bf073 commit 5597411
Show file tree
Hide file tree
Showing 34 changed files with 1,436 additions and 43 deletions.
51 changes: 23 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ env:
BOOST_PREBUILT_URL: "https://github.com/ModOrganizer2/mob/releases/download/2.5-dependencies/boost_prebuilt_1_85_0.7z"

jobs:
build-x64:
name: Build USVFS x64
build:
name: Build USVFS
strategy:
matrix:
arch: [x86, x64]
config: [Release]
tests: ["", "Test"]
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
Expand All @@ -23,37 +28,27 @@ jobs:
Expand-7ZipArchive -Path boost.7z -Destination .\boost
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build x64
run: |
msbuild -nologo `
-maxCpuCount "-property:UseMultiToolTask=true" "-property:EnforceProcessCountAcrossBuilds=true" `
"-property:Configuration=Release" `
"-property:Platform=x64" `
"-property:BOOST_PATH=..\boost" `
"-property:RunCodeAnalysis=false" `
.\vsbuild\usvfs.sln
build-x86:
name: Build USVFS x86
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Fetch Boost prebuilt
run: |
Invoke-WebRequest -Uri ${env:BOOST_PREBUILT_URL} -OutFile boost.7z
Expand-7ZipArchive -Path boost.7z -Destination .\boost
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
msbuild-architecture: ${{ matrix.arch }}
- if: matrix.tests == 'Test'
name: Fetch googletest
uses: actions/checkout@v4
with:
msbuild-architecture: x86
- name: Build x86
repository: google/googletest
path: ./googletest
- if: matrix.tests == 'Test'
name: Build googletest
run: |
cmake -B googletest/build_${{ matrix.arch }} -A ${{ matrix.arch == 'x86' && 'Win32' || 'x64' }} googletest
cmake --build googletest/build_${{ matrix.arch }} --config ${{ matrix.config }}
- name: Build
run: |
msbuild -nologo `
-maxCpuCount "-property:UseMultiToolTask=true" "-property:EnforceProcessCountAcrossBuilds=true" `
"-property:Configuration=Release" `
"-property:Platform=x86" `
"-property:Configuration=${{ matrix.config }}${{ matrix.tests }}" `
"-property:Platform=${{ matrix.arch }}" `
"-property:BOOST_PATH=..\boost" `
"-property:GTEST_PATH=..\googletest" `
"-property:GTEST_LIBDIR=..\googletest\build_${{ matrix.arch }}\lib\${{ matrix.config }}" `
"-property:RunCodeAnalysis=false" `
.\vsbuild\usvfs.sln
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# build intermediates:
/vsbuild/Release
/vsbuild/ReleaseTest
/vsbuild/Debug

# test "side effects"
Expand Down
2 changes: 1 addition & 1 deletion src/shared/test_helpers.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if 0
#if USVFS_BUILD_TESTS

#include "test_helpers.h"
#include "winapi.h"
Expand Down
4 changes: 3 additions & 1 deletion src/shared/test_helpers.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once

#if 0
#if USVFS_BUILD_TESTS

#include "windows_sane.h"

#include <filesystem>

namespace test {

class FuncFailed : public std::runtime_error
Expand Down
1 change: 1 addition & 0 deletions src/shared/winapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ along with usvfs. If not, see <http://www.gnu.org/licenses/>.
#pragma once

#include "windows_sane.h"
#include <ShlObj.h>
#include "logging.h"
#include "stringcast.h"

Expand Down
2 changes: 2 additions & 0 deletions test/shared_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <directory_tree.h>
#undef PRIVATE

#include <tree_container.h>

using namespace usvfs::shared;

using namespace boost::interprocess;
Expand Down
6 changes: 5 additions & 1 deletion test/test_file_operations/test_file_operations.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include <cstdio>
#include <stdexcept>
#include <winapi.h>
#include <fmt/format.h>

#include <boost/type_traits.hpp>
#include <boost/filesystem.hpp>
#include <winapi.h>

#include <test_helpers.h>
#include "test_ntapi.h"
#include "test_w32api.h"
Expand Down
4 changes: 4 additions & 0 deletions test/thooklib_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
#include <utility.h>
#include <windows_sane.h>
//#include <boost/thread.hpp>
#include <boost/filesystem.hpp>
#include <spdlog.h>
#include <exceptionex.h>
#include <winapi.h>

namespace fs = boost::filesystem;

#include <stringutils.h>


Expand Down
4 changes: 2 additions & 2 deletions test/tinjectlib_test/main.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <gtest/gtest.h>
#include <injectlib.h>
#include <windows_error.h>
#include <boost/type_traits.hpp>
#include <boost/filesystem.hpp>
#include <winapi.h>
#include <spdlog.h>
#include <boost/filesystem.hpp>

using namespace usvfs::shared;
using namespace InjectLib;
Expand Down
4 changes: 4 additions & 0 deletions test/tvfs_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ You should have received a copy of the GNU General Public License
along with usvfs. If not, see <http://www.gnu.org/licenses/>.
*/

// this file depends on so many stuff that the easiest way is to include
// pch.h from shared
#include "pch.h"

#include <test_helpers.h>

#pragma warning (push, 3)
Expand Down
6 changes: 5 additions & 1 deletion test/usvfs_test/usvfs_test.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@

#include <iostream>
#include <memory>

#include <boost/filesystem.hpp>
#include <boost/type_traits.hpp>
#include <winapi.h>
#include <stringcast.h>

#include "usvfs_basic_test.h"
#include <stringcast.h>

void print_usage(const std::wstring& exe_name, const std::wstring& test_name) {
using namespace std;
Expand Down
2 changes: 2 additions & 0 deletions test/usvfs_test/usvfs_test_base.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

#include "usvfs_test_base.h"
#include <boost/filesystem.hpp>
#include <boost/type_traits.hpp>
#include <winapi.h>
#include <stringcast.h>
#include <usvfs.h>
Expand Down
4 changes: 2 additions & 2 deletions test/usvfs_test/usvfs_test_base.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <test_helpers.h>
#include <filesystem>
#include <string>

#include <test_helpers.h>

class usvfs_test_options {
public:
static constexpr auto DEFAULT_MAPPING = L"vfs_mappings.txt";
Expand Down
2 changes: 2 additions & 0 deletions test/usvfs_test_runner/usvfs_test_runner.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <gtest/gtest.h>

#include <boost/filesystem.hpp>
#include <test_helpers.h>
#include <windows_sane.h>
#include <iostream>
Expand Down
54 changes: 54 additions & 0 deletions vsbuild/asmjit.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseTest|Win32">
<Configuration>ReleaseTest</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseTest|x64">
<Configuration>ReleaseTest</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
Expand Down Expand Up @@ -95,6 +103,13 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseTest|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
Expand All @@ -108,6 +123,13 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseTest|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
Expand All @@ -121,6 +143,10 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseTest|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="common.props" />
Expand All @@ -129,6 +155,10 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseTest|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand All @@ -155,6 +185,18 @@
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseTest|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>ASMJIT_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
Expand All @@ -167,6 +209,18 @@
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseTest|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>ASMJIT_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
Loading

0 comments on commit 5597411

Please sign in to comment.