Improve TESTUTILS_ASSERT_EXEC to print stdout/stderr on failure

This commit is contained in:
Martchus 2018-10-21 20:22:21 +02:00
parent cad2977e4e
commit 66b4b782cd
1 changed files with 8 additions and 1 deletions

View File

@ -209,7 +209,14 @@ template <typename T, Traits::DisableIf<std::is_integral<T>> * = nullptr> const
*
* \remarks Requires cppunit.
*/
#define TESTUTILS_ASSERT_EXEC(args) CPPUNIT_ASSERT_EQUAL(0, execApp(args, stdout, stderr))
#define TESTUTILS_ASSERT_EXEC(args) \
{ \
const auto returnCode = execApp(args, stdout, stderr); \
if (returnCode != 0) { \
CPPUNIT_FAIL( \
::ConversionUtilities::argsToString("app failed with return code ", returnCode, "\nstdout: ", stdout, "\nstderr: ", stderr)); \
} \
}
/*!
* \brief Asserts whether the specified \a string matches the specified \a regex.