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)
37
37
return true ;
38
38
}
39
39
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
-
47
40
BOOST_AUTO_TEST_CASE (run_command)
48
41
{
49
42
{
@@ -79,7 +72,19 @@ BOOST_AUTO_TEST_CASE(run_command)
79
72
}
80
73
{
81
74
// 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
+ });
83
88
}
84
89
{
85
90
BOOST_REQUIRE_THROW (RunCommandParseJSON (" echo \" {\" " ), std::runtime_error); // Unable to parse JSON
You can’t perform that action at this time.
0 commit comments