[Libreoffice-commits] online.git: test/run_unit.sh.in test/test.cpp

Jan Holesovsky kendy at collabora.com
Fri Apr 7 13:38:33 UTC 2017


 test/run_unit.sh.in |    6 +++---
 test/test.cpp       |   18 ++++++++++++++++--
 2 files changed, 19 insertions(+), 5 deletions(-)

New commits:
commit c562471302bbd4776c76f783ca2dc8b9c0806d3a
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Apr 7 15:37:20 2017 +0200

    Write the failures we got during the test run.
    
    Change-Id: I2c05b6f2c890b3a67824f1ca612fa7f4e05d994f

diff --git a/test/run_unit.sh.in b/test/run_unit.sh.in
index 4b8e71cf..32d7ba2d 100755
--- a/test/run_unit.sh.in
+++ b/test/run_unit.sh.in
@@ -13,7 +13,7 @@ enable_debug="@ENABLE_DEBUG@"
 jails_path="@JAILS_PATH@"
 lo_path="@LO_PATH@"
 valgrind_cmd="valgrind --tool=memcheck --trace-children=no -v --read-var-info=yes"
-hide_stderr='2>/dev/null'
+verbose=''
 
 # Note that these options are used by commands in the Makefile that
 # Automake generates. Don't be mislead by 'git grep' not showing any
@@ -26,7 +26,7 @@ while test $# -gt 0; do
       --log-file)  tst_log=$2; shift;;
       --trs-file)  test_output=$2; shift;;
       --valgrind)  valgrind=$valgrind_cmd; shift;;
-      --verbose)   hide_stderr="";;
+      --verbose)   verbose="--verbose";;
   -*) ;; # ignore
   esac
   shift
@@ -86,7 +86,7 @@ if test "z$tst" == "z"; then
 
      oldpath=`pwd`
      cd "${abs_top_builddir}/test"
-     if eval ${valgrind} ./test ${hide_stderr}; then
+     if eval ${valgrind} ./test ${verbose}; then
 	 echo "Test run_test.sh passed."
 	 echo ":test-result: PASS run_test.sh" >> $oldpath/$test_output
 	 retval=0
diff --git a/test/test.cpp b/test/test.cpp
index 9ad21cd5..fc0a6dfb 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -56,9 +56,13 @@ bool filterTests(CPPUNIT_NS::TestRunner& runner, CPPUNIT_NS::Test* testRegistry,
     return haveTests;
 }
 
-int main(int /*argc*/, char** /*argv*/)
+int main(int argc, char** argv)
 {
-    Log::initialize("tst", "trace", true, false, {});
+    const char* loglevel = "error";
+    if (argc > 0 && std::string("--verbose") == argv[0])
+        loglevel = "trace";
+
+    Log::initialize("tst", loglevel, true, false, {});
 
     CPPUNIT_NS::TestResult controller;
     CPPUNIT_NS::TestResultCollector result;
@@ -92,8 +96,18 @@ int main(int /*argc*/, char** /*argv*/)
         }
     }
 
+    // redirect std::cerr temporarily
+    std::stringstream errorBuffer;
+    std::streambuf* oldCerr = std::cerr.rdbuf(errorBuffer.rdbuf());
+
     runner.run(controller);
 
+    std::cerr.rdbuf(oldCerr);
+
+    // output the errors we got during the testing
+    if (!result.wasSuccessful())
+        std::cerr << errorBuffer.str() << std::endl;
+
     CPPUNIT_NS::CompilerOutputter outputter(&result, std::cerr);
     outputter.setNoWrap();
     outputter.write();


More information about the Libreoffice-commits mailing list