From 77676d558ea16b30ca6128ee9f1bafcf7c2476c4 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Mon, 24 Feb 2014 13:45:43 +0000 Subject: [PATCH] potential fix for unit/integ test false positives --- src/test/integtests/Main.cpp | 9 +++++++-- src/test/unittests/Main.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/test/integtests/Main.cpp b/src/test/integtests/Main.cpp index d76bb30b..584e881b 100644 --- a/src/test/integtests/Main.cpp +++ b/src/test/integtests/Main.cpp @@ -66,8 +66,13 @@ main(int argc, char **argv) if (!lockFile.empty()) { unlock(lockFile); } - - return result; + + // gtest seems to randomly finish with error codes (e.g. -1, -1073741819) + // even when no tests have failed. not sure what causes this, but it + // happens on all platforms and keeps leading to false positives. + // according to the documentation, 1 is a failure, so we should be + // able to trust that code. + return (result == 1) ? 1 : 0; } void diff --git a/src/test/unittests/Main.cpp b/src/test/unittests/Main.cpp index dd165045..2320acbf 100644 --- a/src/test/unittests/Main.cpp +++ b/src/test/unittests/Main.cpp @@ -39,6 +39,11 @@ main(int argc, char **argv) log.setFilter(kDEBUG4); testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); + + // gtest seems to randomly finish with error codes (e.g. -1, -1073741819) + // even when no tests have failed. not sure what causes this, but it + // happens on all platforms and keeps leading to false positives. + // according to the documentation, 1 is a failure, so we should be + // able to trust that code. + return (RUN_ALL_TESTS() == 1) ? 1 : 0; }