From 0c68bd0f8e649d2c77dd290b65033789271fe5d9 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 12 Feb 2018 15:32:36 +0100 Subject: [PATCH] skip unit tests for handling child errors in pipestream with ancient boost --- test/test_pipestream.cpp | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-) diff --git a/test/test_pipestream.cpp b/test/test_pipestream.cpp index b03d6c0..e145ab7 100644 --- a/test/test_pipestream.cpp +++ b/test/test_pipestream.cpp @@ -24,7 +24,19 @@ * Copyright 2018 by Intra2net AG */ -#define BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE +#include +#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 @@ -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"; -- 1.7.1