ctest: Restore Windows Error Reporting in interactive mode

This behavior was removed when we switched to libuv in CMake 3.11.
After backporting new changes from libuv v2, we can restore the
behavior.

Fixes: #20115
This commit is contained in:
Dylan Snelgrove 2024-10-22 16:55:07 +00:00 committed by Brad King
parent 9fdf716ee8
commit 0a4ee422c1
5 changed files with 38 additions and 8 deletions

View File

@ -353,18 +353,32 @@ Run Tests
This allows the user to widen the output to avoid clipping the test
name which can be very annoying.
.. option:: --interactive-debug-mode [0|1]
.. option:: --interactive-debug-mode <0|1>
Set the interactive mode to ``0`` or ``1``.
Disable (``0``) or enable (``1``) interactive debug mode.
This option causes CTest to run tests in either an interactive mode
or a non-interactive mode. In dashboard mode (``Experimental``, ``Nightly``,
``Continuous``), the default is non-interactive. In non-interactive mode,
the environment variable :envvar:`DASHBOARD_TEST_FROM_CTEST` is set.
Prior to CMake 3.11, interactive mode on Windows allowed system debug
popup windows to appear. Now, due to CTest's use of ``libuv`` to launch
test processes, all system debug popup windows are always blocked.
Interactive Mode allows Windows Error Reporting (WER) to show debug popup
windows and to create core dumps. To enable core dumps in tests,
use interactive mode, and follow the Windows documentation
on `Collecting User-Mode Dumps`_.
.. versionchanged:: 3.32
Windows Error Reporting (WER) is enabled in interactive mode, so
test processes may show debug popup windows and create core dumps.
This was made possible by updates to ``libuv``.
.. versionchanged:: 3.11
Windows Error Reporting (WER) is disabled in both interactive and
non-interactive modes, so test processes do not show popup windows
or create core dumps. This is due to launching test processes with
``libuv``.
.. _`Collecting User-Mode Dumps`: https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps
.. option:: --no-label-summary

View File

@ -0,0 +1,7 @@
ctest-crash-handling
--------------------
* The :option:`ctest --interactive-debug-mode` option on Windows
now enables Windows Error Reporting by default in test processes,
allowing them to creating debug popup windows and core dumps.
This restores behavior previously removed by CMake 3.11.

View File

@ -106,6 +106,11 @@ bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity)
options.stdio_count = 3; // in, out and err
options.exit_cb = &cmProcess::OnExitCB;
options.stdio = stdio;
#if UV_VERSION_MAJOR > 1 || !defined(CMAKE_USE_SYSTEM_LIBUV)
if (!this->Runner->GetCTest()->GetInteractiveDebugMode()) {
options.flags = UV_PROCESS_WINDOWS_USE_PARENT_ERROR_MODE;
}
#endif
#if !defined(CMAKE_USE_SYSTEM_LIBUV)
std::vector<char> cpumask;
if (affinity && !affinity->empty()) {
@ -122,9 +127,6 @@ bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity)
#else
static_cast<void>(affinity);
#endif
#if UV_VERSION_MAJOR > 1 || !defined(CMAKE_USE_SYSTEM_LIBUV)
options.flags = UV_PROCESS_WINDOWS_USE_PARENT_ERROR_MODE;
#endif
status =
uv_read_start(pipe_reader, &cmProcess::OnAllocateCB, &cmProcess::OnReadCB);

View File

@ -3096,6 +3096,11 @@ int cmCTest::GetSubmitIndex() const
return this->Impl->SubmitIndex;
}
bool cmCTest::GetInteractiveDebugMode() const
{
return this->Impl->InteractiveDebugMode;
}
bool cmCTest::GetLabelSummary() const
{
return this->Impl->LabelSummary;

View File

@ -389,6 +389,8 @@ public:
void AddSiteProperties(cmXMLWriter& xml, cmake* cm);
bool GetInteractiveDebugMode() const;
bool GetLabelSummary() const;
bool GetSubprojectSummary() const;