Skip to content

Commit 7a743c3

Browse files
committed
fix(catalog_tests): use test_data dir for save/load temp file
mkstemp with /tmp path fails on some CI runners. Use test_data directory instead, with mkstemp fallback to fixed path.
1 parent c3d51d2 commit 7a743c3

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

tests/catalog_coverage_tests.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,20 @@ TEST(CatalogCoverageTests, SaveAndLoad) {
241241
std::vector<ColumnInfo> cols = {{"id", common::ValueType::TYPE_INT64, 0}};
242242
catalog->create_table("persisted_table", cols);
243243

244-
// Use mkstemp to create a unique temp file atomically
245-
std::string temp_template = "/tmp/test_catalog_XXXXXX.bin";
244+
// Use a unique path in test_data directory (mkstemp may fail on some CI runners)
245+
std::string temp_template = "./test_data/save_load_test_XXXXXX.bin";
246246
std::vector<char> temp_path_vec(temp_template.begin(), temp_template.end());
247-
temp_path_vec.push_back('\0'); // null-terminate for mkstemp
247+
temp_path_vec.push_back('\0');
248248
int fd = mkstemp(temp_path_vec.data());
249-
ASSERT_NE(fd, -1);
250-
std::filesystem::path temp_path(temp_path_vec.data());
251-
close(fd); // Close the file descriptor, we only need the path
249+
std::string temp_path;
250+
if (fd != -1) {
251+
temp_path = std::string(temp_path_vec.data());
252+
close(fd);
253+
} else {
254+
// Fallback: use a fixed path if mkstemp fails
255+
temp_path = std::string("./test_data/save_load_test_fallback.bin");
256+
std::filesystem::remove(temp_path);
257+
}
252258

253259
// Save catalog - should succeed
254260
ASSERT_TRUE(catalog->save(temp_path.string()));

0 commit comments

Comments
 (0)