mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge bitcoin/bitcoin#28989: test: Fix test by checking the actual exception instance
55e3dc3e03510e97caba1547a82e3e022b0bbd42 test: Fix test by checking the actual exception instance (Hennadii Stepanov) Pull request description: The `system_tests/run_command` test is broken because it passes even with the diff as follows: ```diff --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(run_command) }); } { - BOOST_REQUIRE_THROW(RunCommandParseJSON("echo \"{\""), std::runtime_error); // Unable to parse JSON + BOOST_REQUIRE_THROW(RunCommandParseJSON("invalid_command \"{\""), std::runtime_error); // Unable to parse JSON } // Test std::in, except for Windows #ifndef WIN32 ``` The reason of such fragility is that the [`BOOST_REQUIRE_THROW`](https://www.boost.org/doc/libs/1_83_0/libs/test/doc/html/boost_test/utf_reference/testing_tool_ref/assertion_boost_level_throw.html) macro passes even if the command raises an exception in the underlying subprocess implementation, which might have a type derived from `std::runtime_error`. ACKs for top commit: maflcko: lgtm ACK 55e3dc3e03510e97caba1547a82e3e022b0bbd42 achow101: ACK 55e3dc3e03510e97caba1547a82e3e022b0bbd42 furszy: Non-Windows code ACK 55e3dc3e pablomartin4btc: ACK 55e3dc3e03510e97caba1547a82e3e022b0bbd42 Tree-SHA512: 32f49421bdcc94744c81e82dc10cfa02e3f8ed111974edf1c2a47bdaeb56d7baec1bede67301cc89464fba613029ecb131dedc6bc5948777ab52f0f12df8bfe9
This commit is contained in:
parent
8cd85d311f
commit
75e0334866
@ -77,7 +77,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
|
// Test std::in, except for Windows
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
Loading…
Reference in New Issue
Block a user