From 0aad33db6410ed36fa0f4b96245cacbae7897d2e Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 15 Dec 2021 13:59:08 +0200 Subject: [PATCH] test: Fix "false" subtest in system_tests for Windows --- src/test/system_tests.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp index 32aee2bce54..3cb86de94de 100644 --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -37,12 +37,6 @@ bool checkMessage(const std::runtime_error& ex) return true; } -bool checkMessageFalse(const std::runtime_error& ex) -{ - BOOST_CHECK_EQUAL(ex.what(), std::string("RunCommandParseJSON error: process(false) returned 1: \n")); - return true; -} - bool checkMessageStdErr(const std::runtime_error& ex) { const std::string what(ex.what()); @@ -73,7 +67,15 @@ BOOST_AUTO_TEST_CASE(run_command) } { // Return non-zero exit code, no output to stderr - BOOST_CHECK_EXCEPTION(RunCommandParseJSON("false"), std::runtime_error, checkMessageFalse); +#ifdef WIN32 + const std::string command{"cmd.exe /c call"}; +#else + const std::string command{"false"}; +#endif + BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) { + BOOST_CHECK(std::string(e.what()).find(strprintf("RunCommandParseJSON error: process(%s) returned 1: \n", command)) != std::string::npos); + return true; + }); } { // Return non-zero exit code, with error message for stderr