From 66b4b782cd8fc3aef80d5742b464b7d42180c20f Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 21 Oct 2018 20:22:21 +0200 Subject: [PATCH] Improve TESTUTILS_ASSERT_EXEC to print stdout/stderr on failure --- tests/testutils.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/testutils.h b/tests/testutils.h index 889dbc6..90fdc7d 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -209,7 +209,14 @@ template > * = 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.