diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-12-15 13:21:33 +0200 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-12-15 14:09:31 +0200 |
commit | edd0313ae7c94420642081c9172e349080bb9335 (patch) | |
tree | ac2a27e2aa478f9e323c11e54452166b6d5d7d09 /src/test | |
parent | fb1b0590af138e317803893d2cab9dc887f33c5b (diff) |
test: Improve "invalid_command" subtest in system_tests for Windows
No need to explain code with comments.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/system_tests.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp index 677edb133f..bdb4b4ed7f 100644 --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -28,15 +28,6 @@ BOOST_AUTO_TEST_CASE(dummy) #ifdef ENABLE_EXTERNAL_SIGNER -bool checkMessage(const std::runtime_error& ex) -{ - // On Linux & Mac: "No such file or directory" - // On Windows: "The system cannot find the file specified." - const std::string what(ex.what()); - BOOST_CHECK(what.find("file") != std::string::npos); - return true; -} - BOOST_AUTO_TEST_CASE(run_command) { { @@ -56,7 +47,17 @@ BOOST_AUTO_TEST_CASE(run_command) } { // An invalid command is handled by Boost - BOOST_CHECK_EXCEPTION(RunCommandParseJSON("invalid_command"), boost::process::process_error, checkMessage); // Command failed +#ifdef WIN32 + const std::string expected{"The system cannot find the file specified."}; +#else + const std::string expected{"No such file or directory"}; +#endif + BOOST_CHECK_EXCEPTION(RunCommandParseJSON("invalid_command"), boost::process::process_error, [&](const boost::process::process_error& e) { + const std::string what(e.what()); + BOOST_CHECK(what.find("RunCommandParseJSON error:") == std::string::npos); + BOOST_CHECK(what.find(expected) != std::string::npos); + return true; + }); } { // Return non-zero exit code, no output to stderr |