Merge pull request 'Build containers, toolchains and portability fixes' (#35) from chore/toolchains-and-portability into main
This commit was merged in pull request #35.
This commit is contained in:
commit
b3c566ed4d
17 files changed
+361
-96
No files matched your search
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "VoidLibrary (GCC 16, CMake 4, Ninja)",
|
||||||
|
"build": {
|
||||||
|
"dockerfile": "../Dockerfile",
|
||||||
|
"context": ".."
|
||||||
|
},
|
||||||
|
"workspaceFolder": "/src",
|
||||||
|
"workspaceMount": "source=${localWorkspaceFolder},target=/src,type=bind",
|
||||||
|
"remoteUser": "root",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"ms-vscode.cmake-tools",
|
||||||
|
"twxs.cmake"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"cmake.generator": "Ninja",
|
||||||
|
"cmake.configureSettings": {
|
||||||
|
"CMAKE_CXX_COMPILER": "g++-16",
|
||||||
|
"CMAKE_C_COMPILER": "gcc-16",
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
|
},
|
||||||
|
"C_Cpp.default.cppStandard": "c++26"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"postCreateCommand": "cmake --version && g++-16 --version && ninja --version"
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Windows builds: MSYS2 (native) and MinGW-w64 (cross)
|
||||||
|
|
||||||
|
## MSYS2 (native Windows, recommended for a full build)
|
||||||
|
|
||||||
|
Install the MINGW64 toolchain and the optional libraries used by the modules:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pacman -S --needed base-devel \
|
||||||
|
mingw-w64-x86_64-toolchain \
|
||||||
|
mingw-w64-x86_64-cmake \
|
||||||
|
mingw-w64-x86_64-ninja \
|
||||||
|
mingw-w64-x86_64-boost \
|
||||||
|
mingw-w64-x86_64-openssl \
|
||||||
|
mingw-w64-x86_64-libsodium \
|
||||||
|
mingw-w64-x86_64-libarchive \
|
||||||
|
mingw-w64-x86_64-sqlite3 \
|
||||||
|
mingw-w64-x86_64-lua
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, from a **MINGW64** shell (not the MSYS shell):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Debug
|
||||||
|
cmake --build build
|
||||||
|
ctest --test-dir build --output-on-failure
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
- C++26 reflection requires GCC 16 or newer (`-freflection`). The build
|
||||||
|
probes for it; on older GCC some reflection-only tests are skipped.
|
||||||
|
- `Void::IO` currently has a POSIX (epoll) backend only; select the modules
|
||||||
|
you need with `-DVOID_ENABLED_MODULES=...` if a module is not yet available
|
||||||
|
on Windows.
|
||||||
|
- The Windows branches of `Void::System` (paths, bounded reads, audio) are
|
||||||
|
compiled by this configuration.
|
||||||
|
|
||||||
|
## MinGW-w64 cross build (Linux container)
|
||||||
|
|
||||||
|
`Dockerfile.mingw` uses the LLVM-MinGW toolchain (Clang + libc++ + the
|
||||||
|
MinGW-w64 runtime) on top of Ubuntu, together with CMake 4 and Ninja. The
|
||||||
|
matching devcontainer is in `.devcontainer/mingw/`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -f Dockerfile.mingw -t voidlibrary-mingw .
|
||||||
|
docker run --rm -v "$PWD:/src" -w /src voidlibrary-mingw bash -lc '
|
||||||
|
cmake -B build-mingw -S . -G Ninja \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64.cmake \
|
||||||
|
-DCMAKE_BUILD_TYPE=Debug \
|
||||||
|
-DVOID_ENABLE_TESTING=OFF \
|
||||||
|
-DVOID_ENABLED_MODULES="Core;Functional;Containers;Math;Text;Algorithms;Unicode;Time;LogState"
|
||||||
|
cmake --build build-mingw
|
||||||
|
'
|
||||||
|
```
|
||||||
|
|
||||||
|
Cross-compiling cannot use the host's Boost/OpenSSL/libsodium/libarchive/SQLite/
|
||||||
|
Lua libraries. Modules that need them (or the POSIX-only IO backend) are
|
||||||
|
therefore excluded from a cross build; use MSYS2 on Windows for those.
|
||||||
|
|
||||||
|
- The toolchain file accepts GCC- or Clang-based MinGW prefixes and picks
|
||||||
|
whichever compiler exists.
|
||||||
|
- `CMAKE_CXX_STANDARD` can be pinned for older toolchains
|
||||||
|
(`-DCMAKE_CXX_STANDARD=23`); the build probes capabilities against the
|
||||||
|
selected standard.
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "VoidLibrary (MinGW-w64 cross build)",
|
||||||
|
"build": {
|
||||||
|
"dockerfile": "../../Dockerfile.mingw",
|
||||||
|
"context": "../.."
|
||||||
|
},
|
||||||
|
"workspaceFolder": "/src",
|
||||||
|
"workspaceMount": "source=${localWorkspaceFolder},target=/src,type=bind",
|
||||||
|
"remoteUser": "root",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"ms-vscode.cmake-tools",
|
||||||
|
"twxs.cmake"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"cmake.generator": "Ninja",
|
||||||
|
"cmake.configureSettings": {
|
||||||
|
"CMAKE_TOOLCHAIN_FILE": "cmake/toolchains/mingw-w64.cmake",
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
|
},
|
||||||
|
"C_Cpp.default.cppStandard": "c++26"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"postCreateCommand": "cmake --version && x86_64-w64-mingw32-g++ --version && ninja --version"
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
build*
|
||||||
|
.git
|
||||||
|
.gitea
|
||||||
|
.github
|
||||||
|
.dockerignore
|
||||||
|
Dockerfile
|
||||||
+12
-2
@@ -15,10 +15,20 @@ option(VOID_ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (Clang/GCC)" OFF)
|
|||||||
option(VOID_ENABLE_TSAN "Enable ThreadSanitizer (Clang/GCC)" OFF)
|
option(VOID_ENABLE_TSAN "Enable ThreadSanitizer (Clang/GCC)" OFF)
|
||||||
option(VOID_ENABLE_COVERAGE "Enable code coverage instrumentation" OFF)
|
option(VOID_ENABLE_COVERAGE "Enable code coverage instrumentation" OFF)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 26)
|
# C++26 is the default. Cross/toolchain-limited builds (e.g. MinGW-w64
|
||||||
|
# with an older GCC) may pin a lower standard explicitly.
|
||||||
|
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
||||||
|
set(CMAKE_CXX_STANDARD 26)
|
||||||
|
endif()
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
set(CMAKE_CXX_MODULE_MAP_FORMAT "gcc")
|
if(NOT DEFINED CMAKE_CXX_MODULE_MAP_FORMAT)
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
set(CMAKE_CXX_MODULE_MAP_FORMAT "clang")
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_MODULE_MAP_FORMAT "gcc")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
set(CXX_SCAN_FOR_MODULES OFF)
|
set(CXX_SCAN_FOR_MODULES OFF)
|
||||||
# <Void/Data/Reflect.hpp>, <Void/Configuration/Bind.hpp>, etc.
|
# <Void/Data/Reflect.hpp>, <Void/Configuration/Bind.hpp>, etc.
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16)
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16)
|
||||||
|
|||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
# Development image for VoidLibrary.
|
||||||
|
#
|
||||||
|
# Toolchain: GCC 16 (C++26 reflection), CMake 4, Ninja.
|
||||||
|
# Optional dependencies used by the modules: Boost, OpenSSL, libsodium,
|
||||||
|
# libarchive, SQLite3 and Lua 5.4.
|
||||||
|
#
|
||||||
|
# The image does not copy or build the sources: mount the repository at /src
|
||||||
|
# (the devcontainer does this) and configure/build there.
|
||||||
|
|
||||||
|
FROM ubuntu:24.04
|
||||||
|
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
ARG GCC_VERSION=16
|
||||||
|
ARG CMAKE_VERSION=4.2.3
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
gnupg \
|
||||||
|
ninja-build \
|
||||||
|
pkg-config \
|
||||||
|
software-properties-common \
|
||||||
|
libboost-all-dev \
|
||||||
|
libssl-dev \
|
||||||
|
libsodium-dev \
|
||||||
|
libarchive-dev \
|
||||||
|
libsqlite3-dev \
|
||||||
|
liblua5.4-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
gcc-${GCC_VERSION} \
|
||||||
|
g++-${GCC_VERSION} \
|
||||||
|
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 100 \
|
||||||
|
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} 100 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN curl -fsSL -o /tmp/cmake.tar.gz \
|
||||||
|
"https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz" \
|
||||||
|
&& tar -xzf /tmp/cmake.tar.gz -C /opt \
|
||||||
|
&& ln -s "/opt/cmake-${CMAKE_VERSION}-linux-x86_64/bin/cmake" /usr/local/bin/cmake \
|
||||||
|
&& ln -s "/opt/cmake-${CMAKE_VERSION}-linux-x86_64/bin/ctest" /usr/local/bin/ctest \
|
||||||
|
&& ln -s "/opt/cmake-${CMAKE_VERSION}-linux-x86_64/bin/cpack" /usr/local/bin/cpack \
|
||||||
|
&& rm /tmp/cmake.tar.gz
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
CMD ["bash"]
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# MinGW-w64 cross-build environment for VoidLibrary (Windows x64 from Linux).
|
||||||
|
#
|
||||||
|
# Uses the LLVM-MinGW toolchain (Clang + libc++ + MinGW-w64 runtime), which is
|
||||||
|
# new enough for the C++26 features this project uses. Reflection is not
|
||||||
|
# available on Clang, so the reflection-only tests are skipped exactly as on
|
||||||
|
# any non-reflecting compiler.
|
||||||
|
|
||||||
|
FROM mstorsjo/llvm-mingw:latest
|
||||||
|
|
||||||
|
ARG CMAKE_VERSION=4.2.3
|
||||||
|
|
||||||
|
# The base image is Ubuntu 24.04 with CMake 3.28; Void requires CMake 4.
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends ca-certificates curl git \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN curl -fsSL -o /tmp/cmake.tar.gz \
|
||||||
|
"https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz" \
|
||||||
|
&& tar -xzf /tmp/cmake.tar.gz -C /opt \
|
||||||
|
&& ln -sf "/opt/cmake-${CMAKE_VERSION}-linux-x86_64/bin/cmake" /usr/local/bin/cmake \
|
||||||
|
&& ln -sf "/opt/cmake-${CMAKE_VERSION}-linux-x86_64/bin/ctest" /usr/local/bin/ctest \
|
||||||
|
&& ln -sf "/opt/cmake-${CMAKE_VERSION}-linux-x86_64/bin/cpack" /usr/local/bin/cpack \
|
||||||
|
&& rm /tmp/cmake.tar.gz
|
||||||
|
|
||||||
|
ENV PATH="/opt/llvm-mingw/bin:${PATH}"
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
CMD ["bash"]
|
||||||
@@ -33,7 +33,7 @@ function(void_probe_capabilities)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_push_check_state(RESET)
|
cmake_push_check_state(RESET)
|
||||||
set(CMAKE_REQUIRED_FLAGS "-std=c++26")
|
set(CMAKE_REQUIRED_FLAGS "-std=c++${CMAKE_CXX_STANDARD}")
|
||||||
check_cxx_source_compiles(
|
check_cxx_source_compiles(
|
||||||
"#include <expected>\nint main() { std::expected<int, int> e{0}; return *e; }\n"
|
"#include <expected>\nint main() { std::expected<int, int> e{0}; return *e; }\n"
|
||||||
VOID_HAS_STD_EXPECTED
|
VOID_HAS_STD_EXPECTED
|
||||||
@@ -46,10 +46,12 @@ function(void_probe_capabilities)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_push_check_state(RESET)
|
cmake_push_check_state(RESET)
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16)
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
|
||||||
set(CMAKE_REQUIRED_FLAGS "-std=c++26 -freflection")
|
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16 AND
|
||||||
|
CMAKE_CXX_STANDARD GREATER_EQUAL 26)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-std=c++${CMAKE_CXX_STANDARD} -freflection")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_REQUIRED_FLAGS "-std=c++26")
|
set(CMAKE_REQUIRED_FLAGS "-std=c++${CMAKE_CXX_STANDARD}")
|
||||||
endif()
|
endif()
|
||||||
check_cxx_source_compiles(
|
check_cxx_source_compiles(
|
||||||
"#include <meta>\nconsteval bool probe() { constexpr auto r = ^^int; return std::meta::is_type(r); }\nstatic_assert(probe());\nint main() { return 0; }\n"
|
"#include <meta>\nconsteval bool probe() { constexpr auto r = ^^int; return std::meta::is_type(r); }\nstatic_assert(probe());\nint main() { return 0; }\n"
|
||||||
|
|||||||
+3
-3
@@ -33,7 +33,7 @@ function(void_add_module MODULE_NAME)
|
|||||||
set(LIB_TYPE "INTERFACE")
|
set(LIB_TYPE "INTERFACE")
|
||||||
set(SCOPE "INTERFACE")
|
set(SCOPE "INTERFACE")
|
||||||
add_library(${TGT} INTERFACE)
|
add_library(${TGT} INTERFACE)
|
||||||
target_compile_features(${TGT} INTERFACE cxx_std_26)
|
target_compile_features(${TGT} INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
|
||||||
else()
|
else()
|
||||||
set(SCOPE "PUBLIC")
|
set(SCOPE "PUBLIC")
|
||||||
if (MODULE_NAME STREQUAL "Testing")
|
if (MODULE_NAME STREQUAL "Testing")
|
||||||
@@ -45,7 +45,7 @@ function(void_add_module MODULE_NAME)
|
|||||||
add_library(${TGT})
|
add_library(${TGT})
|
||||||
endif()
|
endif()
|
||||||
target_sources(${TGT} PRIVATE ${SRC})
|
target_sources(${TGT} PRIVATE ${SRC})
|
||||||
target_compile_features(${TGT} PUBLIC cxx_std_26)
|
target_compile_features(${TGT} PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
|
||||||
endif()
|
endif()
|
||||||
get_target_property(_module_target_type ${TGT} TYPE)
|
get_target_property(_module_target_type ${TGT} TYPE)
|
||||||
if(_module_target_type STREQUAL "SHARED_LIBRARY" OR
|
if(_module_target_type STREQUAL "SHARED_LIBRARY" OR
|
||||||
@@ -221,7 +221,7 @@ function(void_add_module MODULE_NAME)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties(${TGT} PROPERTIES
|
set_target_properties(${TGT} PROPERTIES
|
||||||
CXX_STANDARD 26
|
CXX_STANDARD ${CMAKE_CXX_STANDARD}
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
CXX_EXTENSIONS OFF
|
CXX_EXTENSIONS OFF
|
||||||
EXPORT_NAME ${MODULE_NAME}
|
EXPORT_NAME ${MODULE_NAME}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# CMake toolchain for cross-compiling to Windows x64 with MinGW-w64.
|
||||||
|
#
|
||||||
|
# Works with the GCC-based mingw-w64 package and with the LLVM-MinGW
|
||||||
|
# toolchain (Dockerfile.mingw). Override the compiler paths for your install.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# cmake -B build-mingw -S . -G Ninja \
|
||||||
|
# -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64.cmake \
|
||||||
|
# -DCMAKE_BUILD_TYPE=Debug
|
||||||
|
|
||||||
|
set(CMAKE_SYSTEM_NAME Windows)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||||
|
|
||||||
|
if(NOT DEFINED VOID_MINGW_PREFIX)
|
||||||
|
set(VOID_MINGW_PREFIX x86_64-w64-mingw32)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_program(VOID_MINGW_CXX NAMES "${VOID_MINGW_PREFIX}-clang++"
|
||||||
|
"${VOID_MINGW_PREFIX}-g++" REQUIRED)
|
||||||
|
find_program(VOID_MINGW_C NAMES "${VOID_MINGW_PREFIX}-clang"
|
||||||
|
"${VOID_MINGW_PREFIX}-gcc" REQUIRED)
|
||||||
|
find_program(VOID_MINGW_RC NAMES "${VOID_MINGW_PREFIX}-windres")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_COMPILER "${VOID_MINGW_CXX}")
|
||||||
|
set(CMAKE_C_COMPILER "${VOID_MINGW_C}")
|
||||||
|
if(VOID_MINGW_RC)
|
||||||
|
set(CMAKE_RC_COMPILER "${VOID_MINGW_RC}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
@@ -263,6 +263,7 @@ class AudioDevice
|
|||||||
HWAVEOUT wave{};
|
HWAVEOUT wave{};
|
||||||
WAVEHDR header{};
|
WAVEHDR header{};
|
||||||
WAVEFORMATEX format{};
|
WAVEFORMATEX format{};
|
||||||
|
std::vector<PcmSample> playback;
|
||||||
bool prepared{false};
|
bool prepared{false};
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -343,11 +344,14 @@ class AudioDevice
|
|||||||
"waveOutOpen failed"}};
|
"waveOutOpen failed"}};
|
||||||
}
|
}
|
||||||
voice.header = WAVEHDR{};
|
voice.header = WAVEHDR{};
|
||||||
|
// waveOut only reads the samples, but WAVEHDR exposes a mutable
|
||||||
|
// buffer; keep an owned mutable copy instead of casting away
|
||||||
|
// constness of the shared buffer.
|
||||||
|
voice.playback = voice.buffer->samples;
|
||||||
voice.header.lpData =
|
voice.header.lpData =
|
||||||
reinterpret_cast<LPSTR>(
|
reinterpret_cast<LPSTR>(voice.playback.data());
|
||||||
const_cast<PcmSample*>(voice.buffer->samples.data()));
|
|
||||||
voice.header.dwBufferLength = static_cast<DWORD>(
|
voice.header.dwBufferLength = static_cast<DWORD>(
|
||||||
voice.buffer->samples.size() * sizeof(PcmSample));
|
voice.playback.size() * sizeof(PcmSample));
|
||||||
if (::waveOutPrepareHeader(voice.wave, &voice.header,
|
if (::waveOutPrepareHeader(voice.wave, &voice.header,
|
||||||
sizeof(WAVEHDR)) !=
|
sizeof(WAVEHDR)) !=
|
||||||
MMSYSERR_NOERROR) {
|
MMSYSERR_NOERROR) {
|
||||||
|
|||||||
@@ -209,22 +209,18 @@ private:
|
|||||||
|
|
||||||
[[nodiscard]] inline std::string win32_message(DWORD error)
|
[[nodiscard]] inline std::string win32_message(DWORD error)
|
||||||
{
|
{
|
||||||
char* buffer = nullptr;
|
std::array<char, 512> buffer{};
|
||||||
const DWORD length = ::FormatMessageA(
|
const DWORD length = ::FormatMessageA(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
|
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
nullptr,
|
nullptr,
|
||||||
error,
|
error,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
reinterpret_cast<char*>(&buffer),
|
buffer.data(),
|
||||||
0,
|
static_cast<DWORD>(buffer.size()),
|
||||||
nullptr);
|
nullptr);
|
||||||
std::string message = (length != 0 && buffer != nullptr)
|
std::string message = length != 0
|
||||||
? std::string{buffer, length}
|
? std::string{buffer.data(), length}
|
||||||
: std::string{"unknown error"};
|
: std::string{"unknown error"};
|
||||||
if (buffer != nullptr) {
|
|
||||||
::LocalFree(buffer);
|
|
||||||
}
|
|
||||||
while (!message.empty() &&
|
while (!message.empty() &&
|
||||||
(message.back() == '\n' || message.back() == '\r' ||
|
(message.back() == '\n' || message.back() == '\r' ||
|
||||||
message.back() == ' ' || message.back() == '.')) {
|
message.back() == ' ' || message.back() == '.')) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Void/Core/Meta.hpp>
|
#include <Void/Core/Meta.hpp>
|
||||||
#include <Void/Testing/Annotations.hpp>
|
|
||||||
#include <Void/Testing/Config.hpp>
|
#include <Void/Testing/Config.hpp>
|
||||||
#include <Void/Testing/Detail/Registry.hpp>
|
#include <Void/Testing/Detail/Registry.hpp>
|
||||||
#include <Void/Testing/Test.hpp>
|
#include <Void/Testing/Test.hpp>
|
||||||
@@ -11,6 +10,7 @@
|
|||||||
|
|
||||||
#if __has_include(<meta>)
|
#if __has_include(<meta>)
|
||||||
#include <meta>
|
#include <meta>
|
||||||
|
#include <Void/Testing/Annotations.hpp>
|
||||||
#define VOID_TESTING_HAS_REFLECTION 1
|
#define VOID_TESTING_HAS_REFLECTION 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -95,6 +95,13 @@ namespace Void::Testing
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Non-capturing thunk: a template argument is a constant
|
||||||
|
/// expression, unlike a reflected member captured by a lambda.
|
||||||
|
template <meta::info M> static void run_method_thunk()
|
||||||
|
{
|
||||||
|
run_method<M>();
|
||||||
|
}
|
||||||
|
|
||||||
static std::string suite_label()
|
static std::string suite_label()
|
||||||
{
|
{
|
||||||
if constexpr (constexpr auto n =
|
if constexpr (constexpr auto n =
|
||||||
@@ -138,12 +145,17 @@ namespace Void::Testing
|
|||||||
skip_reason = std::string{s->reason.view()};
|
skip_reason = std::string{s->reason.view()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr auto name = meta::identifier_of(m);
|
||||||
|
constexpr const char* file = loc.file_name();
|
||||||
|
constexpr int line =
|
||||||
|
static_cast<int>(loc.line());
|
||||||
|
constexpr auto run = &run_method_thunk<m>;
|
||||||
reg.add(TestCase{
|
reg.add(TestCase{
|
||||||
.run = [] { run_method<m>(); },
|
.run = run,
|
||||||
.name = std::string{meta::identifier_of(m)},
|
.name = std::string{name},
|
||||||
.suite = suite,
|
.suite = suite,
|
||||||
.file = loc.file_name(),
|
.file = file,
|
||||||
.line = static_cast<int>(loc.line()),
|
.line = line,
|
||||||
.disabled = disabled,
|
.disabled = disabled,
|
||||||
.skip_reason = std::move(skip_reason),
|
.skip_reason = std::move(skip_reason),
|
||||||
.tags = std::move(tags),
|
.tags = std::move(tags),
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ namespace Void::Testing {
|
|||||||
using namespace Void::Testing::Detail::Color;
|
using namespace Void::Testing::Detail::Color;
|
||||||
|
|
||||||
void ConsoleReporter::on_run_start(const RunConfig&, int total_tests) {
|
void ConsoleReporter::on_run_start(const RunConfig&, int total_tests) {
|
||||||
os_ << "\n" << apply(bold_blue, "╭──────────────────────────────────────────────╮") << "\n"
|
os_ << "\n" << Void::Testing::Detail::Color::apply(bold_blue, "╭──────────────────────────────────────────────╮") << "\n"
|
||||||
<< apply(bold_blue, "│") << apply(bold_white, " Void Testing") << apply(dim, " v1.0") << std::string(31, ' ') << apply(bold_blue, "│") << "\n"
|
<< Void::Testing::Detail::Color::apply(bold_blue, "│") << Void::Testing::Detail::Color::apply(bold_white, " Void Testing") << Void::Testing::Detail::Color::apply(dim, " v1.0") << std::string(31, ' ') << Void::Testing::Detail::Color::apply(bold_blue, "│") << "\n"
|
||||||
<< std::format("{}│{} Discovered {} test{}{}│\n", apply(bold_blue, "╰"), apply(dim, ""), apply(bold_white, std::to_string(total_tests)), total_tests != 1 ? "s" : "", std::string(total_tests < 10 ? 33 : 28, ' '))
|
<< std::format("{}│{} Discovered {} test{}{}│\n", Void::Testing::Detail::Color::apply(bold_blue, "╰"), Void::Testing::Detail::Color::apply(dim, ""), Void::Testing::Detail::Color::apply(bold_white, std::to_string(total_tests)), total_tests != 1 ? "s" : "", std::string(total_tests < 10 ? 33 : 28, ' '))
|
||||||
<< apply(bold_blue, "╰──────────────────────────────────────────────╯") << "\n\n";
|
<< Void::Testing::Detail::Color::apply(bold_blue, "╰──────────────────────────────────────────────╯") << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleReporter::on_suite_start(const std::string& suite_name, int test_count) {
|
void ConsoleReporter::on_suite_start(const std::string& suite_name, int test_count) {
|
||||||
os_ << std::format(" {} {} [{} test{}]\n", apply(bold_blue, "◆"), apply(bold_white, suite_name), apply(dim, std::to_string(test_count)), test_count != 1 ? "s" : "");
|
os_ << std::format(" {} {} [{} test{}]\n", Void::Testing::Detail::Color::apply(bold_blue, "◆"), Void::Testing::Detail::Color::apply(bold_white, suite_name), Void::Testing::Detail::Color::apply(dim, std::to_string(test_count)), test_count != 1 ? "s" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleReporter::on_test_start(const TestCase&) {}
|
void ConsoleReporter::on_test_start(const TestCase&) {}
|
||||||
@@ -25,46 +25,46 @@ void ConsoleReporter::on_test_end(const TestResult& result) {
|
|||||||
double ms = std::chrono::duration<double, std::milli>(result.duration).count();
|
double ms = std::chrono::duration<double, std::milli>(result.duration).count();
|
||||||
std::string time_str = ms < 1.0 ? std::format("{:.3f}ms", ms) : std::format("{:.1f}ms", ms);
|
std::string time_str = ms < 1.0 ? std::format("{:.3f}ms", ms) : std::format("{:.1f}ms", ms);
|
||||||
std::string tags_str;
|
std::string tags_str;
|
||||||
if (!result.tags.empty()) { for(const auto& t : result.tags) tags_str += "[" + t + "]"; tags_str = " " + apply(dim, tags_str); }
|
if (!result.tags.empty()) { for(const auto& t : result.tags) tags_str += "[" + t + "]"; tags_str = " " + Void::Testing::Detail::Color::apply(dim, tags_str); }
|
||||||
|
|
||||||
switch (result.state) {
|
switch (result.state) {
|
||||||
case TestState::Passed: os_ << std::format(" {} {:<40s}{}{}\n", apply(bold_green, "✔"), apply(green, result.name), tags_str, apply(dim, time_str)); break;
|
case TestState::Passed: os_ << std::format(" {} {:<40s}{}{}\n", Void::Testing::Detail::Color::apply(bold_green, "✔"), Void::Testing::Detail::Color::apply(green, result.name), tags_str, Void::Testing::Detail::Color::apply(dim, time_str)); break;
|
||||||
case TestState::Failed:
|
case TestState::Failed:
|
||||||
os_ << std::format(" {} {:<40s}{}{}\n", apply(bold_red, "✘"), apply(red, result.name), tags_str, apply(dim, time_str));
|
os_ << std::format(" {} {:<40s}{}{}\n", Void::Testing::Detail::Color::apply(bold_red, "✘"), Void::Testing::Detail::Color::apply(red, result.name), tags_str, Void::Testing::Detail::Color::apply(dim, time_str));
|
||||||
for (const auto& ar : result.assertions) if (!ar.passed) print_assertion_failure(ar);
|
for (const auto& ar : result.assertions) if (!ar.passed) print_assertion_failure(ar);
|
||||||
if (!result.crash_info.empty()) print_crash_info(result);
|
if (!result.crash_info.empty()) print_crash_info(result);
|
||||||
break;
|
break;
|
||||||
case TestState::Skipped: os_ << std::format(" {} {:<40s}{}\n", apply(bold_yellow, "⊘"), apply(yellow, result.name), apply(dim, std::format("[SKIPPED: {}]", result.skip_reason.empty() ? "no reason" : result.skip_reason))); break;
|
case TestState::Skipped: os_ << std::format(" {} {:<40s}{}\n", Void::Testing::Detail::Color::apply(bold_yellow, "⊘"), Void::Testing::Detail::Color::apply(yellow, result.name), Void::Testing::Detail::Color::apply(dim, std::format("[SKIPPED: {}]", result.skip_reason.empty() ? "no reason" : result.skip_reason))); break;
|
||||||
case TestState::Crashed: os_ << std::format(" {} {:<40s}{}\n", apply(bold_red, "⚡"), apply(red, result.name), apply(dim, time_str)); print_crash_info(result); break;
|
case TestState::Crashed: os_ << std::format(" {} {:<40s}{}\n", Void::Testing::Detail::Color::apply(bold_red, "⚡"), Void::Testing::Detail::Color::apply(red, result.name), Void::Testing::Detail::Color::apply(dim, time_str)); print_crash_info(result); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleReporter::print_assertion_failure(const AssertionResult& ar) {
|
void ConsoleReporter::print_assertion_failure(const AssertionResult& ar) {
|
||||||
os_ << apply(red, " ╭─── Assertion Failed") << apply(dim, " ──────────────────────╮") << "\n";
|
os_ << Void::Testing::Detail::Color::apply(red, " ╭─── Assertion Failed") << Void::Testing::Detail::Color::apply(dim, " ──────────────────────╮") << "\n";
|
||||||
std::filesystem::path p{ar.location.file_name()};
|
std::filesystem::path p{ar.location.file_name()};
|
||||||
os_ << std::format(" │ {}:{}\n", apply(bold_white, p.filename().string()), ar.location.line());
|
os_ << std::format(" │ {}:{}\n", Void::Testing::Detail::Color::apply(bold_white, p.filename().string()), ar.location.line());
|
||||||
if (!ar.expression.empty()) os_ << std::format(" │ {}\n", apply(cyan, ar.expression));
|
if (!ar.expression.empty()) os_ << std::format(" │ {}\n", Void::Testing::Detail::Color::apply(cyan, ar.expression));
|
||||||
if (!ar.expected_repr.empty()) os_ << std::format(" │ {} {}\n", apply(bold_white, "expected:"), apply(green, ar.expected_repr));
|
if (!ar.expected_repr.empty()) os_ << std::format(" │ {} {}\n", Void::Testing::Detail::Color::apply(bold_white, "expected:"), Void::Testing::Detail::Color::apply(green, ar.expected_repr));
|
||||||
if (!ar.actual_repr.empty()) os_ << std::format(" │ {} {}\n", apply(bold_white, "actual: "), apply(red, ar.actual_repr));
|
if (!ar.actual_repr.empty()) os_ << std::format(" │ {} {}\n", Void::Testing::Detail::Color::apply(bold_white, "actual: "), Void::Testing::Detail::Color::apply(red, ar.actual_repr));
|
||||||
if (!ar.message.empty()) os_ << std::format(" │ {}\n", ar.message);
|
if (!ar.message.empty()) os_ << std::format(" │ {}\n", ar.message);
|
||||||
os_ << apply(red, " ╰────────────────────────────────────────────╯") << "\n";
|
os_ << Void::Testing::Detail::Color::apply(red, " ╰────────────────────────────────────────────╯") << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleReporter::print_crash_info(const TestResult& result) {
|
void ConsoleReporter::print_crash_info(const TestResult& result) {
|
||||||
os_ << apply(bold_red, " ╭─── Crash") << apply(dim, " ───────────────────────────╮") << "\n";
|
os_ << Void::Testing::Detail::Color::apply(bold_red, " ╭─── Crash") << Void::Testing::Detail::Color::apply(dim, " ───────────────────────────╮") << "\n";
|
||||||
if (!result.crash_info.empty()) os_ << std::format(" │ {}\n", apply(red, result.crash_info));
|
if (!result.crash_info.empty()) os_ << std::format(" │ {}\n", Void::Testing::Detail::Color::apply(red, result.crash_info));
|
||||||
os_ << apply(bold_red, " ╰────────────────────────────────────────────╯") << "\n";
|
os_ << Void::Testing::Detail::Color::apply(bold_red, " ╰────────────────────────────────────────────╯") << "\n";
|
||||||
if (!result.stacktrace.empty()) os_ << apply(dim, " Stacktrace:\n") << result.stacktrace << "\n";
|
if (!result.stacktrace.empty()) os_ << Void::Testing::Detail::Color::apply(dim, " Stacktrace:\n") << result.stacktrace << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleReporter::on_run_end(const RunResult& result) {
|
void ConsoleReporter::on_run_end(const RunResult& result) {
|
||||||
os_ << "\n" << apply(dim, "╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍") << "\n"
|
os_ << "\n" << Void::Testing::Detail::Color::apply(dim, "╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍") << "\n"
|
||||||
<< std::format(" {} tests: ", apply(bold_white, std::to_string(result.total)));
|
<< std::format(" {} tests: ", Void::Testing::Detail::Color::apply(bold_white, std::to_string(result.total)));
|
||||||
if (result.passed > 0) os_ << std::format("{} {} ", apply(bold_green, std::to_string(result.passed)), apply(green, "✔"));
|
if (result.passed > 0) os_ << std::format("{} {} ", Void::Testing::Detail::Color::apply(bold_green, std::to_string(result.passed)), Void::Testing::Detail::Color::apply(green, "✔"));
|
||||||
if (result.failed + result.crashed > 0) os_ << std::format("{} {} ", apply(bold_red, std::to_string(result.failed + result.crashed)), apply(red, "✘"));
|
if (result.failed + result.crashed > 0) os_ << std::format("{} {} ", Void::Testing::Detail::Color::apply(bold_red, std::to_string(result.failed + result.crashed)), Void::Testing::Detail::Color::apply(red, "✘"));
|
||||||
if (result.skipped > 0) os_ << std::format("{} {} ", apply(bold_yellow, std::to_string(result.skipped)), apply(yellow, "⊘"));
|
if (result.skipped > 0) os_ << std::format("{} {} ", Void::Testing::Detail::Color::apply(bold_yellow, std::to_string(result.skipped)), Void::Testing::Detail::Color::apply(yellow, "⊘"));
|
||||||
double total_ms = std::chrono::duration<double, std::milli>(result.total_duration).count();
|
double total_ms = std::chrono::duration<double, std::milli>(result.total_duration).count();
|
||||||
os_ << std::format(" {} {}\n", apply(dim, "in"), apply(bold_cyan, total_ms < 1000 ? std::format("{:.1f}ms", total_ms) : std::format("{:.2f}s", total_ms / 1000.0)))
|
os_ << std::format(" {} {}\n", Void::Testing::Detail::Color::apply(dim, "in"), Void::Testing::Detail::Color::apply(bold_cyan, total_ms < 1000 ? std::format("{:.1f}ms", total_ms) : std::format("{:.2f}s", total_ms / 1000.0)))
|
||||||
<< apply(dim, "╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍") << "\n\n";
|
<< Void::Testing::Detail::Color::apply(dim, "╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍") << "\n\n";
|
||||||
}
|
}
|
||||||
} // namespace Void::Testing
|
} // namespace Void::Testing
|
||||||
+36
-36
@@ -447,7 +447,7 @@ namespace Void::Testing
|
|||||||
|
|
||||||
std::cout
|
std::cout
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< apply(bold_blue,
|
<< Void::Testing::Detail::Color::apply(bold_blue,
|
||||||
"\xe2\x95\xad\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
"\xe2\x95\xad\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
||||||
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
||||||
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
||||||
@@ -461,12 +461,12 @@ namespace Void::Testing
|
|||||||
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
||||||
"\xe2\x94\x80\xe2\x94\x80\xe2\x95\xae")
|
"\xe2\x94\x80\xe2\x94\x80\xe2\x95\xae")
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< apply(bold_blue, "\xe2\x94\x82")
|
<< Void::Testing::Detail::Color::apply(bold_blue, "\xe2\x94\x82")
|
||||||
<< apply(bold_white, " Void Testing")
|
<< Void::Testing::Detail::Color::apply(bold_white, " Void Testing")
|
||||||
<< apply(dim, " \xe2\x80\x94 Command Line Interface")
|
<< Void::Testing::Detail::Color::apply(dim, " \xe2\x80\x94 Command Line Interface")
|
||||||
<< std::string(28, ' ') << apply(bold_blue, "\xe2\x94\x82")
|
<< std::string(28, ' ') << Void::Testing::Detail::Color::apply(bold_blue, "\xe2\x94\x82")
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< apply(bold_blue,
|
<< Void::Testing::Detail::Color::apply(bold_blue,
|
||||||
"\xe2\x95\xb0\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
"\xe2\x95\xb0\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
||||||
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
||||||
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
"\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80"
|
||||||
@@ -481,76 +481,76 @@ namespace Void::Testing
|
|||||||
"\xe2\x94\x80\xe2\x94\x80\xe2\x95\xaf")
|
"\xe2\x94\x80\xe2\x94\x80\xe2\x95\xaf")
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< " " << apply(bold_white, "USAGE:") << "\n"
|
<< " " << Void::Testing::Detail::Color::apply(bold_white, "USAGE:") << "\n"
|
||||||
<< " " << apply(cyan, "<executable>") << " "
|
<< " " << Void::Testing::Detail::Color::apply(cyan, "<executable>") << " "
|
||||||
<< apply(dim, "[options]") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "[options]") << "\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< " " << apply(bold_white, "OPTIONS:") << "\n";
|
<< " " << Void::Testing::Detail::Color::apply(bold_white, "OPTIONS:") << "\n";
|
||||||
|
|
||||||
constexpr std::size_t OPT_WIDTH = 23;
|
constexpr std::size_t OPT_WIDTH = 23;
|
||||||
auto opt = [&](std::string_view name) {
|
auto opt = [&](std::string_view name) {
|
||||||
#ifdef VOID_HAS_TEXT
|
#ifdef VOID_HAS_TEXT
|
||||||
return apply(green, Void::Str::pad_right(name, OPT_WIDTH));
|
return Void::Testing::Detail::Color::apply(green, Void::Str::pad_right(name, OPT_WIDTH));
|
||||||
#else
|
#else
|
||||||
std::string s{name};
|
std::string s{name};
|
||||||
if (s.size() < OPT_WIDTH) {
|
if (s.size() < OPT_WIDTH) {
|
||||||
s.append(OPT_WIDTH - s.size(), ' ');
|
s.append(OPT_WIDTH - s.size(), ' ');
|
||||||
}
|
}
|
||||||
return apply(green, s);
|
return Void::Testing::Detail::Color::apply(green, s);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
std::cout
|
std::cout
|
||||||
<< " " << opt("--filter <pattern>")
|
<< " " << opt("--filter <pattern>")
|
||||||
<< apply(dim, "Run tests matching the regex pattern") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Run tests matching the regex pattern") << "\n"
|
||||||
<< " " << opt("--suite <name>")
|
<< " " << opt("--suite <name>")
|
||||||
<< apply(dim, "Run only tests in the specified suite") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Run only tests in the specified suite") << "\n"
|
||||||
<< " " << opt("--tag <name>")
|
<< " " << opt("--tag <name>")
|
||||||
<< apply(dim, "Run only tests with the specified tag") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Run only tests with the specified tag") << "\n"
|
||||||
<< " " << opt("--list")
|
<< " " << opt("--list")
|
||||||
<< apply(dim, "List discovered tests without running them")
|
<< Void::Testing::Detail::Color::apply(dim, "List discovered tests without running them")
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< " " << opt("--shuffle")
|
<< " " << opt("--shuffle")
|
||||||
<< apply(dim, "Randomize the order of test execution") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Randomize the order of test execution") << "\n"
|
||||||
<< " " << opt("--seed <n>")
|
<< " " << opt("--seed <n>")
|
||||||
<< apply(dim, "Set the random seed (implies --shuffle)") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Set the random seed (implies --shuffle)") << "\n"
|
||||||
<< " " << opt("--repeat <n>")
|
<< " " << opt("--repeat <n>")
|
||||||
<< apply(dim, "Repeat the test run n times") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Repeat the test run n times") << "\n"
|
||||||
<< " " << opt("--reporter <type>")
|
<< " " << opt("--reporter <type>")
|
||||||
<< apply(dim, "Choose the output reporter: console, junit")
|
<< Void::Testing::Detail::Color::apply(dim, "Choose the output reporter: console, junit")
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< " " << opt("--output <file>")
|
<< " " << opt("--output <file>")
|
||||||
<< apply(dim, "Write reporter output to a file") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Write reporter output to a file") << "\n"
|
||||||
#ifdef VOID_HAS_LOG
|
#ifdef VOID_HAS_LOG
|
||||||
<< " " << opt("--log-file <file>")
|
<< " " << opt("--log-file <file>")
|
||||||
<< apply(dim,
|
<< Void::Testing::Detail::Color::apply(dim,
|
||||||
"Mirror test events to <file> via Void::Logging")
|
"Mirror test events to <file> via Void::Logging")
|
||||||
<< "\n"
|
<< "\n"
|
||||||
#endif
|
#endif
|
||||||
#ifdef VOID_HAS_ASYNC
|
#ifdef VOID_HAS_ASYNC
|
||||||
<< " " << opt("--parallel <n>")
|
<< " " << opt("--parallel <n>")
|
||||||
<< apply(dim,
|
<< Void::Testing::Detail::Color::apply(dim,
|
||||||
"Run tests across n threads (no crash detection)")
|
"Run tests across n threads (no crash detection)")
|
||||||
<< "\n"
|
<< "\n"
|
||||||
#endif
|
#endif
|
||||||
<< " " << opt("--verbose")
|
<< " " << opt("--verbose")
|
||||||
<< apply(dim, "Enable verbose output") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Enable verbose output") << "\n"
|
||||||
<< " " << opt("--no-color")
|
<< " " << opt("--no-color")
|
||||||
<< apply(dim, "Disable colored console output") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Disable colored console output") << "\n"
|
||||||
<< " " << opt("--allow-empty")
|
<< " " << opt("--allow-empty")
|
||||||
<< apply(dim, "Do not fail when selection matches zero tests") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Do not fail when selection matches zero tests") << "\n"
|
||||||
<< " " << opt("--help")
|
<< " " << opt("--help")
|
||||||
<< apply(dim, "Show this help message") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Show this help message") << "\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< " " << apply(bold_white, "EXAMPLES:") << "\n"
|
<< " " << Void::Testing::Detail::Color::apply(bold_white, "EXAMPLES:") << "\n"
|
||||||
<< " " << apply(cyan, "./run_tests") << " "
|
<< " " << Void::Testing::Detail::Color::apply(cyan, "./run_tests") << " "
|
||||||
<< apply(yellow, "--filter") << " \"math_tests.*\"" << "\n"
|
<< Void::Testing::Detail::Color::apply(yellow, "--filter") << " \"math_tests.*\"" << "\n"
|
||||||
<< " " << apply(cyan, "./run_tests") << " "
|
<< " " << Void::Testing::Detail::Color::apply(cyan, "./run_tests") << " "
|
||||||
<< apply(yellow, "--tag") << " integration "
|
<< Void::Testing::Detail::Color::apply(yellow, "--tag") << " integration "
|
||||||
<< apply(yellow, "--shuffle") << "\n"
|
<< Void::Testing::Detail::Color::apply(yellow, "--shuffle") << "\n"
|
||||||
<< " " << apply(cyan, "./run_tests") << " "
|
<< " " << Void::Testing::Detail::Color::apply(cyan, "./run_tests") << " "
|
||||||
<< apply(yellow, "--reporter") << " junit "
|
<< Void::Testing::Detail::Color::apply(yellow, "--reporter") << " junit "
|
||||||
<< apply(yellow, "--output") << " results.xml" << "\n"
|
<< Void::Testing::Detail::Color::apply(yellow, "--output") << " results.xml" << "\n"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ if(TARGET VoidTests AND (TARGET Void::System OR TARGET Void::IPC))
|
|||||||
add_executable(VoidProcessHelper
|
add_executable(VoidProcessHelper
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/helpers/ProcessHelper.cpp")
|
"${CMAKE_CURRENT_SOURCE_DIR}/helpers/ProcessHelper.cpp")
|
||||||
set_target_properties(VoidProcessHelper PROPERTIES
|
set_target_properties(VoidProcessHelper PROPERTIES
|
||||||
CXX_STANDARD 26
|
CXX_STANDARD ${CMAKE_CXX_STANDARD}
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
CXX_EXTENSIONS OFF
|
CXX_EXTENSIONS OFF
|
||||||
VOID_TESTING_NO_AUTO_SCAN TRUE)
|
VOID_TESTING_NO_AUTO_SCAN TRUE)
|
||||||
@@ -181,7 +181,7 @@ if(TARGET VoidTests AND TARGET Void::Archive)
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/helpers/ArchiveWorker.cpp")
|
"${CMAKE_CURRENT_SOURCE_DIR}/helpers/ArchiveWorker.cpp")
|
||||||
target_link_libraries(VoidArchiveWorker PRIVATE Void::Archive)
|
target_link_libraries(VoidArchiveWorker PRIVATE Void::Archive)
|
||||||
set_target_properties(VoidArchiveWorker PROPERTIES
|
set_target_properties(VoidArchiveWorker PROPERTIES
|
||||||
CXX_STANDARD 26
|
CXX_STANDARD ${CMAKE_CXX_STANDARD}
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
CXX_EXTENSIONS OFF
|
CXX_EXTENSIONS OFF
|
||||||
VOID_TESTING_NO_AUTO_SCAN TRUE)
|
VOID_TESTING_NO_AUTO_SCAN TRUE)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ Void::Testing::Test request_ledger_replays_exact_repeat()
|
|||||||
auto repeat = ledger.check(k, "op");
|
auto repeat = ledger.check(k, "op");
|
||||||
Void::Testing::expect(repeat.status == Status::replay);
|
Void::Testing::expect(repeat.status == Status::replay);
|
||||||
Void::Testing::require(repeat.result.has_value());
|
Void::Testing::require(repeat.result.has_value());
|
||||||
Void::Testing::expect_eq(*repeat.result, 7);
|
Void::Testing::expect_eq(repeat.result->value(), 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
Void::Testing::Test request_ledger_replays_rejected_outcome()
|
Void::Testing::Test request_ledger_replays_rejected_outcome()
|
||||||
@@ -67,7 +67,7 @@ Void::Testing::Test request_ledger_detects_payload_conflict()
|
|||||||
// The conflicting retry changed nothing.
|
// The conflicting retry changed nothing.
|
||||||
auto repeat = ledger.check(k, "payload-a");
|
auto repeat = ledger.check(k, "payload-a");
|
||||||
Void::Testing::expect(repeat.status == Status::replay);
|
Void::Testing::expect(repeat.status == Status::replay);
|
||||||
Void::Testing::expect_eq(*repeat.result, 10);
|
Void::Testing::expect_eq(repeat.result->value(), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
Void::Testing::Test request_ledger_delayed_retry_after_newer_operations()
|
Void::Testing::Test request_ledger_delayed_retry_after_newer_operations()
|
||||||
@@ -82,7 +82,7 @@ Void::Testing::Test request_ledger_delayed_retry_after_newer_operations()
|
|||||||
|
|
||||||
auto delayed = ledger.check(first, "one");
|
auto delayed = ledger.check(first, "one");
|
||||||
Void::Testing::expect(delayed.status == Status::replay);
|
Void::Testing::expect(delayed.status == Status::replay);
|
||||||
Void::Testing::expect_eq(*delayed.result, 100);
|
Void::Testing::expect_eq(delayed.result->value(), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
Void::Testing::Test request_ledger_epoch_rollover()
|
Void::Testing::Test request_ledger_epoch_rollover()
|
||||||
@@ -136,7 +136,7 @@ Void::Testing::Test request_ledger_in_progress_and_result_is_immutable()
|
|||||||
Void::Testing::expect(!ledger.record(k, 6));
|
Void::Testing::expect(!ledger.record(k, 6));
|
||||||
auto repeat = ledger.check(k, "op");
|
auto repeat = ledger.check(k, "op");
|
||||||
Void::Testing::expect(repeat.status == Status::replay);
|
Void::Testing::expect(repeat.status == Status::replay);
|
||||||
Void::Testing::expect_eq(*repeat.result, 5);
|
Void::Testing::expect_eq(repeat.result->value(), 5);
|
||||||
|
|
||||||
const auto snap = ledger.snapshot();
|
const auto snap = ledger.snapshot();
|
||||||
Void::Testing::expect_eq(snap.size, std::size_t{1});
|
Void::Testing::expect_eq(snap.size, std::size_t{1});
|
||||||
|
|||||||
Reference in new issue
Block a user