mirror of
https://github.com/NixOS/nix.git
synced 2025-12-13 20:41:04 +01:00
libutil: Get rid of restartableSourceFromFactory
Instead we can just seek back in the file - duh. Also this makes use of the anonymous temp file facility, since that is much safer (no need window where the we don't have an open file descriptor for it).
This commit is contained in:
parent
4ad272015e
commit
4b3536e092
4 changed files with 43 additions and 73 deletions
|
|
@ -398,4 +398,20 @@ TEST(createAnonymousTempFile, works)
|
|||
EXPECT_EQ(source.drain(), "testtest");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* FdSource
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
||||
TEST(FdSource, restartWorks)
|
||||
{
|
||||
auto fd = createAnonymousTempFile();
|
||||
writeFull(fd.get(), "hello world");
|
||||
lseek(fd.get(), 0, SEEK_SET);
|
||||
FdSource source{fd.get()};
|
||||
EXPECT_EQ(source.drain(), "hello world");
|
||||
source.restart();
|
||||
EXPECT_EQ(source.drain(), "hello world");
|
||||
EXPECT_EQ(source.drain(), "");
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue