Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add (some) solver Database tests #3185

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions libmamba/include/mamba/api/install.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ namespace mamba
class PackageInfo;
}

namespace solver::libsolv
{
class DataBase;
}

void install(Configuration& config);

void install_specs(
Expand Down
5 changes: 0 additions & 5 deletions libmamba/include/mamba/api/repoquery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

namespace mamba
{
namespace solver::libsolv
{
class DataBase;
}

enum class QueryResultFormat
{
Json = 0,
Expand Down
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
15 changes: 14 additions & 1 deletion libmamba/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ set(
src/specs/test_version.cpp
src/specs/test_version_spec.cpp
# Solver tests
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 @@ -103,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
Loading