diff --git a/CMakeLists.txt b/CMakeLists.txt index b03b70b..354084f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -327,16 +327,11 @@ endif() include(CTest) include(Catch) if(BUILD_TESTING) - if(APPLE) - # On macOS, only build tests for debug builds - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - add_subdirectory(test/cpp) - endif() - elseif(CMAKE_CROSSCOMPILING) + if(CMAKE_CROSSCOMPILING) # Skip running tests when cross-compiling message(STATUS "Skipping tests during cross-compilation") else() - # On other platforms (Linux), build tests for all configurations + # Build tests for all platforms and configurations add_subdirectory(test/cpp) endif() endif() diff --git a/src/caching_file_provider.cpp b/src/caching_file_provider.cpp index 79f9cea..950ed0c 100644 --- a/src/caching_file_provider.cpp +++ b/src/caching_file_provider.cpp @@ -111,16 +111,18 @@ std::string CachingFileProvider::ReadFile(const std::string& path) { evictLRU(content_size); } - // Add to cache + // Add to cache only if not already inserted by a concurrent thread CacheEntry entry; entry.content = content; entry.expires_at = std::chrono::steady_clock::now() + _config.ttl; entry.last_access = std::chrono::steady_clock::now(); entry.size_bytes = content_size; - _cache[path] = std::move(entry); - _stats.current_entries.fetch_add(1); - _stats.current_size_bytes.fetch_add(content_size); + auto [it, inserted] = _cache.emplace(path, std::move(entry)); + if (inserted) { + _stats.current_entries.fetch_add(1); + _stats.current_size_bytes.fetch_add(content_size); + } } return content; diff --git a/test/integration/pyproject.toml b/test/integration/pyproject.toml index fcc40fd..3a1e618 100644 --- a/test/integration/pyproject.toml +++ b/test/integration/pyproject.toml @@ -1,3 +1,10 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +packages = [] + [project] name = "flapi-integration-tests" version = "0.1.0" @@ -20,9 +27,6 @@ dependencies = [ "psutil>=5.9.0", ] -[tool.setuptools] -packages = [] - [tool.pytest.ini_options] addopts = "-v" testpaths = ["."]