diff options
author | Jadi <jadijadi@gmail.com> | 2024-09-02 16:18:33 +0330 |
---|---|---|
committer | Jadi <jadijadi@gmail.com> | 2024-09-04 09:30:05 +0330 |
commit | ae48a22a3df086fb59843b7b814619ed5df7557b (patch) | |
tree | d38bbd5dce26eb45651bae71da6585a7af1d0e09 /src/test | |
parent | 5abb9b1af49be9024f95fa2f777285c531785d85 (diff) | |
download | bitcoin-ae48a22a3df086fb59843b7b814619ed5df7557b.tar.xz |
test: fixing failing system_tests/run_command under some Locales
the run_command test under system_tests fails if the locale is anything
other than English ones because results such as "No such file or directory"
will be different under Non-English locales.
On the old version, a `ls nonexistingfile` was used to generate the error
output which is not ideal. In the current version we are using a Python one-liner
to generate a non 0 zero return value and "err" on stderr and check the
expected value against this.
fixes #30608
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/system_tests.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp index baa759e42c..07d15f5552 100644 --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -54,8 +54,8 @@ BOOST_AUTO_TEST_CASE(run_command) } { // Return non-zero exit code, with error message for stderr - const std::string command{"ls nosuchfile"}; - const std::string expected{"No such file or directory"}; + const std::string command{"python3 -c 'import sys; print(\"err\", file=sys.stderr); sys.exit(2)'"}; + const std::string expected{"err"}; BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) { const std::string what(e.what()); BOOST_CHECK(what.find(strprintf("RunCommandParseJSON error: process(%s) returned", command)) != std::string::npos); |