From 0bec1dc4b28da3f8e887ce1ba7b6c216c0c815d3 Mon Sep 17 00:00:00 2001 From: "David Fields (ANALOG)" Date: Tue, 7 Sep 2021 15:06:26 -0700 Subject: [PATCH 1/2] Buffer test output and redirect to stdout/stderr depending whether the test executable exits successfully --- .gitignore | 1 + run_tests.cmd | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a6fabe55a..39ccd342c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *.c *.nupkg test*.xml +test*_results.txt build packages Debug diff --git a/run_tests.cmd b/run_tests.cmd index 9cdbeb4b3..86ec520e1 100644 --- a/run_tests.cmd +++ b/run_tests.cmd @@ -20,5 +20,6 @@ goto :eof :run_test if not "%target_version%"=="" set args=-o %1-%target_version%.xml -r junit -_build\%target_platform%\%target_configuration%\%1.exe %args% +rem Buffer output and redirect to stdout/stderr depending whether the test executable exits successfully. Pipeline will fail if there's any output to stderr. +_build\%target_platform%\%target_configuration%\%1.exe %args% > %1_results.txt && type %1_results.txt || type %1_results.txt >&2 goto :eof From fd0b747bb2441f0a915b9c63d5a96c4d94e68487 Mon Sep 17 00:00:00 2001 From: "David Fields (ANALOG)" Date: Wed, 1 Sep 2021 16:14:24 -0700 Subject: [PATCH 2/2] Generate test failure output on abnormal termination --- test/old_tests/UnitTests/Main.cpp | 2 +- test/test/main.cpp | 2 +- test/test_win7/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/old_tests/UnitTests/Main.cpp b/test/old_tests/UnitTests/Main.cpp index 680f26e01..de63b39fc 100644 --- a/test/old_tests/UnitTests/Main.cpp +++ b/test/old_tests/UnitTests/Main.cpp @@ -8,7 +8,7 @@ int main(int argc, char * argv[]) using namespace winrt; init_apartment(); - std::set_terminate([]{ ExitProcess(1); }); + std::set_terminate([]{ reportFatal("Abnormal termination"); ExitProcess(1); }); int const result = Catch::Session().run(argc, argv); // Completely unnecessary in an app, but useful for testing clear_factory_cache behavior. diff --git a/test/test/main.cpp b/test/test/main.cpp index 171bd517f..7c55cbbed 100644 --- a/test/test/main.cpp +++ b/test/test/main.cpp @@ -7,7 +7,7 @@ using namespace winrt; int main(int const argc, char** argv) { init_apartment(); - std::set_terminate([] { ExitProcess(1); }); + std::set_terminate([] { reportFatal("Abnormal termination"); ExitProcess(1); }); return Catch::Session().run(argc, argv); } diff --git a/test/test_win7/main.cpp b/test/test_win7/main.cpp index 171bd517f..7c55cbbed 100644 --- a/test/test_win7/main.cpp +++ b/test/test_win7/main.cpp @@ -7,7 +7,7 @@ using namespace winrt; int main(int const argc, char** argv) { init_apartment(); - std::set_terminate([] { ExitProcess(1); }); + std::set_terminate([] { reportFatal("Abnormal termination"); ExitProcess(1); }); return Catch::Session().run(argc, argv); }