aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-12-03 16:04:20 +0000
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-12-03 16:04:20 +0000
commit55e3dc3e03510e97caba1547a82e3e022b0bbd42 (patch)
tree8d711d2d26e16e16161b085e0214b50dac63ee91 /src
parent160d23677ad799cf9b493eaa923b2ac080c3fb8e (diff)
downloadbitcoin-55e3dc3e03510e97caba1547a82e3e022b0bbd42.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/test/system_tests.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp
index 740f461548..6a96b60db0 100644
--- a/src/test/system_tests.cpp
+++ b/src/test/system_tests.cpp
@@ -90,7 +90,13 @@ BOOST_AUTO_TEST_CASE(run_command)
});
}
{
- BOOST_REQUIRE_THROW(RunCommandParseJSON("echo \"{\""), std::runtime_error); // Unable to parse JSON
+ // Unable to parse JSON
+#ifdef WIN32
+ const std::string command{"cmd.exe /c echo {"};
+#else
+ const std::string command{"echo {"};
+#endif
+ BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, HasReason("Unable to parse JSON: {"));
}
// Test std::in, except for Windows
#ifndef WIN32