]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
test: Don't leave fs_test.tmp* files after InodeCache unit tests
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 1 Apr 2024 19:24:14 +0000 (21:24 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 1 Apr 2024 19:33:34 +0000 (21:33 +0200)
unittest/test_InodeCache.cpp

index 5e9cd8068a237c0df8fd4a18e47df9646e1408ca..41a9c348c5a81d3dab2fbdb0e880e56b2d5154a1 100644 (file)
@@ -25,6 +25,7 @@
 #include <ccache/util/Fd.hpp>
 #include <ccache/util/TemporaryFile.hpp>
 #include <ccache/util/file.hpp>
+#include <ccache/util/filesystem.hpp>
 #include <ccache/util/path.hpp>
 
 #include <doctest.h>
@@ -32,6 +33,8 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+namespace fs = util::filesystem;
+
 using TestUtil::TestContext;
 
 namespace {
@@ -40,7 +43,12 @@ bool
 inode_cache_available()
 {
   auto tmp_file = util::TemporaryFile::create(util::actual_cwd() + "/fs_test");
-  return tmp_file && tmp_file->fd && InodeCache::available(*tmp_file->fd);
+  if (!tmp_file) {
+    return false;
+  }
+  bool available = tmp_file->fd && InodeCache::available(*tmp_file->fd);
+  fs::remove(tmp_file->path);
+  return available;
 }
 
 void