Merge branch 'master' into fs_QuadricEdgeCollapse
This commit is contained in:
commit
c53c958cdd
10 changed files with 25614 additions and 188 deletions
190
build_win.bat
Normal file
190
build_win.bat
Normal file
|
@ -0,0 +1,190 @@
|
||||||
|
@setlocal disableDelayedExpansion enableExtensions
|
||||||
|
@echo off
|
||||||
|
GOTO :MAIN
|
||||||
|
:HELP
|
||||||
|
@ECHO Performs initial build or rebuild of the app (build) and deps (build/deps).
|
||||||
|
@ECHO Default options are determined from build directories and system state.
|
||||||
|
@ECHO.
|
||||||
|
@ECHO Usage: build_win [-ARCH ^<arch^>] [-CONFIG ^<config^>] [-DESTDIR ^<directory^>]
|
||||||
|
@ECHO [-STEPS ^<all^|all-dirty^|app^|app-dirty^|deps^|deps-dirty^>]
|
||||||
|
@ECHO.
|
||||||
|
@ECHO -a -ARCH Target processor architecture
|
||||||
|
@ECHO Default: %PS_ARCH_HOST%
|
||||||
|
@ECHO -c -CONFIG MSVC project config
|
||||||
|
@ECHO Default: %PS_CONFIG_DEFAULT%
|
||||||
|
@ECHO -s -STEPS Performs only the specified build steps:
|
||||||
|
@ECHO all - clean and build deps and app
|
||||||
|
@ECHO all-dirty - build deps and app without cleaning
|
||||||
|
@ECHO app - build main project/application
|
||||||
|
@ECHO app-dirty - does not build main project/application
|
||||||
|
@ECHO deps - clean and build deps
|
||||||
|
@ECHO deps-dirty - build deps without cleaning
|
||||||
|
@ECHO Default: %PS_STEPS_DEFAULT%
|
||||||
|
@ECHO -d -DESTDIR Deps destination directory
|
||||||
|
@ECHO %PS_DESTDIR_DEFAULT_MSG%
|
||||||
|
@ECHO.
|
||||||
|
@ECHO Example usage:
|
||||||
|
@ECHO First build: build_win -d "c:\src\PrusaSlicer-deps"
|
||||||
|
@ECHO Deps change: build_win -s all
|
||||||
|
@ECHO App rebuild: build_win
|
||||||
|
GOTO :END
|
||||||
|
|
||||||
|
:MAIN
|
||||||
|
SET START_TIME=%TIME%
|
||||||
|
pushd %~dp0
|
||||||
|
REM Probe build directories and sytem state for reasonable default arguments
|
||||||
|
SET PS_CONFIG=RelWithDebInfo
|
||||||
|
SET PS_ARCH=%PROCESSOR_ARCHITECTURE%
|
||||||
|
CALL :TOLOWER PS_ARCH
|
||||||
|
SET DEPS_PATH_FILE=%~dp0deps\build\.DEPS_PATH.txt
|
||||||
|
SET PS_DESTDIR=
|
||||||
|
IF EXIST %DEPS_PATH_FILE% (
|
||||||
|
FOR /F "tokens=* USEBACKQ" %%I IN ("%DEPS_PATH_FILE%") DO SET PS_DESTDIR=%%I
|
||||||
|
IF EXIST build/ALL_BUILD.vcxproj (
|
||||||
|
SET PS_STEPS=app-dirty
|
||||||
|
) ELSE SET PS_STEPS=app
|
||||||
|
) ELSE SET PS_STEPS=all
|
||||||
|
|
||||||
|
REM Set up parameters used by help menu
|
||||||
|
SET PS_CONFIG_DEFAULT=%PS_CONFIG%
|
||||||
|
SET PS_ARCH_HOST=%PS_ARCH%
|
||||||
|
SET PS_STEPS_DEFAULT=%PS_STEPS%
|
||||||
|
IF "%PS_DESTDIR%" NEQ "" (
|
||||||
|
SET PS_DESTDIR_DEFAULT_MSG=Default: %PS_DESTDIR%
|
||||||
|
) ELSE (
|
||||||
|
SET PS_DESTDIR_DEFAULT_MSG=Argument required ^(no default available^)
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Parse arguments
|
||||||
|
SET EXIT_STATUS=1
|
||||||
|
SET PARSER_STATE=
|
||||||
|
SET PARSER_FAIL=
|
||||||
|
FOR %%I in (%*) DO CALL :PARSE_OPTION "ARCH CONFIG DESTDIR STEPS" PARSER_STATE "%%~I"
|
||||||
|
IF "%PARSER_FAIL%%PARSER_STATE%" NEQ "" GOTO :HELP
|
||||||
|
|
||||||
|
REM Validate arguments
|
||||||
|
CALL :PARSE_OPTION_NAME "all all-dirty deps-dirty deps app-dirty app" PS_STEPS -%PS_STEPS%
|
||||||
|
IF "%PS_STEPS%" EQU "" GOTO :HELP
|
||||||
|
(echo %PS_STEPS%)| findstr /I /C:"dirty">nul && SET PS_STEPS_DIRTY=1
|
||||||
|
CALL :TOLOWER PS_STEPS
|
||||||
|
CALL :TOLOWER PS_ARCH
|
||||||
|
IF "%OPTION_NAME%" NEQ "" GOTO :HELP
|
||||||
|
IF "%PS_STEPS_DIRTY%%PS_DESTDIR%" EQU "" GOTO :HELP
|
||||||
|
|
||||||
|
REM Set up MSVC environment
|
||||||
|
SET EXIT_STATUS=2
|
||||||
|
@ECHO **********************************************************************
|
||||||
|
@ECHO ** Build Config: %PS_CONFIG%
|
||||||
|
@ECHO ** Target Arch: %PS_ARCH%
|
||||||
|
@ECHO ** Build Steps: %PS_STEPS%
|
||||||
|
@ECHO ** Using Microsoft Visual Studio installation found at:
|
||||||
|
SET VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||||
|
IF NOT EXIST %VSWHERE% SET VSWHERE="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||||
|
FOR /F "tokens=* USEBACKQ" %%I IN (`%VSWHERE% -nologo -property installationPath`) DO SET MSVC_DIR=%%I
|
||||||
|
@ECHO ** %MSVC_DIR%
|
||||||
|
CALL "%MSVC_DIR%\Common7\Tools\vsdevcmd.bat" -arch=%PS_ARCH% -host_arch=%PS_ARCH_HOST% -app_platform=Desktop || GOTO :END
|
||||||
|
IF /I "%PS_STEPS:~0,3%" EQU "app" GOTO :BUILD_APP
|
||||||
|
|
||||||
|
REM Build deps
|
||||||
|
:BUILD_DEPS
|
||||||
|
SET EXIT_STATUS=3
|
||||||
|
IF "%PS_STEPS_DIRTY%" EQU "" CALL :MAKE_OR_CLEAN_DIRECTORY deps\build
|
||||||
|
cd deps\build || GOTO :END
|
||||||
|
IF "%PS_STEPS_DIRTY%" EQU "" cmake.exe .. -DDESTDIR="%PS_DESTDIR%" || GOTO :END
|
||||||
|
(echo %PS_DESTDIR%)> "%DEPS_PATH_FILE%"
|
||||||
|
msbuild /m ALL_BUILD.vcxproj /p:Configuration=%PS_CONFIG% || GOTO :END
|
||||||
|
cd ..\..
|
||||||
|
IF /I "%PS_STEPS:~0,4%" EQU "deps" GOTO :PROLOGUE
|
||||||
|
|
||||||
|
REM Build app
|
||||||
|
:BUILD_APP
|
||||||
|
SET EXIT_STATUS=4
|
||||||
|
IF "%PS_STEPS_DIRTY%" EQU "" CALL :MAKE_OR_CLEAN_DIRECTORY build
|
||||||
|
cd build || GOTO :END
|
||||||
|
IF "%PS_STEPS_DIRTY%" EQU "" cmake.exe .. -DCMAKE_PREFIX_PATH="%PS_DESTDIR%\usr\local" || GOTO :END
|
||||||
|
msbuild /m ALL_BUILD.vcxproj /p:Configuration=%PS_CONFIG% || GOTO :END
|
||||||
|
|
||||||
|
:PROLOGUE
|
||||||
|
SET EXIT_STATUS=%ERRORLEVEL%
|
||||||
|
:END
|
||||||
|
@ECHO Script started at %START_TIME% and completed at %TIME%.
|
||||||
|
popd
|
||||||
|
endlocal
|
||||||
|
exit /B %EXIT_STATUS%
|
||||||
|
|
||||||
|
GOTO :EOF
|
||||||
|
REM Functions and stubs start here.
|
||||||
|
|
||||||
|
:PARSE_OPTION
|
||||||
|
REM Argument parser called for each argument
|
||||||
|
REM %1 - Valid option list
|
||||||
|
REM %2 - Variable name for parser state; must be unset when parsing finished
|
||||||
|
REM %3 - Current argument value
|
||||||
|
REM PARSER_FAIL will be set on an error
|
||||||
|
REM Note: Must avoid delayed expansion since filenames may contain ! character
|
||||||
|
setlocal disableDelayedExpansion
|
||||||
|
CALL SET LAST_ARG=%%%2%%
|
||||||
|
IF "%LAST_ARG%" EQU "" (
|
||||||
|
CALL :PARSE_OPTION_NAME %1 %~2 %~3 1
|
||||||
|
SET ARG_TYPE=NAME
|
||||||
|
) ELSE (
|
||||||
|
SET PS_SET_COMMAND=^&SET PS_%LAST_ARG%=%~3
|
||||||
|
SET ARG_TYPE=LAST_ARG
|
||||||
|
SET %~2=
|
||||||
|
)
|
||||||
|
CALL SET LAST_ARG=%%%2%%
|
||||||
|
IF "%LAST_ARG%" EQU "" IF "%ARG_TYPE%" EQU "NAME" SET PARSER_FAIL=1
|
||||||
|
endlocal & (SET PARSER_FAIL=%PARSER_FAIL%) & (SET %~2=%LAST_ARG%) %PS_SET_COMMAND%
|
||||||
|
GOTO :EOF
|
||||||
|
|
||||||
|
:PARSE_OPTION_NAME
|
||||||
|
REM Parses an option name
|
||||||
|
REM %1 - Valid option list
|
||||||
|
REM %2 - Out variable name; unset on error
|
||||||
|
REM %3 - Current argument value
|
||||||
|
REM $4 - Boolean indicating single character switches are valid
|
||||||
|
REM Note: Delayed expansion safe because ! character is invalid in option name
|
||||||
|
setlocal enableDelayedExpansion
|
||||||
|
IF "%4" NEQ "" FOR %%I IN (%~1) DO (
|
||||||
|
SET SHORT_NAME=%%~I
|
||||||
|
SET SHORT_ARG_!SHORT_NAME:~0,1!=%%~I
|
||||||
|
)
|
||||||
|
SET OPTION_NAME=%~3
|
||||||
|
(echo %OPTION_NAME%)| findstr /R /C:"[-/]..*">nul || GOTO :PARSE_OPTION_NAME_FAIL
|
||||||
|
SET OPTION_NAME=%OPTION_NAME:~1%
|
||||||
|
IF "%4" NEQ "" (
|
||||||
|
IF "%OPTION_NAME%" EQU "%OPTION_NAME:~0,1%" (
|
||||||
|
IF "!SHORT_ARG_%OPTION_NAME:~0,1%!" NEQ "" SET OPTION_NAME=!SHORT_ARG_%OPTION_NAME:~0,1%!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(echo %OPTION_NAME%)| findstr /R /C:".[ ][ ]*.">nul && GOTO :PARSE_OPTION_NAME_FAIL
|
||||||
|
(echo %~1 )| findstr /I /C:" %OPTION_NAME% ">nul || GOTO :PARSE_OPTION_NAME_FAIL
|
||||||
|
endlocal & SET %~2=%OPTION_NAME%
|
||||||
|
GOTO :EOF
|
||||||
|
:PARSE_OPTION_NAME_FAIL
|
||||||
|
endlocal & SET %~2=
|
||||||
|
GOTO :EOF
|
||||||
|
|
||||||
|
:MAKE_OR_CLEAN_DIRECTORY
|
||||||
|
REM Create directory if it doesn't exist or clean it if it does
|
||||||
|
REM %1 - Directory path to clean or create
|
||||||
|
setlocal disableDelayedExpansion
|
||||||
|
IF NOT EXIST "%~1" (
|
||||||
|
ECHO Creating %~1
|
||||||
|
mkdir "%~1" && GOTO :EOF
|
||||||
|
)
|
||||||
|
ECHO Cleaning %~1 ...
|
||||||
|
for /F "usebackq delims=" %%I in (`dir /a /b "%~1"`) do (
|
||||||
|
(rmdir /s /q "%~1\%%I" 2>nul ) || del /q /f "%~1\%%I")
|
||||||
|
GOTO :EOF
|
||||||
|
|
||||||
|
:TOLOWER
|
||||||
|
REM Converts supplied environment variable to lowercase
|
||||||
|
REM %1 - Input/output variable name
|
||||||
|
REM Note: This is slow on very long strings, but is used only on very short ones
|
||||||
|
setlocal disableDelayedExpansion
|
||||||
|
FOR %%b IN (a b c d e f g h i j k l m n o p q r s t u v w x y z) DO CALL set %~1=%%%1:%%b=%%b%%
|
||||||
|
CALL SET OUTPUT=%%%~1%%
|
||||||
|
endlocal & SET %~1=%OUTPUT%
|
||||||
|
GOTO :EOF
|
||||||
|
|
|
@ -154,7 +154,7 @@ Then `cd` into the `deps` directory and use these commands to build:
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake .. -G "Visual Studio 12 Win64" -DDESTDIR="C:\local\destdir-custom"
|
cmake .. -G "Visual Studio 16 2019" -DDESTDIR="C:\local\destdir-custom"
|
||||||
msbuild /m ALL_BUILD.vcxproj
|
msbuild /m ALL_BUILD.vcxproj
|
||||||
|
|
||||||
You can also use the Visual Studio GUI or other generators as mentioned above.
|
You can also use the Visual Studio GUI or other generators as mentioned above.
|
||||||
|
|
BIN
resources/localization/ko_KR/PrusaSlicer.mo
Normal file
BIN
resources/localization/ko_KR/PrusaSlicer.mo
Normal file
Binary file not shown.
12568
resources/localization/ko_KR/PrusaSlicer_ko.po
Normal file
12568
resources/localization/ko_KR/PrusaSlicer_ko.po
Normal file
File diff suppressed because it is too large
Load diff
BIN
resources/localization/ko_KR/PrusaSlicer_ko_KR.mo
Normal file
BIN
resources/localization/ko_KR/PrusaSlicer_ko_KR.mo
Normal file
Binary file not shown.
12568
resources/localization/ko_KR/PrusaSlicer_ko_KR.po
Normal file
12568
resources/localization/ko_KR/PrusaSlicer_ko_KR.po
Normal file
File diff suppressed because it is too large
Load diff
|
@ -8,6 +8,8 @@
|
||||||
#include "slic3r/GUI/GUI.hpp"
|
#include "slic3r/GUI/GUI.hpp"
|
||||||
#include "slic3r/GUI/GUI_App.hpp"
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
|
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
|
||||||
|
#include "slic3r/GUI/NotificationManager.hpp"
|
||||||
|
#include "slic3r/GUI/format.hpp"
|
||||||
|
|
||||||
#include "libnest2d/common.hpp"
|
#include "libnest2d/common.hpp"
|
||||||
|
|
||||||
|
@ -67,6 +69,7 @@ void ArrangeJob::clear_input()
|
||||||
m_selected.clear();
|
m_selected.clear();
|
||||||
m_unselected.clear();
|
m_unselected.clear();
|
||||||
m_unprintable.clear();
|
m_unprintable.clear();
|
||||||
|
m_unarranged.clear();
|
||||||
m_selected.reserve(count + 1 /* for optional wti */);
|
m_selected.reserve(count + 1 /* for optional wti */);
|
||||||
m_unselected.reserve(count + 1 /* for optional wti */);
|
m_unselected.reserve(count + 1 /* for optional wti */);
|
||||||
m_unprintable.reserve(cunprint /* for optional wti */);
|
m_unprintable.reserve(cunprint /* for optional wti */);
|
||||||
|
@ -78,7 +81,7 @@ void ArrangeJob::prepare_all() {
|
||||||
for (ModelObject *obj: m_plater->model().objects)
|
for (ModelObject *obj: m_plater->model().objects)
|
||||||
for (ModelInstance *mi : obj->instances) {
|
for (ModelInstance *mi : obj->instances) {
|
||||||
ArrangePolygons & cont = mi->printable ? m_selected : m_unprintable;
|
ArrangePolygons & cont = mi->printable ? m_selected : m_unprintable;
|
||||||
cont.emplace_back(get_arrange_poly(mi, m_plater));
|
cont.emplace_back(get_arrange_poly_(mi));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto wti = get_wipe_tower_arrangepoly(*m_plater))
|
if (auto wti = get_wipe_tower_arrangepoly(*m_plater))
|
||||||
|
@ -110,8 +113,8 @@ void ArrangeJob::prepare_selected() {
|
||||||
inst_sel[size_t(inst_id)] = true;
|
inst_sel[size_t(inst_id)] = true;
|
||||||
|
|
||||||
for (size_t i = 0; i < inst_sel.size(); ++i) {
|
for (size_t i = 0; i < inst_sel.size(); ++i) {
|
||||||
ArrangePolygon &&ap =
|
ModelInstance * mi = mo->instances[i];
|
||||||
get_arrange_poly(mo->instances[i], m_plater);
|
ArrangePolygon &&ap = get_arrange_poly_(mi);
|
||||||
|
|
||||||
ArrangePolygons &cont = mo->instances[i]->printable ?
|
ArrangePolygons &cont = mo->instances[i]->printable ?
|
||||||
(inst_sel[i] ? m_selected :
|
(inst_sel[i] ? m_selected :
|
||||||
|
@ -139,6 +142,20 @@ void ArrangeJob::prepare_selected() {
|
||||||
for (auto &p : m_unselected) p.translation(X) -= p.bed_idx * stride;
|
for (auto &p : m_unselected) p.translation(X) -= p.bed_idx * stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arrangement::ArrangePolygon ArrangeJob::get_arrange_poly_(ModelInstance *mi)
|
||||||
|
{
|
||||||
|
arrangement::ArrangePolygon ap = get_arrange_poly(mi, m_plater);
|
||||||
|
|
||||||
|
auto setter = ap.setter;
|
||||||
|
ap.setter = [this, setter, mi](const arrangement::ArrangePolygon &set_ap) {
|
||||||
|
setter(set_ap);
|
||||||
|
if (!set_ap.is_arranged())
|
||||||
|
m_unarranged.emplace_back(mi);
|
||||||
|
};
|
||||||
|
|
||||||
|
return ap;
|
||||||
|
}
|
||||||
|
|
||||||
void ArrangeJob::prepare()
|
void ArrangeJob::prepare()
|
||||||
{
|
{
|
||||||
wxGetKeyState(WXK_SHIFT) ? prepare_selected() : prepare_all();
|
wxGetKeyState(WXK_SHIFT) ? prepare_selected() : prepare_all();
|
||||||
|
@ -187,6 +204,16 @@ void ArrangeJob::process()
|
||||||
: _(L("Arranging done.")));
|
: _(L("Arranging done.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string concat_strings(const std::set<std::string> &strings,
|
||||||
|
const std::string &delim = "\n")
|
||||||
|
{
|
||||||
|
return std::accumulate(
|
||||||
|
strings.begin(), strings.end(), std::string(""),
|
||||||
|
[delim](const std::string &s, const std::string &name) {
|
||||||
|
return s + name + delim;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ArrangeJob::finalize() {
|
void ArrangeJob::finalize() {
|
||||||
// Ignore the arrange result if aborted.
|
// Ignore the arrange result if aborted.
|
||||||
if (was_canceled()) return;
|
if (was_canceled()) return;
|
||||||
|
@ -213,6 +240,16 @@ void ArrangeJob::finalize() {
|
||||||
m_plater->update();
|
m_plater->update();
|
||||||
wxGetApp().obj_manipul()->set_dirty();
|
wxGetApp().obj_manipul()->set_dirty();
|
||||||
|
|
||||||
|
if (!m_unarranged.empty()) {
|
||||||
|
std::set<std::string> names;
|
||||||
|
for (ModelInstance *mi : m_unarranged)
|
||||||
|
names.insert(mi->get_object()->name);
|
||||||
|
|
||||||
|
m_plater->get_notification_manager()->push_notification(GUI::format(
|
||||||
|
_L("Arrangement ignored the following objects which can't fit into a single bed:\n%s"),
|
||||||
|
concat_strings(names, "\n")));
|
||||||
|
}
|
||||||
|
|
||||||
Job::finalize();
|
Job::finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ class ArrangeJob : public PlaterJob
|
||||||
using ArrangePolygons = arrangement::ArrangePolygons;
|
using ArrangePolygons = arrangement::ArrangePolygons;
|
||||||
|
|
||||||
ArrangePolygons m_selected, m_unselected, m_unprintable;
|
ArrangePolygons m_selected, m_unselected, m_unprintable;
|
||||||
|
std::vector<ModelInstance*> m_unarranged;
|
||||||
|
|
||||||
// clear m_selected and m_unselected, reserve space for next usage
|
// clear m_selected and m_unselected, reserve space for next usage
|
||||||
void clear_input();
|
void clear_input();
|
||||||
|
@ -27,6 +28,8 @@ class ArrangeJob : public PlaterJob
|
||||||
// selected, behaves as if everything would be selected.
|
// selected, behaves as if everything would be selected.
|
||||||
void prepare_selected();
|
void prepare_selected();
|
||||||
|
|
||||||
|
ArrangePolygon get_arrange_poly_(ModelInstance *mi);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
|
|
@ -2323,10 +2323,10 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||||
|
|
||||||
preset_bundle->update_compatible(PresetSelectCompatibleType::Never);
|
preset_bundle->update_compatible(PresetSelectCompatibleType::Never);
|
||||||
|
|
||||||
// show notification about temporary instaled presets
|
// show notification about temporarily installed presets
|
||||||
if (!names.empty()) {
|
if (!names.empty()) {
|
||||||
std::string notif_text = into_u8(_L_PLURAL("The preset below was temporary instaled on active instance of PrusaSlicer",
|
std::string notif_text = into_u8(_L_PLURAL("The preset below was temporarily installed on active instance of PrusaSlicer",
|
||||||
"The presets below were temporary instaled on active instance of PrusaSlicer", names.size())) + ":";
|
"The presets below were temporarily installed on active instance of PrusaSlicer", names.size())) + ":";
|
||||||
for (std::string& name : names)
|
for (std::string& name : names)
|
||||||
notif_text += "\n - " + name;
|
notif_text += "\n - " + name;
|
||||||
notification_manager->push_notification(NotificationType::CustomNotification,
|
notification_manager->push_notification(NotificationType::CustomNotification,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* Catch v2.13.3
|
* Catch v2.13.6
|
||||||
* Generated: 2020-10-31 18:20:31.045274
|
* Generated: 2021-04-16 18:23:38.044268
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2021 Two Blue Cubes Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#define CATCH_VERSION_MAJOR 2
|
#define CATCH_VERSION_MAJOR 2
|
||||||
#define CATCH_VERSION_MINOR 13
|
#define CATCH_VERSION_MINOR 13
|
||||||
#define CATCH_VERSION_PATCH 3
|
#define CATCH_VERSION_PATCH 6
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
# pragma clang system_header
|
# pragma clang system_header
|
||||||
|
@ -66,13 +66,16 @@
|
||||||
#if !defined(CATCH_CONFIG_IMPL_ONLY)
|
#if !defined(CATCH_CONFIG_IMPL_ONLY)
|
||||||
// start catch_platform.h
|
// start catch_platform.h
|
||||||
|
|
||||||
|
// See e.g.:
|
||||||
|
// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
# include <TargetConditionals.h>
|
# include <TargetConditionals.h>
|
||||||
# if TARGET_OS_OSX == 1
|
# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \
|
||||||
# define CATCH_PLATFORM_MAC
|
(defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1)
|
||||||
# elif TARGET_OS_IPHONE == 1
|
# define CATCH_PLATFORM_MAC
|
||||||
# define CATCH_PLATFORM_IPHONE
|
# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1)
|
||||||
# endif
|
# define CATCH_PLATFORM_IPHONE
|
||||||
|
# endif
|
||||||
|
|
||||||
#elif defined(linux) || defined(__linux) || defined(__linux__)
|
#elif defined(linux) || defined(__linux) || defined(__linux__)
|
||||||
# define CATCH_PLATFORM_LINUX
|
# define CATCH_PLATFORM_LINUX
|
||||||
|
@ -132,9 +135,9 @@ namespace Catch {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We have to avoid both ICC and Clang, because they try to mask themselves
|
// Only GCC compiler should be used in this block, so other compilers trying to
|
||||||
// as gcc, and we want only GCC in this block
|
// mask themselves as GCC should be ignored.
|
||||||
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__)
|
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__)
|
||||||
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" )
|
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" )
|
||||||
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" )
|
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" )
|
||||||
|
|
||||||
|
@ -7054,8 +7057,8 @@ namespace Catch {
|
||||||
double b2 = bias - z1;
|
double b2 = bias - z1;
|
||||||
double a1 = a(b1);
|
double a1 = a(b1);
|
||||||
double a2 = a(b2);
|
double a2 = a(b2);
|
||||||
auto lo = std::max(cumn(a1), 0);
|
auto lo = (std::max)(cumn(a1), 0);
|
||||||
auto hi = std::min(cumn(a2), n - 1);
|
auto hi = (std::min)(cumn(a2), n - 1);
|
||||||
|
|
||||||
return { point, resample[lo], resample[hi], confidence_level };
|
return { point, resample[lo], resample[hi], confidence_level };
|
||||||
}
|
}
|
||||||
|
@ -7124,7 +7127,9 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
template <typename Clock>
|
template <typename Clock>
|
||||||
EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_cost(FloatDuration<Clock> resolution) {
|
EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_cost(FloatDuration<Clock> resolution) {
|
||||||
auto time_limit = std::min(resolution * clock_cost_estimation_tick_limit, FloatDuration<Clock>(clock_cost_estimation_time_limit));
|
auto time_limit = (std::min)(
|
||||||
|
resolution * clock_cost_estimation_tick_limit,
|
||||||
|
FloatDuration<Clock>(clock_cost_estimation_time_limit));
|
||||||
auto time_clock = [](int k) {
|
auto time_clock = [](int k) {
|
||||||
return Detail::measure<Clock>([k] {
|
return Detail::measure<Clock>([k] {
|
||||||
for (int i = 0; i < k; ++i) {
|
for (int i = 0; i < k; ++i) {
|
||||||
|
@ -7771,7 +7776,7 @@ namespace Catch {
|
||||||
double sb = stddev.point;
|
double sb = stddev.point;
|
||||||
double mn = mean.point / n;
|
double mn = mean.point / n;
|
||||||
double mg_min = mn / 2.;
|
double mg_min = mn / 2.;
|
||||||
double sg = std::min(mg_min / 4., sb / std::sqrt(n));
|
double sg = (std::min)(mg_min / 4., sb / std::sqrt(n));
|
||||||
double sg2 = sg * sg;
|
double sg2 = sg * sg;
|
||||||
double sb2 = sb * sb;
|
double sb2 = sb * sb;
|
||||||
|
|
||||||
|
@ -7790,7 +7795,7 @@ namespace Catch {
|
||||||
return (nc / n) * (sb2 - nc * sg2);
|
return (nc / n) * (sb2 - nc * sg2);
|
||||||
};
|
};
|
||||||
|
|
||||||
return std::min(var_out(1), var_out(std::min(c_max(0.), c_max(mg_min)))) / sb2;
|
return (std::min)(var_out(1), var_out((std::min)(c_max(0.), c_max(mg_min)))) / sb2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) {
|
bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) {
|
||||||
|
@ -7980,86 +7985,58 @@ namespace Catch {
|
||||||
|
|
||||||
// start catch_fatal_condition.h
|
// start catch_fatal_condition.h
|
||||||
|
|
||||||
// start catch_windows_h_proxy.h
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
#if defined(CATCH_PLATFORM_WINDOWS)
|
|
||||||
|
|
||||||
#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX)
|
|
||||||
# define CATCH_DEFINED_NOMINMAX
|
|
||||||
# define NOMINMAX
|
|
||||||
#endif
|
|
||||||
#if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN)
|
|
||||||
# define CATCH_DEFINED_WIN32_LEAN_AND_MEAN
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __AFXDLL
|
|
||||||
#include <AfxWin.h>
|
|
||||||
#else
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CATCH_DEFINED_NOMINMAX
|
|
||||||
# undef NOMINMAX
|
|
||||||
#endif
|
|
||||||
#ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN
|
|
||||||
# undef WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // defined(CATCH_PLATFORM_WINDOWS)
|
|
||||||
|
|
||||||
// end catch_windows_h_proxy.h
|
|
||||||
#if defined( CATCH_CONFIG_WINDOWS_SEH )
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct FatalConditionHandler {
|
// Wrapper for platform-specific fatal error (signals/SEH) handlers
|
||||||
|
//
|
||||||
static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo);
|
// Tries to be cooperative with other handlers, and not step over
|
||||||
FatalConditionHandler();
|
// other handlers. This means that unknown structured exceptions
|
||||||
static void reset();
|
// are passed on, previous signal handlers are called, and so on.
|
||||||
~FatalConditionHandler();
|
//
|
||||||
|
// Can only be instantiated once, and assumes that once a signal
|
||||||
private:
|
// is caught, the binary will end up terminating. Thus, there
|
||||||
static bool isSet;
|
class FatalConditionHandler {
|
||||||
static ULONG guaranteeSize;
|
bool m_started = false;
|
||||||
static PVOID exceptionHandlerHandle;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Catch
|
|
||||||
|
|
||||||
#elif defined ( CATCH_CONFIG_POSIX_SIGNALS )
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
struct FatalConditionHandler {
|
|
||||||
|
|
||||||
static bool isSet;
|
|
||||||
static struct sigaction oldSigActions[];
|
|
||||||
static stack_t oldSigStack;
|
|
||||||
static char altStackMem[];
|
|
||||||
|
|
||||||
static void handleSignal( int sig );
|
|
||||||
|
|
||||||
|
// Install/disengage implementation for specific platform.
|
||||||
|
// Should be if-defed to work on current platform, can assume
|
||||||
|
// engage-disengage 1:1 pairing.
|
||||||
|
void engage_platform();
|
||||||
|
void disengage_platform();
|
||||||
|
public:
|
||||||
|
// Should also have platform-specific implementations as needed
|
||||||
FatalConditionHandler();
|
FatalConditionHandler();
|
||||||
~FatalConditionHandler();
|
~FatalConditionHandler();
|
||||||
static void reset();
|
|
||||||
|
void engage() {
|
||||||
|
assert(!m_started && "Handler cannot be installed twice.");
|
||||||
|
m_started = true;
|
||||||
|
engage_platform();
|
||||||
|
}
|
||||||
|
|
||||||
|
void disengage() {
|
||||||
|
assert(m_started && "Handler cannot be uninstalled without being installed first");
|
||||||
|
m_started = false;
|
||||||
|
disengage_platform();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Catch
|
//! Simple RAII guard for (dis)engaging the FatalConditionHandler
|
||||||
|
class FatalConditionHandlerGuard {
|
||||||
#else
|
FatalConditionHandler* m_handler;
|
||||||
|
public:
|
||||||
namespace Catch {
|
FatalConditionHandlerGuard(FatalConditionHandler* handler):
|
||||||
struct FatalConditionHandler {
|
m_handler(handler) {
|
||||||
void reset();
|
m_handler->engage();
|
||||||
|
}
|
||||||
|
~FatalConditionHandlerGuard() {
|
||||||
|
m_handler->disengage();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
} // end namespace Catch
|
||||||
|
|
||||||
// end catch_fatal_condition.h
|
// end catch_fatal_condition.h
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -8185,6 +8162,7 @@ namespace Catch {
|
||||||
std::vector<SectionEndInfo> m_unfinishedSections;
|
std::vector<SectionEndInfo> m_unfinishedSections;
|
||||||
std::vector<ITracker*> m_activeSections;
|
std::vector<ITracker*> m_activeSections;
|
||||||
TrackerContext m_trackerContext;
|
TrackerContext m_trackerContext;
|
||||||
|
FatalConditionHandler m_fatalConditionhandler;
|
||||||
bool m_lastAssertionPassed = false;
|
bool m_lastAssertionPassed = false;
|
||||||
bool m_shouldReportUnexpected = true;
|
bool m_shouldReportUnexpected = true;
|
||||||
bool m_includeSuccessfulResults;
|
bool m_includeSuccessfulResults;
|
||||||
|
@ -10057,6 +10035,36 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
// end catch_errno_guard.h
|
// end catch_errno_guard.h
|
||||||
|
// start catch_windows_h_proxy.h
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CATCH_PLATFORM_WINDOWS)
|
||||||
|
|
||||||
|
#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX)
|
||||||
|
# define CATCH_DEFINED_NOMINMAX
|
||||||
|
# define NOMINMAX
|
||||||
|
#endif
|
||||||
|
#if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN)
|
||||||
|
# define CATCH_DEFINED_WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __AFXDLL
|
||||||
|
#include <AfxWin.h>
|
||||||
|
#else
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CATCH_DEFINED_NOMINMAX
|
||||||
|
# undef NOMINMAX
|
||||||
|
#endif
|
||||||
|
#ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN
|
||||||
|
# undef WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // defined(CATCH_PLATFORM_WINDOWS)
|
||||||
|
|
||||||
|
// end catch_windows_h_proxy.h
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
@ -10573,7 +10581,7 @@ namespace Catch {
|
||||||
// Extracts the actual name part of an enum instance
|
// Extracts the actual name part of an enum instance
|
||||||
// In other words, it returns the Blue part of Bikeshed::Colour::Blue
|
// In other words, it returns the Blue part of Bikeshed::Colour::Blue
|
||||||
StringRef extractInstanceName(StringRef enumInstance) {
|
StringRef extractInstanceName(StringRef enumInstance) {
|
||||||
// Find last occurence of ":"
|
// Find last occurrence of ":"
|
||||||
size_t name_start = enumInstance.size();
|
size_t name_start = enumInstance.size();
|
||||||
while (name_start > 0 && enumInstance[name_start - 1] != ':') {
|
while (name_start > 0 && enumInstance[name_start - 1] != ':') {
|
||||||
--name_start;
|
--name_start;
|
||||||
|
@ -10735,25 +10743,47 @@ namespace Catch {
|
||||||
// end catch_exception_translator_registry.cpp
|
// end catch_exception_translator_registry.cpp
|
||||||
// start catch_fatal_condition.cpp
|
// start catch_fatal_condition.cpp
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#include <algorithm>
|
||||||
# pragma GCC diagnostic push
|
|
||||||
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
#if !defined( CATCH_CONFIG_WINDOWS_SEH ) && !defined( CATCH_CONFIG_POSIX_SIGNALS )
|
||||||
#endif
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
// If neither SEH nor signal handling is required, the handler impls
|
||||||
|
// do not have to do anything, and can be empty.
|
||||||
|
void FatalConditionHandler::engage_platform() {}
|
||||||
|
void FatalConditionHandler::disengage_platform() {}
|
||||||
|
FatalConditionHandler::FatalConditionHandler() = default;
|
||||||
|
FatalConditionHandler::~FatalConditionHandler() = default;
|
||||||
|
|
||||||
|
} // end namespace Catch
|
||||||
|
|
||||||
|
#endif // !CATCH_CONFIG_WINDOWS_SEH && !CATCH_CONFIG_POSIX_SIGNALS
|
||||||
|
|
||||||
|
#if defined( CATCH_CONFIG_WINDOWS_SEH ) && defined( CATCH_CONFIG_POSIX_SIGNALS )
|
||||||
|
#error "Inconsistent configuration: Windows' SEH handling and POSIX signals cannot be enabled at the same time"
|
||||||
|
#endif // CATCH_CONFIG_WINDOWS_SEH && CATCH_CONFIG_POSIX_SIGNALS
|
||||||
|
|
||||||
#if defined( CATCH_CONFIG_WINDOWS_SEH ) || defined( CATCH_CONFIG_POSIX_SIGNALS )
|
#if defined( CATCH_CONFIG_WINDOWS_SEH ) || defined( CATCH_CONFIG_POSIX_SIGNALS )
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Report the error condition
|
//! Signals fatal error message to the run context
|
||||||
void reportFatal( char const * const message ) {
|
void reportFatal( char const * const message ) {
|
||||||
Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message );
|
Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif // signals/SEH handling
|
//! Minimal size Catch2 needs for its own fatal error handling.
|
||||||
|
//! Picked anecdotally, so it might not be sufficient on all
|
||||||
|
//! platforms, and for all configurations.
|
||||||
|
constexpr std::size_t minStackSizeForErrors = 32 * 1024;
|
||||||
|
} // end unnamed namespace
|
||||||
|
|
||||||
|
#endif // CATCH_CONFIG_WINDOWS_SEH || CATCH_CONFIG_POSIX_SIGNALS
|
||||||
|
|
||||||
#if defined( CATCH_CONFIG_WINDOWS_SEH )
|
#if defined( CATCH_CONFIG_WINDOWS_SEH )
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct SignalDefs { DWORD id; const char* name; };
|
struct SignalDefs { DWORD id; const char* name; };
|
||||||
|
|
||||||
// There is no 1-1 mapping between signals and windows exceptions.
|
// There is no 1-1 mapping between signals and windows exceptions.
|
||||||
|
@ -10766,7 +10796,7 @@ namespace Catch {
|
||||||
{ static_cast<DWORD>(EXCEPTION_INT_DIVIDE_BY_ZERO), "Divide by zero error" },
|
{ static_cast<DWORD>(EXCEPTION_INT_DIVIDE_BY_ZERO), "Divide by zero error" },
|
||||||
};
|
};
|
||||||
|
|
||||||
LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
|
static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
|
||||||
for (auto const& def : signalDefs) {
|
for (auto const& def : signalDefs) {
|
||||||
if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) {
|
if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) {
|
||||||
reportFatal(def.name);
|
reportFatal(def.name);
|
||||||
|
@ -10777,38 +10807,50 @@ namespace Catch {
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
FatalConditionHandler::FatalConditionHandler() {
|
// Since we do not support multiple instantiations, we put these
|
||||||
isSet = true;
|
// into global variables and rely on cleaning them up in outlined
|
||||||
// 32k seems enough for Catch to handle stack overflow,
|
// constructors/destructors
|
||||||
// but the value was found experimentally, so there is no strong guarantee
|
static PVOID exceptionHandlerHandle = nullptr;
|
||||||
guaranteeSize = 32 * 1024;
|
|
||||||
exceptionHandlerHandle = nullptr;
|
|
||||||
// Register as first handler in current chain
|
|
||||||
exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException);
|
|
||||||
// Pass in guarantee size to be filled
|
|
||||||
SetThreadStackGuarantee(&guaranteeSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FatalConditionHandler::reset() {
|
// For MSVC, we reserve part of the stack memory for handling
|
||||||
if (isSet) {
|
// memory overflow structured exception.
|
||||||
RemoveVectoredExceptionHandler(exceptionHandlerHandle);
|
FatalConditionHandler::FatalConditionHandler() {
|
||||||
SetThreadStackGuarantee(&guaranteeSize);
|
ULONG guaranteeSize = static_cast<ULONG>(minStackSizeForErrors);
|
||||||
exceptionHandlerHandle = nullptr;
|
if (!SetThreadStackGuarantee(&guaranteeSize)) {
|
||||||
isSet = false;
|
// We do not want to fully error out, because needing
|
||||||
|
// the stack reserve should be rare enough anyway.
|
||||||
|
Catch::cerr()
|
||||||
|
<< "Failed to reserve piece of stack."
|
||||||
|
<< " Stack overflows will not be reported successfully.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FatalConditionHandler::~FatalConditionHandler() {
|
// We do not attempt to unset the stack guarantee, because
|
||||||
reset();
|
// Windows does not support lowering the stack size guarantee.
|
||||||
|
FatalConditionHandler::~FatalConditionHandler() = default;
|
||||||
|
|
||||||
|
void FatalConditionHandler::engage_platform() {
|
||||||
|
// Register as first handler in current chain
|
||||||
|
exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException);
|
||||||
|
if (!exceptionHandlerHandle) {
|
||||||
|
CATCH_RUNTIME_ERROR("Could not register vectored exception handler");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FatalConditionHandler::isSet = false;
|
void FatalConditionHandler::disengage_platform() {
|
||||||
ULONG FatalConditionHandler::guaranteeSize = 0;
|
if (!RemoveVectoredExceptionHandler(exceptionHandlerHandle)) {
|
||||||
PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr;
|
CATCH_RUNTIME_ERROR("Could not unregister vectored exception handler");
|
||||||
|
}
|
||||||
|
exceptionHandlerHandle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#elif defined( CATCH_CONFIG_POSIX_SIGNALS )
|
#endif // CATCH_CONFIG_WINDOWS_SEH
|
||||||
|
|
||||||
|
#if defined( CATCH_CONFIG_POSIX_SIGNALS )
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
@ -10817,10 +10859,6 @@ namespace Catch {
|
||||||
const char* name;
|
const char* name;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 32kb for the alternate stack seems to be sufficient. However, this value
|
|
||||||
// is experimentally determined, so that's not guaranteed.
|
|
||||||
static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
|
|
||||||
|
|
||||||
static SignalDefs signalDefs[] = {
|
static SignalDefs signalDefs[] = {
|
||||||
{ SIGINT, "SIGINT - Terminal interrupt signal" },
|
{ SIGINT, "SIGINT - Terminal interrupt signal" },
|
||||||
{ SIGILL, "SIGILL - Illegal instruction signal" },
|
{ SIGILL, "SIGILL - Illegal instruction signal" },
|
||||||
|
@ -10830,7 +10868,32 @@ namespace Catch {
|
||||||
{ SIGABRT, "SIGABRT - Abort (abnormal termination) signal" }
|
{ SIGABRT, "SIGABRT - Abort (abnormal termination) signal" }
|
||||||
};
|
};
|
||||||
|
|
||||||
void FatalConditionHandler::handleSignal( int sig ) {
|
// Older GCCs trigger -Wmissing-field-initializers for T foo = {}
|
||||||
|
// which is zero initialization, but not explicit. We want to avoid
|
||||||
|
// that.
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static char* altStackMem = nullptr;
|
||||||
|
static std::size_t altStackSize = 0;
|
||||||
|
static stack_t oldSigStack{};
|
||||||
|
static struct sigaction oldSigActions[sizeof(signalDefs) / sizeof(SignalDefs)]{};
|
||||||
|
|
||||||
|
static void restorePreviousSignalHandlers() {
|
||||||
|
// We set signal handlers back to the previous ones. Hopefully
|
||||||
|
// nobody overwrote them in the meantime, and doesn't expect
|
||||||
|
// their signal handlers to live past ours given that they
|
||||||
|
// installed them after ours..
|
||||||
|
for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
|
||||||
|
sigaction(signalDefs[i].id, &oldSigActions[i], nullptr);
|
||||||
|
}
|
||||||
|
// Return the old stack
|
||||||
|
sigaltstack(&oldSigStack, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleSignal( int sig ) {
|
||||||
char const * name = "<unknown signal>";
|
char const * name = "<unknown signal>";
|
||||||
for (auto const& def : signalDefs) {
|
for (auto const& def : signalDefs) {
|
||||||
if (sig == def.id) {
|
if (sig == def.id) {
|
||||||
|
@ -10838,16 +10901,33 @@ namespace Catch {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reset();
|
// We need to restore previous signal handlers and let them do
|
||||||
reportFatal(name);
|
// their thing, so that the users can have the debugger break
|
||||||
|
// when a signal is raised, and so on.
|
||||||
|
restorePreviousSignalHandlers();
|
||||||
|
reportFatal( name );
|
||||||
raise( sig );
|
raise( sig );
|
||||||
}
|
}
|
||||||
|
|
||||||
FatalConditionHandler::FatalConditionHandler() {
|
FatalConditionHandler::FatalConditionHandler() {
|
||||||
isSet = true;
|
assert(!altStackMem && "Cannot initialize POSIX signal handler when one already exists");
|
||||||
|
if (altStackSize == 0) {
|
||||||
|
altStackSize = std::max(static_cast<size_t>(SIGSTKSZ), minStackSizeForErrors);
|
||||||
|
}
|
||||||
|
altStackMem = new char[altStackSize]();
|
||||||
|
}
|
||||||
|
|
||||||
|
FatalConditionHandler::~FatalConditionHandler() {
|
||||||
|
delete[] altStackMem;
|
||||||
|
// We signal that another instance can be constructed by zeroing
|
||||||
|
// out the pointer.
|
||||||
|
altStackMem = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FatalConditionHandler::engage_platform() {
|
||||||
stack_t sigStack;
|
stack_t sigStack;
|
||||||
sigStack.ss_sp = altStackMem;
|
sigStack.ss_sp = altStackMem;
|
||||||
sigStack.ss_size = sigStackSize;
|
sigStack.ss_size = altStackSize;
|
||||||
sigStack.ss_flags = 0;
|
sigStack.ss_flags = 0;
|
||||||
sigaltstack(&sigStack, &oldSigStack);
|
sigaltstack(&sigStack, &oldSigStack);
|
||||||
struct sigaction sa = { };
|
struct sigaction sa = { };
|
||||||
|
@ -10859,40 +10939,17 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FatalConditionHandler::~FatalConditionHandler() {
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FatalConditionHandler::reset() {
|
|
||||||
if( isSet ) {
|
|
||||||
// Set signals back to previous values -- hopefully nobody overwrote them in the meantime
|
|
||||||
for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) {
|
|
||||||
sigaction(signalDefs[i].id, &oldSigActions[i], nullptr);
|
|
||||||
}
|
|
||||||
// Return the old stack
|
|
||||||
sigaltstack(&oldSigStack, nullptr);
|
|
||||||
isSet = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FatalConditionHandler::isSet = false;
|
|
||||||
struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {};
|
|
||||||
stack_t FatalConditionHandler::oldSigStack = {};
|
|
||||||
char FatalConditionHandler::altStackMem[sigStackSize] = {};
|
|
||||||
|
|
||||||
} // namespace Catch
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
void FatalConditionHandler::reset() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // signals/SEH handling
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
# pragma GCC diagnostic pop
|
# pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void FatalConditionHandler::disengage_platform() {
|
||||||
|
restorePreviousSignalHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace Catch
|
||||||
|
|
||||||
|
#endif // CATCH_CONFIG_POSIX_SIGNALS
|
||||||
// end catch_fatal_condition.cpp
|
// end catch_fatal_condition.cpp
|
||||||
// start catch_generators.cpp
|
// start catch_generators.cpp
|
||||||
|
|
||||||
|
@ -11447,7 +11504,8 @@ namespace {
|
||||||
return lhs == rhs;
|
return lhs == rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ulpDiff = std::abs(lc - rc);
|
// static cast as a workaround for IBM XLC
|
||||||
|
auto ulpDiff = std::abs(static_cast<FP>(lc - rc));
|
||||||
return static_cast<uint64_t>(ulpDiff) <= maxUlpDiff;
|
return static_cast<uint64_t>(ulpDiff) <= maxUlpDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11621,7 +11679,6 @@ Floating::WithinRelMatcher WithinRel(float target) {
|
||||||
|
|
||||||
} // namespace Matchers
|
} // namespace Matchers
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
|
||||||
// end catch_matchers_floating.cpp
|
// end catch_matchers_floating.cpp
|
||||||
// start catch_matchers_generic.cpp
|
// start catch_matchers_generic.cpp
|
||||||
|
|
||||||
|
@ -12955,9 +13012,8 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunContext::invokeActiveTestCase() {
|
void RunContext::invokeActiveTestCase() {
|
||||||
FatalConditionHandler fatalConditionHandler; // Handle signals
|
FatalConditionHandlerGuard _(&m_fatalConditionhandler);
|
||||||
m_activeTestCase->invoke();
|
m_activeTestCase->invoke();
|
||||||
fatalConditionHandler.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunContext::handleUnfinishedSections() {
|
void RunContext::handleUnfinishedSections() {
|
||||||
|
@ -14126,24 +14182,28 @@ namespace Catch {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct TestHasher {
|
struct TestHasher {
|
||||||
explicit TestHasher(Catch::SimplePcg32& rng_instance) {
|
using hash_t = uint64_t;
|
||||||
basis = rng_instance();
|
|
||||||
basis <<= 32;
|
|
||||||
basis |= rng_instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t basis;
|
explicit TestHasher( hash_t hashSuffix ):
|
||||||
|
m_hashSuffix{ hashSuffix } {}
|
||||||
|
|
||||||
uint64_t operator()(TestCase const& t) const {
|
uint32_t operator()( TestCase const& t ) const {
|
||||||
// Modified FNV-1a hash
|
// FNV-1a hash with multiplication fold.
|
||||||
static constexpr uint64_t prime = 1099511628211;
|
const hash_t prime = 1099511628211u;
|
||||||
uint64_t hash = basis;
|
hash_t hash = 14695981039346656037u;
|
||||||
for (const char c : t.name) {
|
for ( const char c : t.name ) {
|
||||||
hash ^= c;
|
hash ^= c;
|
||||||
hash *= prime;
|
hash *= prime;
|
||||||
}
|
}
|
||||||
return hash;
|
hash ^= m_hashSuffix;
|
||||||
|
hash *= prime;
|
||||||
|
const uint32_t low{ static_cast<uint32_t>( hash ) };
|
||||||
|
const uint32_t high{ static_cast<uint32_t>( hash >> 32 ) };
|
||||||
|
return low * high;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
hash_t m_hashSuffix;
|
||||||
};
|
};
|
||||||
} // end unnamed namespace
|
} // end unnamed namespace
|
||||||
|
|
||||||
|
@ -14161,9 +14221,9 @@ namespace Catch {
|
||||||
|
|
||||||
case RunTests::InRandomOrder: {
|
case RunTests::InRandomOrder: {
|
||||||
seedRng( config );
|
seedRng( config );
|
||||||
TestHasher h( rng() );
|
TestHasher h{ config.rngSeed() };
|
||||||
|
|
||||||
using hashedTest = std::pair<uint64_t, TestCase const*>;
|
using hashedTest = std::pair<TestHasher::hash_t, TestCase const*>;
|
||||||
std::vector<hashedTest> indexed_tests;
|
std::vector<hashedTest> indexed_tests;
|
||||||
indexed_tests.reserve( unsortedTestCases.size() );
|
indexed_tests.reserve( unsortedTestCases.size() );
|
||||||
|
|
||||||
|
@ -15316,7 +15376,7 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
Version const& libraryVersion() {
|
Version const& libraryVersion() {
|
||||||
static Version version( 2, 13, 3, "", 0 );
|
static Version version( 2, 13, 6, "", 0 );
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue