skip unit tests for handling child errors in pipestream with ancient boost
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Mon, 12 Feb 2018 14:32:36 +0000 (15:32 +0100)
committerPhilipp Gesang <philipp.gesang@intra2net.com>
Tue, 14 Aug 2018 14:53:34 +0000 (16:53 +0200)
test/test_pipestream.cpp

index b03d6c0..e145ab7 100644 (file)
  * Copyright 2018 by Intra2net AG
  */
 
-#define BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE
+#include <boost/version.hpp>
+#if BOOST_VERSION > /* guessed */ 104400
+/*
+ * Boost overeagerly terminates a unit test when a child exits non-zero
+ * without offering a means of disabling this behavior locally. All we
+ * have is below macro which isn’t even available on older versions of
+ * the unittest runner.
+ */
+#   define BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE
+#else
+/* Boost too old; skip test that validate error handling. */
+#   define NO_CHILD_FAIL_TESTS
+#endif
 
 #define BOOST_TEST_DYN_LINK
 #include <boost/test/unit_test.hpp>
@@ -99,6 +111,7 @@ BOOST_AUTO_TEST_SUITE(pipestream)
 
         const char *const bad_command [] = { "/does_not_exist", NULL };
 
+# ifndef NO_CHILD_FAIL_TESTS
         BOOST_AUTO_TEST_CASE(abspath_bad_shell_fail)
         {
             assert (access(bad_command [0], X_OK) != 0);
@@ -115,7 +128,9 @@ BOOST_AUTO_TEST_SUITE(pipestream)
             BOOST_CHECK(!exres.normal_exit);
             BOOST_CHECK_EQUAL(result.size (), 0);
         }
+# endif /* [!NO_CHILD_FAIL_TESTS] */
 
+# ifndef NO_CHILD_FAIL_TESTS
         BOOST_AUTO_TEST_CASE(abspath_bad_noshell_fail)
         {
             assert (access(bad_command [0], X_OK) != 0);
@@ -130,7 +145,9 @@ BOOST_AUTO_TEST_SUITE(pipestream)
                               "child failed to exec(): "
                               "error 2 (No such file or directory)");
         }
+# endif /* [!NO_CHILD_FAIL_TESTS] */
 
+# ifndef NO_CHILD_FAIL_TESTS
         BOOST_AUTO_TEST_CASE(abspath_bad_noshell_stderr)
         {
             assert (access(bad_command [0], X_OK) != 0);
@@ -145,12 +162,14 @@ BOOST_AUTO_TEST_SUITE(pipestream)
                               "child failed to exec(): "
                               "error 2 (No such file or directory)");
         }
+# endif /* [!NO_CHILD_FAIL_TESTS] */
 
         const char *const false_argv_abs [] = { "/bin/false", NULL };
         const char *const true_argv_abs  [] = { "/bin/true" , NULL };
         const char *const false_argv_rel [] = { "false"     , NULL };
         const char *const true_argv_rel  [] = { "true"      , NULL };
 
+# ifndef NO_CHILD_FAIL_TESTS
         BOOST_AUTO_TEST_CASE(abspath_false_noshell_fail_exit)
         {
             ExecResult exres = ExecResult ();
@@ -161,7 +180,9 @@ BOOST_AUTO_TEST_SUITE(pipestream)
             BOOST_CHECK_EQUAL(exres.return_code, EXIT_FAILURE);
             BOOST_CHECK_EQUAL(result.size (), 0);
         }
+# endif /* [!NO_CHILD_FAIL_TESTS] */
 
+# ifndef NO_CHILD_FAIL_TESTS
         BOOST_AUTO_TEST_CASE(abspath_false_shell_fail_exit)
         {
             ExecResult exres = ExecResult ();
@@ -172,6 +193,7 @@ BOOST_AUTO_TEST_SUITE(pipestream)
             BOOST_CHECK_EQUAL(exres.return_code, EXIT_FAILURE);
             BOOST_CHECK_EQUAL(result.size (), 0);
         }
+# endif /* [!NO_CHILD_FAIL_TESTS] */
 
         BOOST_AUTO_TEST_CASE(relpath_true_noshell_ok)
         {
@@ -184,6 +206,7 @@ BOOST_AUTO_TEST_SUITE(pipestream)
             BOOST_CHECK_EQUAL(result.size (), 0);
         }
 
+# ifndef NO_CHILD_FAIL_TESTS
         BOOST_AUTO_TEST_CASE(relpath_true_noshell_fail)
         {
             ExecResult exres = ExecResult ();
@@ -197,6 +220,7 @@ BOOST_AUTO_TEST_SUITE(pipestream)
                               "child failed to exec(): "
                               "error 2 (No such file or directory)");
         }
+# endif /* [!NO_CHILD_FAIL_TESTS] */
 
         BOOST_AUTO_TEST_CASE(abspath_true_noshell_ok)
         {
@@ -209,6 +233,7 @@ BOOST_AUTO_TEST_SUITE(pipestream)
             BOOST_CHECK_EQUAL(result.size (), 0);
         }
 
+# ifndef NO_CHILD_FAIL_TESTS
         BOOST_AUTO_TEST_CASE(relpath_false_noshell_fail)
         {
             ExecResult exres = ExecResult ();
@@ -219,6 +244,7 @@ BOOST_AUTO_TEST_SUITE(pipestream)
             /* no return code check since we couldn't exit */
             BOOST_CHECK_EQUAL(result.size (), 0);
         }
+# endif /* [!NO_CHILD_FAIL_TESTS] */
 
         const char *const echo_abs = "/bin/echo";
         const char *const echo_rel = "echo";