Skip to content

Commit dfbad09

Browse files
committed
Merge bitcoin/bitcoin#29489: test: Remove Windows-specific code from system_tests/run_command
51bc1c7 test: Remove Windows-specific code from `system_tests/run_command` (Hennadii Stepanov) Pull request description: The removed code has been dead since bitcoin/bitcoin#28967. Required as a precondition for replacing Boost.Process with [cpp-subprocess](bitcoin/bitcoin#28981) to make diff for this code meaningful and reviewable. The plan is to reintroduce Windows-specific code in this test simultaneously with enabling Windows support in cpp-subprocess. ACKs for top commit: Sjors: utACK 51bc1c7 theStack: Code-review ACK 51bc1c7 Tree-SHA512: 0e3875c4dc20564332555633daf2227223b10dc3d052557635eced2734575d1e0252fb19e46ea6e6c47a15c51c345f70b6d437e33435abcd0e4fcf29edb50887
2 parents d752831 + 51bc1c7 commit dfbad09

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

src/test/system_tests.cpp

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,20 @@ BOOST_AUTO_TEST_CASE(dummy)
2929

3030
BOOST_AUTO_TEST_CASE(run_command)
3131
{
32-
#ifdef WIN32
33-
// https://www.winehq.org/pipermail/wine-devel/2008-September/069387.html
34-
auto hntdll = GetModuleHandleA("ntdll.dll");
35-
assert(hntdll);
36-
const bool wine_runtime = GetProcAddress(hntdll, "wine_get_version");
37-
#endif
38-
3932
{
4033
const UniValue result = RunCommandParseJSON("");
4134
BOOST_CHECK(result.isNull());
4235
}
4336
{
44-
#ifdef WIN32
45-
const UniValue result = RunCommandParseJSON("cmd.exe /c echo {\"success\": true}");
46-
#else
4737
const UniValue result = RunCommandParseJSON("echo \"{\"success\": true}\"");
48-
#endif
4938
BOOST_CHECK(result.isObject());
5039
const UniValue& success = result.find_value("success");
5140
BOOST_CHECK(!success.isNull());
5241
BOOST_CHECK_EQUAL(success.get_bool(), true);
5342
}
5443
{
5544
// An invalid command is handled by Boost
56-
#ifdef WIN32
57-
const int expected_error{wine_runtime ? 6 : 2};
58-
#else
5945
const int expected_error{2};
60-
#endif
6146
BOOST_CHECK_EXCEPTION(RunCommandParseJSON("invalid_command"), boost::process::process_error, [&](const boost::process::process_error& e) {
6247
BOOST_CHECK(std::string(e.what()).find("RunCommandParseJSON error:") == std::string::npos);
6348
BOOST_CHECK_EQUAL(e.code().value(), expected_error);
@@ -66,11 +51,7 @@ BOOST_AUTO_TEST_CASE(run_command)
6651
}
6752
{
6853
// Return non-zero exit code, no output to stderr
69-
#ifdef WIN32
70-
const std::string command{"cmd.exe /c exit 1"};
71-
#else
7254
const std::string command{"false"};
73-
#endif
7455
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) {
7556
const std::string what{e.what()};
7657
BOOST_CHECK(what.find(strprintf("RunCommandParseJSON error: process(%s) returned 1: \n", command)) != std::string::npos);
@@ -79,13 +60,8 @@ BOOST_AUTO_TEST_CASE(run_command)
7960
}
8061
{
8162
// Return non-zero exit code, with error message for stderr
82-
#ifdef WIN32
83-
const std::string command{"cmd.exe /c dir nosuchfile"};
84-
const std::string expected{wine_runtime ? "File not found." : "File Not Found"};
85-
#else
8663
const std::string command{"ls nosuchfile"};
8764
const std::string expected{"No such file or directory"};
88-
#endif
8965
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) {
9066
const std::string what(e.what());
9167
BOOST_CHECK(what.find(strprintf("RunCommandParseJSON error: process(%s) returned", command)) != std::string::npos);
@@ -95,23 +71,17 @@ BOOST_AUTO_TEST_CASE(run_command)
9571
}
9672
{
9773
// Unable to parse JSON
98-
#ifdef WIN32
99-
const std::string command{"cmd.exe /c echo {"};
100-
#else
10174
const std::string command{"echo {"};
102-
#endif
10375
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, HasReason("Unable to parse JSON: {"));
10476
}
105-
// Test std::in, except for Windows
106-
#ifndef WIN32
77+
// Test std::in
10778
{
10879
const UniValue result = RunCommandParseJSON("cat", "{\"success\": true}");
10980
BOOST_CHECK(result.isObject());
11081
const UniValue& success = result.find_value("success");
11182
BOOST_CHECK(!success.isNull());
11283
BOOST_CHECK_EQUAL(success.get_bool(), true);
11384
}
114-
#endif
11585
}
11686
#endif // ENABLE_EXTERNAL_SIGNER
11787

0 commit comments

Comments
 (0)