Merge #20932: refactor: Replace fs::absolute calls with AbsPathJoin calls

da9caa1ced Replace fs::absolute calls with AbsPathJoin calls (Kiminuo)
66576c4fd5 test: Clear forced -walletdir setting after wallet init_tests (Kiminuo)

Pull request description:

  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.

ACKs for top commit:
  jonatack:
    Code review ACK da9caa1ced only doxygen improvements since my last review per `git diff d867d7a da9caa1`
  MarcoFalke:
    review ACK da9caa1ced 📯
  ryanofsky:
    Code review ACK da9caa1ced. Just comment and test tweaks since previous review.

Tree-SHA512: c940ee60f3ba374d4927cf34cf12d27c4c735c94af591fbc0ca408c641b30f8f8fbcfe521d66bfbddf9877a1fc8cd99bd8a47ebcd2fa59789de6bd87a7b9cf4d
This commit is contained in:
MarcoFalke
2021-01-21 18:47:57 +01:00
9 changed files with 45 additions and 7 deletions

View File

@@ -52,6 +52,23 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream)
file >> input_buffer;
BOOST_CHECK_EQUAL(input_buffer, "bitcoin");
}
{
// Join an absolute path and a relative path.
fs::path p = fsbridge::AbsPathJoin(tmpfolder, "fs_tests_₿_🏃");
BOOST_CHECK(p.is_absolute());
BOOST_CHECK_EQUAL(tmpfile1, p);
}
{
// Join two absolute paths.
fs::path p = fsbridge::AbsPathJoin(tmpfile1, tmpfile2);
BOOST_CHECK(p.is_absolute());
BOOST_CHECK_EQUAL(tmpfile2, p);
}
{
// Ensure joining with empty paths does not add trailing path components.
BOOST_CHECK_EQUAL(tmpfile1, fsbridge::AbsPathJoin(tmpfile1, ""));
BOOST_CHECK_EQUAL(tmpfile1, fsbridge::AbsPathJoin(tmpfile1, {}));
}
}
BOOST_AUTO_TEST_SUITE_END()