diff --git a/src/libexpr-tests/nix_api_expr.cc b/src/libexpr-tests/nix_api_expr.cc index 026c89598..fdd09a449 100644 --- a/src/libexpr-tests/nix_api_expr.cc +++ b/src/libexpr-tests/nix_api_expr.cc @@ -49,7 +49,7 @@ TEST_F(nix_api_expr_test, nix_eval_state_lookup_path) auto pathStr = nix_get_path_string(ctx, value); 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); } diff --git a/src/libflake-tests/nix_api_flake.cc b/src/libflake-tests/nix_api_flake.cc index 84ac8eb40..ec690b812 100644 --- a/src/libflake-tests/nix_api_flake.cc +++ b/src/libflake-tests/nix_api_flake.cc @@ -121,8 +121,8 @@ TEST_F(nix_api_store_test, nix_api_load_flake) assert_ctx_ok(); ASSERT_NE(nullptr, parseFlags); - auto r0 = - nix_flake_reference_parse_flags_set_base_directory(ctx, parseFlags, tmpDir.c_str(), tmpDir.string().size()); + auto r0 = nix_flake_reference_parse_flags_set_base_directory( + ctx, parseFlags, tmpDir.string().c_str(), tmpDir.string().size()); assert_ctx_ok(); 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_NE(nullptr, parseFlags); - auto r0 = - nix_flake_reference_parse_flags_set_base_directory(ctx, parseFlags, tmpDir.c_str(), tmpDir.string().size()); + auto r0 = nix_flake_reference_parse_flags_set_base_directory( + ctx, parseFlags, tmpDir.string().c_str(), tmpDir.string().size()); assert_ctx_ok(); ASSERT_EQ(NIX_OK, r0); diff --git a/src/libstore-test-support/include/nix/store/tests/nix_api_store.hh b/src/libstore-test-support/include/nix/store/tests/nix_api_store.hh index 829972d84..a35d2b1ee 100644 --- a/src/libstore-test-support/include/nix/store/tests/nix_api_store.hh +++ b/src/libstore-test-support/include/nix/store/tests/nix_api_store.hh @@ -41,9 +41,9 @@ protected: { #ifdef _WIN32 // 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) { - nixDir = tmpl + std::string{i}; + nixDir = tmpl.string() + std::to_string(i); if (std::filesystem::create_directory(nixDir)) break; } diff --git a/src/libstore-tests/nar-info-disk-cache.cc b/src/libstore-tests/nar-info-disk-cache.cc index 98a94b91e..b925a4a1e 100644 --- a/src/libstore-tests/nar-info-disk-cache.cc +++ b/src/libstore-tests/nar-info-disk-cache.cc @@ -14,9 +14,9 @@ TEST(NarInfoDiskCacheImpl, create_and_read) int prio = 12345; bool wantMassQuery = true; - Path tmpDir = createTempDir(); + auto tmpDir = createTempDir(); AutoDelete delTmpDir(tmpDir); - Path dbPath(tmpDir + "/test-narinfo-disk-cache.sqlite"); + auto dbPath(tmpDir / "test-narinfo-disk-cache.sqlite"); int savedId; int barId; @@ -24,7 +24,7 @@ TEST(NarInfoDiskCacheImpl, create_and_read) SQLiteStmt getIds; { - auto cache = getTestNarInfoDiskCache(dbPath); + auto cache = getTestNarInfoDiskCache(dbPath.string()); // 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 // more realistic anyway. - auto cache2 = getTestNarInfoDiskCache(dbPath); + auto cache2 = getTestNarInfoDiskCache(dbPath.string()); { auto r = cache2->upToDateCacheExists("http://foo"); diff --git a/src/libstore-tests/nix_api_store.cc b/src/libstore-tests/nix_api_store.cc index 142f648d3..ea600f905 100644 --- a/src/libstore-tests/nix_api_store.cc +++ b/src/libstore-tests/nix_api_store.cc @@ -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) { auto tmp = nix::createTempDir(); - std::string storeRoot = tmp / "store"; - std::string stateDir = tmp / "state"; - std::string logDir = tmp / "log"; + auto storeRoot = (tmp / "store").string(); + auto stateDir = (tmp / "state").string(); + auto logDir = (tmp / "log").string(); const char * rootkv[] = {"root", storeRoot.c_str()}; const char * statekv[] = {"state", stateDir.c_str()}; const char * logkv[] = {"log", logDir.c_str()}; diff --git a/src/libutil-tests/file-system.cc b/src/libutil-tests/file-system.cc index d5b810110..1551227cb 100644 --- a/src/libutil-tests/file-system.cc +++ b/src/libutil-tests/file-system.cc @@ -307,10 +307,10 @@ TEST(DirectoryIterator, works) auto tmpDir = nix::createTempDir(); nix::AutoDelete delTmpDir(tmpDir, true); - nix::writeFile(tmpDir + "/somefile", ""); + nix::writeFile(tmpDir / "somefile", ""); 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) { auto fd = createAnonymousTempFile(); + auto fd_ = fromDescriptorReadOnly(fd.get()); writeFull(fd.get(), "test"); - lseek(fd.get(), 0, SEEK_SET); + lseek(fd_, 0, SEEK_SET); FdSource source{fd.get()}; EXPECT_EQ(source.drain(), "test"); - lseek(fd.get(), 0, SEEK_END); + lseek(fd_, 0, SEEK_END); writeFull(fd.get(), "test"); - lseek(fd.get(), 0, SEEK_SET); + lseek(fd_, 0, SEEK_SET); EXPECT_EQ(source.drain(), "testtest"); } @@ -405,8 +406,9 @@ TEST(createAnonymousTempFile, works) TEST(FdSource, restartWorks) { auto fd = createAnonymousTempFile(); + auto fd_ = fromDescriptorReadOnly(fd.get()); writeFull(fd.get(), "hello world"); - lseek(fd.get(), 0, SEEK_SET); + lseek(fd_, 0, SEEK_SET); FdSource source{fd.get()}; EXPECT_EQ(source.drain(), "hello world"); source.restart();