File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,6 @@ bool checkMessage(const std::runtime_error& ex)
3737 return true ;
3838}
3939
40- bool checkMessageStdErr (const std::runtime_error& ex)
41- {
42- const std::string what (ex.what ());
43- BOOST_CHECK (what.find (" RunCommandParseJSON error:" ) != std::string::npos);
44- return checkMessage (ex);
45- }
46-
4740BOOST_AUTO_TEST_CASE (run_command)
4841{
4942 {
@@ -79,7 +72,19 @@ BOOST_AUTO_TEST_CASE(run_command)
7972 }
8073 {
8174 // Return non-zero exit code, with error message for stderr
82- BOOST_CHECK_EXCEPTION (RunCommandParseJSON (" ls nosuchfile" ), std::runtime_error, checkMessageStdErr);
75+ #ifdef WIN32
76+ const std::string command{" cmd.exe /c dir nosuchfile" };
77+ const std::string expected{" File Not Found" };
78+ #else
79+ const std::string command{" ls nosuchfile" };
80+ const std::string expected{" No such file or directory" };
81+ #endif
82+ BOOST_CHECK_EXCEPTION (RunCommandParseJSON (command), std::runtime_error, [&](const std::runtime_error& e) {
83+ const std::string what (e.what ());
84+ BOOST_CHECK (what.find (strprintf (" RunCommandParseJSON error: process(%s) returned" , command)) != std::string::npos);
85+ BOOST_CHECK (what.find (expected) != std::string::npos);
86+ return true ;
87+ });
8388 }
8489 {
8590 BOOST_REQUIRE_THROW (RunCommandParseJSON (" echo \" {\" " ), std::runtime_error); // Unable to parse JSON
You can’t perform that action at this time.
0 commit comments