1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 14:21:48 +02:00

More support for std::filepath in libnixutil

We're not replacing `Path` in exposed definitions in many cases, but
just adding alternatives. This will allow us to "top down" change `Path`
to `std::fileysystem::path`, and then we can remove the `Path`-using
utilities which will become unused.

Also add some test files which we forgot to include in the libutil unit
tests `meson.build`.

Co-Authored-By: siddhantCodes <siddhantk232@gmail.com>
This commit is contained in:
John Ericson 2024-08-26 12:24:37 -04:00
parent dbabfc92d4
commit a97a08411c
37 changed files with 258 additions and 120 deletions

View file

@ -13,7 +13,7 @@ namespace nix {
* The path to the unit test data directory. See the contributing guide
* in the manual for further details.
*/
static inline Path getUnitTestData() {
static inline std::filesystem::path getUnitTestData() {
return getEnv("_NIX_TEST_UNIT_DATA").value();
}
@ -36,7 +36,7 @@ protected:
* While the "golden master" for this characterization test is
* located. It should not be shared with any other test.
*/
virtual Path goldenMaster(PathView testStem) const = 0;
virtual std::filesystem::path goldenMaster(PathView testStem) const = 0;
public:
/**
@ -77,7 +77,7 @@ public:
if (testAccept())
{
createDirs(dirOf(file));
std::filesystem::create_directories(file.parent_path());
writeFile2(file, got);
GTEST_SKIP()
<< "Updating golden master "
@ -97,10 +97,10 @@ public:
{
writeTest(
testStem, test,
[](const Path & f) -> std::string {
[](const std::filesystem::path & f) -> std::string {
return readFile(f);
},
[](const Path & f, const std::string & c) {
[](const std::filesystem::path & f, const std::string & c) {
return writeFile(f, c);
});
}