-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: Fix system_tests/run_command test
#32601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This change addresses two issues for the "Return non-zero exit code, with error message for stderr" case: 1. The test now checks the exact exit code, which must be 1. 2. The process invocation string is removed from the exception message before checking the stderr output, as the latter is a substring of the former.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32601. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
| versionbits_tests.cpp | ||
| ) | ||
| set_property(SOURCE system_tests.cpp PROPERTY | ||
| COMPILE_DEFINITIONS PRINT_ERR_AND_FAIL_SCRIPT_PATH="${CMAKE_CURRENT_SOURCE_DIR}/print_err_and_fail.sh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will just re-introduce the bugs fixed in #31542, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better option would be to use the test's temp dir as scratch space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will just re-introduce the bugs fixed in #31542, no?
Oops, forgot about it 🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better option would be to use the test's temp dir as scratch space
That doesn't work with the currently used std::string overload of subprocess::Popen() because of to the space in the full path. Is using fs::temp_directory_path() acceptable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does quoting not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subprocess uses space and tab as delimiters:
Lines 307 to 334 in 2df824f
| /*! | |
| * Function: split | |
| * Parameters: | |
| * [in] str : Input string which needs to be split based upon the | |
| * delimiters provided. | |
| * [in] deleims : Delimiter characters based upon which the string needs | |
| * to be split. Default constructed to ' '(space) and '\t'(tab) | |
| * [out] vector<string> : Vector of strings split at deleimiter. | |
| */ | |
| static inline std::vector<std::string> | |
| split(const std::string& str, const std::string& delims=" \t") | |
| { | |
| std::vector<std::string> res; | |
| size_t init = 0; | |
| while (true) { | |
| auto pos = str.find_first_of(delims, init); | |
| if (pos == std::string::npos) { | |
| res.emplace_back(str.substr(init, str.length())); | |
| break; | |
| } | |
| res.emplace_back(str.substr(init, pos - init)); | |
| pos++; | |
| init = pos; | |
| } | |
| return res; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it seems like it should be fixed in RunCommandParseJSON, because real users could run into the bug as well?
RunCommandParseJSON should just take a string and then pass it to the shell as-is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the approach in #32577.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it is unclear to me why it was closed, when it looks like the correct approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it is unclear to me why it was closed, when it looks like the correct approach
Reopened.
|
Probably close this now, if #32577 has been re-opened, and the approach here has been nacked for re-introducing bugs? |
This PR addresses two issues related to the "Return non-zero exit code, with error message for stderr" check in the
system_tests/run_commandtest:This is an alternative to #32577 without introducing a shell wrapper and altering quotation in
src/external_signer.cpp.The main idea is to avoid parsing the problematic
sh -c 'echo err 1>&2 && false'command withsubprocess::Popen.In the past, this check used:
bitcoin/src/test/system_tests.cpp
Lines 56 to 58 in 5abb9b1
which was problematic due to its dependence on the system locale.
Fixes #32574.