Skip to content

Commit 55e3dc3

Browse files
committed
test: Fix test by checking the actual exception instance
The BOOST_REQUIRE_THROW passes even if the command raises an exception in the underlying subprocess implementation, which might have a type derived from std::runtime_error.
1 parent 160d236 commit 55e3dc3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/test/system_tests.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ BOOST_AUTO_TEST_CASE(run_command)
9090
});
9191
}
9292
{
93-
BOOST_REQUIRE_THROW(RunCommandParseJSON("echo \"{\""), std::runtime_error); // Unable to parse JSON
93+
// Unable to parse JSON
94+
#ifdef WIN32
95+
const std::string command{"cmd.exe /c echo {"};
96+
#else
97+
const std::string command{"echo {"};
98+
#endif
99+
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, HasReason("Unable to parse JSON: {"));
94100
}
95101
// Test std::in, except for Windows
96102
#ifndef WIN32

0 commit comments

Comments
 (0)