@@ -34,6 +34,13 @@ BOOST_AUTO_TEST_CASE(dummy)
34
34
35
35
BOOST_AUTO_TEST_CASE (run_command)
36
36
{
37
+ #ifdef WIN32
38
+ // https://www.winehq.org/pipermail/wine-devel/2008-September/069387.html
39
+ auto hntdll = GetModuleHandleA (" ntdll.dll" );
40
+ assert (hntdll);
41
+ const bool wine_runtime = GetProcAddress (hntdll, " wine_get_version" );
42
+ #endif
43
+
37
44
{
38
45
const UniValue result = RunCommandParseJSON (" " );
39
46
BOOST_CHECK (result.isNull ());
@@ -51,29 +58,35 @@ BOOST_AUTO_TEST_CASE(run_command)
51
58
}
52
59
{
53
60
// An invalid command is handled by Boost
61
+ #ifdef WIN32
62
+ const int expected_error{wine_runtime ? 6 : 2 };
63
+ #else
64
+ const int expected_error{2 };
65
+ #endif
54
66
BOOST_CHECK_EXCEPTION (RunCommandParseJSON (" invalid_command" ), boost::process::process_error, [&](const boost::process::process_error& e) {
55
67
BOOST_CHECK (std::string (e.what ()).find (" RunCommandParseJSON error:" ) == std::string::npos);
56
- BOOST_CHECK_EQUAL (e.code ().value (), 2 );
68
+ BOOST_CHECK_EQUAL (e.code ().value (), expected_error );
57
69
return true ;
58
70
});
59
71
}
60
72
{
61
73
// Return non-zero exit code, no output to stderr
62
74
#ifdef WIN32
63
- const std::string command{" cmd.exe /c call " };
75
+ const std::string command{" cmd.exe /c exit 1 " };
64
76
#else
65
77
const std::string command{" false" };
66
78
#endif
67
79
BOOST_CHECK_EXCEPTION (RunCommandParseJSON (command), std::runtime_error, [&](const std::runtime_error& e) {
68
- BOOST_CHECK (std::string (e.what ()).find (strprintf (" RunCommandParseJSON error: process(%s) returned 1: \n " , command)) != std::string::npos);
80
+ const std::string what{e.what ()};
81
+ BOOST_CHECK (what.find (strprintf (" RunCommandParseJSON error: process(%s) returned 1: \n " , command)) != std::string::npos);
69
82
return true ;
70
83
});
71
84
}
72
85
{
73
86
// Return non-zero exit code, with error message for stderr
74
87
#ifdef WIN32
75
88
const std::string command{" cmd.exe /c dir nosuchfile" };
76
- const std::string expected{" File Not Found" };
89
+ const std::string expected{wine_runtime ? " File not found. " : " File Not Found" };
77
90
#else
78
91
const std::string command{" ls nosuchfile" };
79
92
const std::string expected{" No such file or directory" };
0 commit comments