mirror of https://github.com/mamba-org/mamba.git
Structure test directory layout (#2380)
* Clean test layout * Copy test data before run
This commit is contained in:
parent
b52484cd74
commit
aa8d28c6c5
|
@ -1,4 +1,4 @@
|
|||
exclude: libmamba/tests/repodata_json_cache*
|
||||
exclude: libmamba/tests/data/repodata_json_cache*
|
||||
repos:
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.12.0
|
||||
|
|
|
@ -1,51 +1,50 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
|
||||
add_executable(testing_libmamba_lock testing/lock.cpp)
|
||||
add_executable(testing_libmamba_lock libmamba_lock/lock.cpp)
|
||||
|
||||
target_link_libraries(testing_libmamba_lock PUBLIC libmamba)
|
||||
|
||||
target_compile_features(testing_libmamba_lock PUBLIC cxx_std_17)
|
||||
|
||||
mamba_target_add_compile_warnings(testing_libmamba_lock WARNING_AS_ERROR ${MAMBA_WARNING_AS_ERROR})
|
||||
|
||||
find_package(GTest)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
set(LIBMAMBA_TEST_SRCS
|
||||
# C++ wrapping of libsolv
|
||||
solv-cpp/test_queue.cpp
|
||||
src/solv-cpp/test_queue.cpp
|
||||
# Implementation of version and matching specs
|
||||
specs/test_version.cpp
|
||||
src/specs/test_version.cpp
|
||||
|
||||
../longpath.manifest
|
||||
test_activation.cpp
|
||||
test_channel.cpp
|
||||
test_configuration.cpp
|
||||
test_cpp.cpp
|
||||
test_env_file_reading.cpp
|
||||
test_environments_manager.cpp
|
||||
history_test/test_history.cpp
|
||||
test_lockfile.cpp
|
||||
test_pinning.cpp
|
||||
test_output.cpp
|
||||
test_progress_bar.cpp
|
||||
test_shell_init.cpp
|
||||
test_thread_utils.cpp
|
||||
test_transfer.cpp
|
||||
test_url.cpp
|
||||
test_validate.cpp
|
||||
test_virtual_packages.cpp
|
||||
test_util.cpp
|
||||
test_util_cast.cpp
|
||||
test_util_compare.cpp
|
||||
test_util_string.cpp
|
||||
test_util_graph.cpp
|
||||
test_env_lockfile.cpp
|
||||
test_execution.cpp
|
||||
test_invoke.cpp
|
||||
test_tasksync.cpp
|
||||
test_filesystem.cpp
|
||||
test_satisfiability_error.cpp
|
||||
src/core/test_activation.cpp
|
||||
src/core/test_channel.cpp
|
||||
src/core/test_configuration.cpp
|
||||
src/core/test_cpp.cpp
|
||||
src/core/test_env_file_reading.cpp
|
||||
src/core/test_environments_manager.cpp
|
||||
src/core/test_history.cpp
|
||||
src/core/test_lockfile.cpp
|
||||
src/core/test_pinning.cpp
|
||||
src/core/test_output.cpp
|
||||
src/core/test_progress_bar.cpp
|
||||
src/core/test_shell_init.cpp
|
||||
src/core/test_thread_utils.cpp
|
||||
src/core/test_transfer.cpp
|
||||
src/core/test_url.cpp
|
||||
src/core/test_validate.cpp
|
||||
src/core/test_virtual_packages.cpp
|
||||
src/core/test_util.cpp
|
||||
src/core/test_util_cast.cpp
|
||||
src/core/test_util_compare.cpp
|
||||
src/core/test_util_string.cpp
|
||||
src/core/test_util_graph.cpp
|
||||
src/core/test_env_lockfile.cpp
|
||||
src/core/test_execution.cpp
|
||||
src/core/test_invoke.cpp
|
||||
src/core/test_tasksync.cpp
|
||||
src/core/test_filesystem.cpp
|
||||
src/core/test_satisfiability_error.cpp
|
||||
)
|
||||
|
||||
message(STATUS "Building libmamba C++ tests")
|
||||
|
@ -55,20 +54,26 @@ mamba_target_add_compile_warnings(test_libmamba WARNING_AS_ERROR ${MAMBA_WARNING
|
|||
|
||||
target_include_directories(
|
||||
test_libmamba
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/libmamba/src"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/libmamba/src"
|
||||
)
|
||||
|
||||
find_package(GTest REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
target_link_libraries(
|
||||
test_libmamba
|
||||
PUBLIC libmamba
|
||||
PRIVATE GTest::GTest GTest::Main Threads::Threads
|
||||
)
|
||||
|
||||
# Copy data directory into binary dir to avoid modifications
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/data" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
target_compile_definitions(
|
||||
test_libmamba
|
||||
PRIVATE
|
||||
MAMBA_TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
MAMBA_TEST_LOCK_EXE="${CMAKE_CURRENT_BINARY_DIR}/testing_libmamba_lock"
|
||||
MAMBA_TEST_DATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data"
|
||||
MAMBA_TEST_LOCK_EXE="$<TARGET_FILE:testing_libmamba_lock>"
|
||||
)
|
||||
|
||||
target_compile_features(test_libmamba PUBLIC cxx_std_17)
|
||||
|
|
|
@ -1049,13 +1049,13 @@ namespace mamba
|
|||
{
|
||||
using namespace detail;
|
||||
|
||||
fs::u8path p = test_data_dir / "config_test/.condarc";
|
||||
fs::u8path p = test_data_dir / "config/.condarc";
|
||||
|
||||
std::vector<fs::u8path> wrong_paths = {
|
||||
test_data_dir / "config_test",
|
||||
test_data_dir / "conf_test",
|
||||
test_data_dir / "config_test/condarc",
|
||||
test_data_dir / "history_test/conda-meta/history",
|
||||
test_data_dir / "config",
|
||||
test_data_dir / "conf",
|
||||
test_data_dir / "config/condarc",
|
||||
test_data_dir / "history/conda-meta/history",
|
||||
};
|
||||
|
||||
EXPECT_TRUE(is_config_file(p));
|
|
@ -36,13 +36,13 @@ namespace mamba
|
|||
TEST(env_file_reading, specs_selection)
|
||||
{
|
||||
using V = std::vector<std::string>;
|
||||
auto res = detail::read_yaml_file(test_data_dir / "env_file_test/env_1.yaml");
|
||||
auto res = detail::read_yaml_file(test_data_dir / "env_file/env_1.yaml");
|
||||
EXPECT_EQ(res.name, "env_1");
|
||||
EXPECT_EQ(res.channels, V({ "conda-forge", "bioconda" }));
|
||||
EXPECT_EQ(res.dependencies, V({ "test1", "test2", "test3" }));
|
||||
EXPECT_FALSE(res.others_pkg_mgrs_specs.size());
|
||||
|
||||
auto res2 = detail::read_yaml_file(test_data_dir / "env_file_test/env_2.yaml");
|
||||
auto res2 = detail::read_yaml_file(test_data_dir / "env_file/env_2.yaml");
|
||||
EXPECT_EQ(res2.name, "env_2");
|
||||
EXPECT_EQ(res2.channels, V({ "conda-forge", "bioconda" }));
|
||||
#ifdef __linux__
|
||||
|
@ -58,7 +58,7 @@ namespace mamba
|
|||
TEST(env_file_reading, external_pkg_mgrs)
|
||||
{
|
||||
using V = std::vector<std::string>;
|
||||
auto res = detail::read_yaml_file(test_data_dir / "env_file_test/env_3.yaml");
|
||||
auto res = detail::read_yaml_file(test_data_dir / "env_file/env_3.yaml");
|
||||
EXPECT_EQ(res.name, "env_3");
|
||||
EXPECT_EQ(res.channels, V({ "conda-forge", "bioconda" }));
|
||||
EXPECT_EQ(res.dependencies, V({ "test1", "test2", "test3", "pip" }));
|
||||
|
@ -67,7 +67,7 @@ namespace mamba
|
|||
auto o = res.others_pkg_mgrs_specs[0];
|
||||
EXPECT_EQ(o.pkg_mgr, "pip");
|
||||
EXPECT_EQ(o.deps, V({ "pytest", "numpy" }));
|
||||
EXPECT_EQ(o.cwd, fs::absolute(test_data_dir / "env_file_test"));
|
||||
EXPECT_EQ(o.cwd, fs::absolute(test_data_dir / "env_file"));
|
||||
}
|
||||
|
||||
} // namespace mamba
|
|
@ -31,7 +31,7 @@ namespace mamba
|
|||
TEST(env_lockfile, invalid_version_fails)
|
||||
{
|
||||
const fs::u8path invalid_version_lockfile_path{ test_data_dir
|
||||
/ "env_lockfile_test/bad_version-lock.yaml" };
|
||||
/ "env_lockfile/bad_version-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(invalid_version_lockfile_path);
|
||||
ASSERT_FALSE(maybe_lockfile);
|
||||
const auto error = maybe_lockfile.error();
|
||||
|
@ -42,8 +42,7 @@ namespace mamba
|
|||
|
||||
TEST(env_lockfile, valid_no_package_succeed)
|
||||
{
|
||||
const fs::u8path lockfile_path{ test_data_dir
|
||||
/ "env_lockfile_test/good_no_package-lock.yaml" };
|
||||
const fs::u8path lockfile_path{ test_data_dir / "env_lockfile/good_no_package-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(lockfile_path);
|
||||
ASSERT_TRUE(maybe_lockfile) << maybe_lockfile.error().what();
|
||||
const auto lockfile = maybe_lockfile.value();
|
||||
|
@ -52,7 +51,7 @@ namespace mamba
|
|||
|
||||
TEST(env_lockfile, invalid_package_fails)
|
||||
{
|
||||
const fs::u8path lockfile_path{ test_data_dir / "env_lockfile_test/bad_package-lock.yaml" };
|
||||
const fs::u8path lockfile_path{ test_data_dir / "env_lockfile/bad_package-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(lockfile_path);
|
||||
ASSERT_FALSE(maybe_lockfile);
|
||||
const auto error = maybe_lockfile.error();
|
||||
|
@ -63,8 +62,7 @@ namespace mamba
|
|||
|
||||
TEST(env_lockfile, valid_one_package_succeed)
|
||||
{
|
||||
const fs::u8path lockfile_path{ test_data_dir
|
||||
/ "env_lockfile_test/good_one_package-lock.yaml" };
|
||||
const fs::u8path lockfile_path{ test_data_dir / "env_lockfile/good_one_package-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(lockfile_path);
|
||||
ASSERT_TRUE(maybe_lockfile) << maybe_lockfile.error().what();
|
||||
const auto lockfile = maybe_lockfile.value();
|
||||
|
@ -74,7 +72,7 @@ namespace mamba
|
|||
TEST(env_lockfile, valid_one_package_implicit_category)
|
||||
{
|
||||
const fs::u8path lockfile_path{
|
||||
test_data_dir / "env_lockfile_test/good_one_package_missing_category-lock.yaml"
|
||||
test_data_dir / "env_lockfile/good_one_package_missing_category-lock.yaml"
|
||||
};
|
||||
const auto maybe_lockfile = read_environment_lockfile(lockfile_path);
|
||||
ASSERT_TRUE(maybe_lockfile) << maybe_lockfile.error().what();
|
||||
|
@ -85,7 +83,7 @@ namespace mamba
|
|||
TEST(env_lockfile, valid_multiple_packages_succeed)
|
||||
{
|
||||
const fs::u8path lockfile_path{ test_data_dir
|
||||
/ "env_lockfile_test/good_multiple_packages-lock.yaml" };
|
||||
/ "env_lockfile/good_multiple_packages-lock.yaml" };
|
||||
const auto maybe_lockfile = read_environment_lockfile(lockfile_path);
|
||||
ASSERT_TRUE(maybe_lockfile) << maybe_lockfile.error().what();
|
||||
const auto lockfile = maybe_lockfile.value();
|
||||
|
@ -95,7 +93,7 @@ namespace mamba
|
|||
TEST(env_lockfile, get_specific_packages)
|
||||
{
|
||||
const fs::u8path lockfile_path{ test_data_dir
|
||||
/ "env_lockfile_test/good_multiple_packages-lock.yaml" };
|
||||
/ "env_lockfile/good_multiple_packages-lock.yaml" };
|
||||
const auto lockfile = read_environment_lockfile(lockfile_path).value();
|
||||
EXPECT_TRUE(lockfile.get_packages_for("", "", "").empty());
|
||||
{
|
||||
|
@ -113,7 +111,7 @@ namespace mamba
|
|||
TEST(env_lockfile, create_transaction_with_categories)
|
||||
{
|
||||
const fs::u8path lockfile_path{ test_data_dir
|
||||
/ "env_lockfile_test/good_multiple_categories-lock.yaml" };
|
||||
/ "env_lockfile/good_multiple_categories-lock.yaml" };
|
||||
MPool pool;
|
||||
mamba::MultiPackageCache pkg_cache({ "/tmp/" });
|
||||
|
|
@ -11,10 +11,10 @@ namespace mamba
|
|||
TEST(history, parse)
|
||||
{
|
||||
static const auto history_file_path = fs::absolute(
|
||||
test_data_dir / "history_test/parse/conda-meta/history"
|
||||
test_data_dir / "history/parse/conda-meta/history"
|
||||
);
|
||||
static const auto aux_file_path = fs::absolute(
|
||||
test_data_dir / "history_test/parse/conda-meta/aux_file"
|
||||
test_data_dir / "history/parse/conda-meta/aux_file"
|
||||
);
|
||||
|
||||
// Backup history file and restore it at the end of the test, whatever the output.
|
||||
|
@ -33,7 +33,7 @@ namespace mamba
|
|||
} scoped_history_file_backup;
|
||||
|
||||
// Gather history from current history file.
|
||||
History history_instance(test_data_dir / "history_test/parse");
|
||||
History history_instance(test_data_dir / "history/parse");
|
||||
std::vector<History::UserRequest> user_reqs = history_instance.get_user_requests();
|
||||
|
||||
// Extract raw history file content into buffer.
|
|
@ -339,7 +339,7 @@ namespace validate
|
|||
|
||||
protected:
|
||||
|
||||
fs::u8path root1_pgp = test_data_dir / "validation_data/1.sv0.6.root.json";
|
||||
fs::u8path root1_pgp = test_data_dir / "validation/1.sv0.6.root.json";
|
||||
json root1_json, root1_pgp_json;
|
||||
|
||||
secrets_type secrets;
|
||||
|
@ -1561,7 +1561,7 @@ namespace validate
|
|||
|
||||
protected:
|
||||
|
||||
fs::u8path root1 = test_data_dir / "validation_data/root.json";
|
||||
fs::u8path root1 = test_data_dir / "validation/root.json";
|
||||
json root1_json;
|
||||
|
||||
std::unique_ptr<TemporaryDirectory> channel_dir;
|
|
@ -8,6 +8,7 @@
|
|||
#define MAMBA_CORE_URL_HPP
|
||||
|
||||
#include "mamba/core/fsutil.hpp"
|
||||
#include "mamba/core/mamba_fs.hpp"
|
||||
|
||||
namespace mamba
|
||||
{
|
Loading…
Reference in New Issue