Skip to content

Commit

Permalink
Add libsolv database test
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv committed Feb 9, 2024
1 parent 59169ef commit f0f486e
Show file tree
Hide file tree
Showing 5 changed files with 1,029 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libmamba/include/mamba/solver/libsolv/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ namespace mamba::solver::libsolv

void remove_repo(RepoInfo repo);

[[nodiscard]] auto repo_count() const -> std::size_t;

[[nodiscard]] auto package_count() const -> std::size_t;

template <typename Func>
void for_each_package_in_repo(RepoInfo repo, Func&&) const;

Expand Down
10 changes: 10 additions & 0 deletions libmamba/src/solver/libsolv/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ namespace mamba::solver::libsolv
pool().remove_repo(repo.id(), /* reuse_ids= */ true);
}

auto Database::repo_count() const -> std::size_t
{
return pool().repo_count();
}

auto Database::package_count() const -> std::size_t
{
return pool().solvable_count();
}

auto Database::installed_repo() const -> std::optional<RepoInfo>
{
if (auto repo = pool().installed_repo())
Expand Down
13 changes: 12 additions & 1 deletion libmamba/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ set(
src/solver/test_request.cpp
src/solver/test_solution.cpp
src/solver/test_problems_graph.cpp
# Solver libsolv implementation tests
src/solver/libsolv/test_database.cpp
# Artifacts validation
src/validation/test_tools.cpp
src/validation/test_update_framework_v0_6.cpp
Expand Down Expand Up @@ -105,7 +107,16 @@ target_link_libraries(
)

# Copy data directory into binary dir to avoid modifications
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/data" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_target(
test_libmamba_data
COMMENT "Copying libmamba tests data"
COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/data"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/data"
COMMAND
"${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/data"
"${CMAKE_CURRENT_BINARY_DIR}/data"
)
add_dependencies(test_libmamba test_libmamba_data)

target_compile_definitions(
test_libmamba
Expand Down
Loading

0 comments on commit f0f486e

Please sign in to comment.