mirror of
https://github.com/NixOS/nix
synced 2025-06-29 02:11:15 +02:00
add DirectoryIterator to re-throw std::filesystem::filesystem_error
Co-authored-by: Sergei Zimmerman <145775305+xokdvium@users.noreply.github.com>
This commit is contained in:
parent
4548dd1abb
commit
7ccc0d591f
3 changed files with 109 additions and 0 deletions
|
@ -297,4 +297,25 @@ TEST(chmodIfNeeded, nonexistent)
|
|||
ASSERT_THROW(chmodIfNeeded("/schnitzel/darmstadt/pommes", 0755), SysError);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* DirectoryIterator
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
||||
TEST(DirectoryIterator, works)
|
||||
{
|
||||
auto tmpDir = nix::createTempDir();
|
||||
nix::AutoDelete delTmpDir(tmpDir, true);
|
||||
|
||||
nix::writeFile(tmpDir + "/somefile", "");
|
||||
|
||||
for (auto path : DirectoryIterator(tmpDir)) {
|
||||
ASSERT_EQ(path.path().string(), tmpDir + "/somefile");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DirectoryIterator, nonexistent)
|
||||
{
|
||||
ASSERT_THROW(DirectoryIterator("/schnitzel/darmstadt/pommes"), SysError);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue