mirror of
https://github.com/NixOS/nix.git
synced 2025-12-09 10:31:02 +01:00
commit
a595348f7c
6 changed files with 22 additions and 20 deletions
|
|
@ -49,7 +49,7 @@ TEST_F(nix_api_expr_test, nix_eval_state_lookup_path)
|
||||||
|
|
||||||
auto pathStr = nix_get_path_string(ctx, value);
|
auto pathStr = nix_get_path_string(ctx, value);
|
||||||
assert_ctx_ok();
|
assert_ctx_ok();
|
||||||
ASSERT_EQ(0, strcmp(pathStr, nixpkgs.c_str()));
|
ASSERT_EQ(0, strcmp(pathStr, nixpkgs.string().c_str()));
|
||||||
|
|
||||||
nix_gc_decref(nullptr, value);
|
nix_gc_decref(nullptr, value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,8 @@ TEST_F(nix_api_store_test, nix_api_load_flake)
|
||||||
assert_ctx_ok();
|
assert_ctx_ok();
|
||||||
ASSERT_NE(nullptr, parseFlags);
|
ASSERT_NE(nullptr, parseFlags);
|
||||||
|
|
||||||
auto r0 =
|
auto r0 = nix_flake_reference_parse_flags_set_base_directory(
|
||||||
nix_flake_reference_parse_flags_set_base_directory(ctx, parseFlags, tmpDir.c_str(), tmpDir.string().size());
|
ctx, parseFlags, tmpDir.string().c_str(), tmpDir.string().size());
|
||||||
assert_ctx_ok();
|
assert_ctx_ok();
|
||||||
ASSERT_EQ(NIX_OK, r0);
|
ASSERT_EQ(NIX_OK, r0);
|
||||||
|
|
||||||
|
|
@ -231,8 +231,8 @@ TEST_F(nix_api_store_test, nix_api_load_flake_with_flags)
|
||||||
assert_ctx_ok();
|
assert_ctx_ok();
|
||||||
ASSERT_NE(nullptr, parseFlags);
|
ASSERT_NE(nullptr, parseFlags);
|
||||||
|
|
||||||
auto r0 =
|
auto r0 = nix_flake_reference_parse_flags_set_base_directory(
|
||||||
nix_flake_reference_parse_flags_set_base_directory(ctx, parseFlags, tmpDir.c_str(), tmpDir.string().size());
|
ctx, parseFlags, tmpDir.string().c_str(), tmpDir.string().size());
|
||||||
assert_ctx_ok();
|
assert_ctx_ok();
|
||||||
ASSERT_EQ(NIX_OK, r0);
|
ASSERT_EQ(NIX_OK, r0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ protected:
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// no `mkdtemp` with MinGW
|
// no `mkdtemp` with MinGW
|
||||||
auto tmpl = nix::defaultTempDir() + "/tests_nix-store.";
|
auto tmpl = nix::defaultTempDir() / "tests_nix-store.";
|
||||||
for (size_t i = 0; true; ++i) {
|
for (size_t i = 0; true; ++i) {
|
||||||
nixDir = tmpl + std::string{i};
|
nixDir = tmpl.string() + std::to_string(i);
|
||||||
if (std::filesystem::create_directory(nixDir))
|
if (std::filesystem::create_directory(nixDir))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ TEST(NarInfoDiskCacheImpl, create_and_read)
|
||||||
int prio = 12345;
|
int prio = 12345;
|
||||||
bool wantMassQuery = true;
|
bool wantMassQuery = true;
|
||||||
|
|
||||||
Path tmpDir = createTempDir();
|
auto tmpDir = createTempDir();
|
||||||
AutoDelete delTmpDir(tmpDir);
|
AutoDelete delTmpDir(tmpDir);
|
||||||
Path dbPath(tmpDir + "/test-narinfo-disk-cache.sqlite");
|
auto dbPath(tmpDir / "test-narinfo-disk-cache.sqlite");
|
||||||
|
|
||||||
int savedId;
|
int savedId;
|
||||||
int barId;
|
int barId;
|
||||||
|
|
@ -24,7 +24,7 @@ TEST(NarInfoDiskCacheImpl, create_and_read)
|
||||||
SQLiteStmt getIds;
|
SQLiteStmt getIds;
|
||||||
|
|
||||||
{
|
{
|
||||||
auto cache = getTestNarInfoDiskCache(dbPath);
|
auto cache = getTestNarInfoDiskCache(dbPath.string());
|
||||||
|
|
||||||
// Set up "background noise" and check that different caches receive different ids
|
// Set up "background noise" and check that different caches receive different ids
|
||||||
{
|
{
|
||||||
|
|
@ -73,7 +73,7 @@ TEST(NarInfoDiskCacheImpl, create_and_read)
|
||||||
{
|
{
|
||||||
// We can't clear the in-memory cache, so we use a new cache object. This is
|
// We can't clear the in-memory cache, so we use a new cache object. This is
|
||||||
// more realistic anyway.
|
// more realistic anyway.
|
||||||
auto cache2 = getTestNarInfoDiskCache(dbPath);
|
auto cache2 = getTestNarInfoDiskCache(dbPath.string());
|
||||||
|
|
||||||
{
|
{
|
||||||
auto r = cache2->upToDateCacheExists("http://foo");
|
auto r = cache2->upToDateCacheExists("http://foo");
|
||||||
|
|
|
||||||
|
|
@ -212,9 +212,9 @@ TEST_F(nix_api_store_test, nix_store_real_path)
|
||||||
TEST_F(nix_api_util_context, nix_store_real_path_relocated)
|
TEST_F(nix_api_util_context, nix_store_real_path_relocated)
|
||||||
{
|
{
|
||||||
auto tmp = nix::createTempDir();
|
auto tmp = nix::createTempDir();
|
||||||
std::string storeRoot = tmp / "store";
|
auto storeRoot = (tmp / "store").string();
|
||||||
std::string stateDir = tmp / "state";
|
auto stateDir = (tmp / "state").string();
|
||||||
std::string logDir = tmp / "log";
|
auto logDir = (tmp / "log").string();
|
||||||
const char * rootkv[] = {"root", storeRoot.c_str()};
|
const char * rootkv[] = {"root", storeRoot.c_str()};
|
||||||
const char * statekv[] = {"state", stateDir.c_str()};
|
const char * statekv[] = {"state", stateDir.c_str()};
|
||||||
const char * logkv[] = {"log", logDir.c_str()};
|
const char * logkv[] = {"log", logDir.c_str()};
|
||||||
|
|
|
||||||
|
|
@ -307,10 +307,10 @@ TEST(DirectoryIterator, works)
|
||||||
auto tmpDir = nix::createTempDir();
|
auto tmpDir = nix::createTempDir();
|
||||||
nix::AutoDelete delTmpDir(tmpDir, true);
|
nix::AutoDelete delTmpDir(tmpDir, true);
|
||||||
|
|
||||||
nix::writeFile(tmpDir + "/somefile", "");
|
nix::writeFile(tmpDir / "somefile", "");
|
||||||
|
|
||||||
for (auto path : DirectoryIterator(tmpDir)) {
|
for (auto path : DirectoryIterator(tmpDir)) {
|
||||||
ASSERT_EQ(path.path().string(), tmpDir + "/somefile");
|
ASSERT_EQ(path.path(), tmpDir / "somefile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -388,13 +388,14 @@ TEST(openFileEnsureBeneathNoSymlinks, works)
|
||||||
TEST(createAnonymousTempFile, works)
|
TEST(createAnonymousTempFile, works)
|
||||||
{
|
{
|
||||||
auto fd = createAnonymousTempFile();
|
auto fd = createAnonymousTempFile();
|
||||||
|
auto fd_ = fromDescriptorReadOnly(fd.get());
|
||||||
writeFull(fd.get(), "test");
|
writeFull(fd.get(), "test");
|
||||||
lseek(fd.get(), 0, SEEK_SET);
|
lseek(fd_, 0, SEEK_SET);
|
||||||
FdSource source{fd.get()};
|
FdSource source{fd.get()};
|
||||||
EXPECT_EQ(source.drain(), "test");
|
EXPECT_EQ(source.drain(), "test");
|
||||||
lseek(fd.get(), 0, SEEK_END);
|
lseek(fd_, 0, SEEK_END);
|
||||||
writeFull(fd.get(), "test");
|
writeFull(fd.get(), "test");
|
||||||
lseek(fd.get(), 0, SEEK_SET);
|
lseek(fd_, 0, SEEK_SET);
|
||||||
EXPECT_EQ(source.drain(), "testtest");
|
EXPECT_EQ(source.drain(), "testtest");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -405,8 +406,9 @@ TEST(createAnonymousTempFile, works)
|
||||||
TEST(FdSource, restartWorks)
|
TEST(FdSource, restartWorks)
|
||||||
{
|
{
|
||||||
auto fd = createAnonymousTempFile();
|
auto fd = createAnonymousTempFile();
|
||||||
|
auto fd_ = fromDescriptorReadOnly(fd.get());
|
||||||
writeFull(fd.get(), "hello world");
|
writeFull(fd.get(), "hello world");
|
||||||
lseek(fd.get(), 0, SEEK_SET);
|
lseek(fd_, 0, SEEK_SET);
|
||||||
FdSource source{fd.get()};
|
FdSource source{fd.get()};
|
||||||
EXPECT_EQ(source.drain(), "hello world");
|
EXPECT_EQ(source.drain(), "hello world");
|
||||||
source.restart();
|
source.restart();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue