-
Notifications
You must be signed in to change notification settings - Fork 38.7k
refactor: Replace fs::absolute calls with AbsPathJoin calls #20932
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
9422f47 to
c0da745
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
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.
ACK c0da745683
The PR title should probably be prefixed with "refactor:" -> Edit: I see you just did it :)
A few suggestions below, happy to re-review if you take them.
ryanofsky
left a comment
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.
Conditional code review ACK c0da7456833fac6d5613d97e09266cf54f13594f if appveyor CreateWallet test is fixed:
C:\projects\bitcoin\src\wallet\test\wallet_tests.cpp(696): Entering test case "CreateWallet"
Assertion failed: base.is_absolute(), file C:\projects\bitcoin\src\fs.cpp, line 36
Command exited with code -1073740791
I think it probably needs some extra test setup (maybe a call to GetDataDir()) to avoid the failure.
|
I'm able to reproduce appveyor failure on linux with To reproduce, it may be necessary to vary the random seed to get CreateWallet test to run after the init_tests as happens on appveyor. The problem seems to be that init_tests force set a -walletdir that GetWalletDir rejects and turns into an empty path, which gets rejected by the assert because it is not absolute. Probably a minimal fix is possible in init_tests. Backtrace at assert fail looks like |
|
Following fix seems to work: --- a/src/wallet/test/init_test_fixture.cpp
+++ b/src/wallet/test/init_test_fixture.cpp
@@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <fs.h>
+#include <univalue.h>
#include <util/check.h>
#include <util/system.h>
@@ -37,6 +38,9 @@ InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainNam
InitWalletDirTestingSetup::~InitWalletDirTestingSetup()
{
+ gArgs.LockSettings([&](util::Settings& settings) {
+ settings.forced_settings.erase("walletdir");
+ });
fs::current_path(m_cwd);
}
Would suggest commit message like:
|
|
re: #20932 (comment)
Would suggest writing a self-contained PR description that doesn't require reading a comment in another issue to understand. Something like: refactor: Replace fs::absolute calls with AbsPathJoin calls This adds better test coverage and will make it easier in #20744 to remove our dependency on the two-argument This PR doesn't change behavior aside from adding an assert and fixing a test bug. |
8fbb7a8 to
215c784
Compare
ryanofsky
left a comment
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.
Code review ACK 215c784. Thanks for updates!
felipsoarez
left a comment
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.
Concept ACK
Leaving this value set interfered with the CreateWallet test if it happened to execute later in the test ordering. Specifically it would cause CreateWallet test to write data to the current directory instead of temporary test directory.
215c784 to
d867d7a
Compare
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.
ACK d867d7a64c5c modulo two comments based on ryanofsky's excellent feedback in #20932 (comment) "If desired, could also add preconditions and postconditions (base path must be absolute, returned path will always be absolute)."
This adds better test coverage and will make it easier in bitcoin#20744 to remove our dependency on the two-argument boost::filesystem::absolute() function which does not have a direct equivalent in C++17.
d867d7a to
da9caa1
Compare
ryanofsky
left a comment
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.
Code review ACK da9caa1. Just comment and test tweaks since previous review.
Final change is very simple and easy to review, and I think makes code more understandable and improves tests. Thanks for implementing this!
|
Code review ACK da9caa1 only doxygen improvements since my last review per Thanks for updating. |
|
review ACK da9caa1 📯 Show signature and timestampSignature: Timestamp of file with hash |
This adds better test coverage and will make it easier in #20744 to remove our dependency on the two-argument boost::filesystem::absolute() function which does not have a direct equivalent in C++17.
This PR doesn't change behavior aside from adding an assert and fixing a test bug.