Skip to content

Commit edd0313

Browse files
committed
test: Improve "invalid_command" subtest in system_tests for Windows
No need to explain code with comments.
1 parent fb1b059 commit edd0313

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/test/system_tests.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ BOOST_AUTO_TEST_CASE(dummy)
2828

2929
#ifdef ENABLE_EXTERNAL_SIGNER
3030

31-
bool checkMessage(const std::runtime_error& ex)
32-
{
33-
// On Linux & Mac: "No such file or directory"
34-
// On Windows: "The system cannot find the file specified."
35-
const std::string what(ex.what());
36-
BOOST_CHECK(what.find("file") != std::string::npos);
37-
return true;
38-
}
39-
4031
BOOST_AUTO_TEST_CASE(run_command)
4132
{
4233
{
@@ -56,7 +47,17 @@ BOOST_AUTO_TEST_CASE(run_command)
5647
}
5748
{
5849
// An invalid command is handled by Boost
59-
BOOST_CHECK_EXCEPTION(RunCommandParseJSON("invalid_command"), boost::process::process_error, checkMessage); // Command failed
50+
#ifdef WIN32
51+
const std::string expected{"The system cannot find the file specified."};
52+
#else
53+
const std::string expected{"No such file or directory"};
54+
#endif
55+
BOOST_CHECK_EXCEPTION(RunCommandParseJSON("invalid_command"), boost::process::process_error, [&](const boost::process::process_error& e) {
56+
const std::string what(e.what());
57+
BOOST_CHECK(what.find("RunCommandParseJSON error:") == std::string::npos);
58+
BOOST_CHECK(what.find(expected) != std::string::npos);
59+
return true;
60+
});
6061
}
6162
{
6263
// Return non-zero exit code, no output to stderr

0 commit comments

Comments
 (0)