Change brace space in clang-format (#2627)

Change braced init spaces
This commit is contained in:
Antoine Prouvost 2023-06-28 11:38:33 +02:00 committed by GitHub
parent 1b28840016
commit 3dce990111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
124 changed files with 1427 additions and 1361 deletions

View File

@ -24,7 +24,7 @@ ColumnLimit: '100'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: 'false'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'false'
DisableFormat: 'false'
EmptyLineAfterAccessModifier: Always

View File

@ -4679,6 +4679,5 @@ unsigned char conda_exe[] = {
0x65, 0xe3, 0x00, 0x00, 0x7e, 0xe3, 0x00, 0x00, 0x54, 0x0b, 0x01, 0x00, 0x7e, 0xe3, 0x00, 0x00,
0x97, 0xe3, 0x00, 0x00, 0x54, 0x0b, 0x01, 0x00, 0x9e, 0xe3, 0x00, 0x00, 0xb7, 0xe3, 0x00, 0x00,
0x54, 0x0b, 0x01, 0x00, 0xb7, 0xe3, 0x00, 0x00, 0xd0, 0xe3, 0x00, 0x00, 0x34, 0x0f, 0x01, 0x00,
0xd0, 0xe3, 0x00, 0x00, 0x1c, 0xe4, 0x00, 0x00, 0x30, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
};
0xd0, 0xe3, 0x00, 0x00, 0x1c, 0xe4, 0x00, 0x00, 0x30, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00};
std::size_t conda_exe_len = 74752;

View File

@ -521,7 +521,7 @@ namespace mamba
std::map<std::string, T> converted_values;
for (auto& y : values)
{
converted_values.insert({ y.first, y.second.as<T>() });
converted_values.insert({y.first, y.second.as<T>()});
}
set_rc_values(converted_values, sources);
}
@ -670,13 +670,13 @@ namespace mamba
if (this->m_api_configured && (level >= ConfigurationLevel::kApi))
{
m_sources.push_back("API");
m_values.insert({ "API", m_value });
m_values.insert({"API", m_value});
}
if (cli_configured() && (level >= ConfigurationLevel::kCli))
{
m_sources.push_back("CLI");
m_values.insert({ "CLI", m_cli_config.value() });
m_values.insert({"CLI", m_cli_config.value()});
}
if (env_var_configured() && env_var_active() && (level >= ConfigurationLevel::kEnvVar))
@ -689,7 +689,7 @@ namespace mamba
try
{
m_values.insert(
{ env_var, detail::Source<T>::deserialize(env_var_value.value()) }
{env_var, detail::Source<T>::deserialize(env_var_value.value())}
);
m_sources.push_back(env_var);
}
@ -714,13 +714,13 @@ namespace mamba
if ((p_default_value_hook != NULL) && (level >= ConfigurationLevel::kDefault))
{
m_sources.push_back("default");
m_values.insert({ "default", p_default_value_hook() });
m_values.insert({"default", p_default_value_hook()});
}
if (m_sources.empty() && (p_fallback_value_hook != NULL))
{
m_sources.push_back("fallback");
m_values.insert({ "fallback", p_fallback_value_hook() });
m_values.insert({"fallback", p_fallback_value_hook()});
}
if (!m_sources.empty())
@ -926,7 +926,7 @@ namespace mamba
std::string name = configurable.name();
if (m_config.count(name) == 0)
{
auto [it, success] = m_config.insert({ name, std::move(configurable) });
auto [it, success] = m_config.insert({name, std::move(configurable)});
it->second.set_configuration(*this);
m_config_order.push_back(name);
}

View File

@ -58,7 +58,7 @@ namespace mamba
{
static std::vector<std::string> default_value(const T&)
{
return std::vector<std::string>({ "default" });
return std::vector<std::string>({"default"});
};
static void merge(
@ -328,9 +328,8 @@ namespace YAML
{
private:
inline static const std::array<std::string, 7> log_level_names = {
"trace", "debug", "info", "warning", "error", "critical", "off"
};
inline static const std::array<std::string, 7>
log_level_names = {"trace", "debug", "info", "warning", "error", "critical", "off"};
public:

View File

@ -124,55 +124,55 @@ namespace mamba
// ssl_verify can be either an empty string (regular SSL verification),
// the string "<false>" to indicate no SSL verification, or a path to
// a directory with cert files, or a cert file.
std::string ssl_verify{ "" };
bool ssl_no_revoke{ false };
bool curl_initialized{ false }; // non configurable, used in fetch only
std::string ssl_verify{""};
bool ssl_no_revoke{false};
bool curl_initialized{false}; // non configurable, used in fetch only
std::string user_agent{ "mamba/" LIBMAMBA_VERSION_STRING };
std::string user_agent{"mamba/" LIBMAMBA_VERSION_STRING};
int connect_timeout_secs{ 10 };
int connect_timeout_secs{10};
// int read_timeout_secs { 60 };
int retry_timeout{ 2 }; // seconds
int retry_backoff{ 3 }; // retry_timeout * retry_backoff
int max_retries{ 3 }; // max number of retries
int retry_timeout{2}; // seconds
int retry_backoff{3}; // retry_timeout * retry_backoff
int max_retries{3}; // max number of retries
};
struct OutputParams
{
int verbosity{ 0 };
log_level logging_level{ log_level::warn };
int verbosity{0};
log_level logging_level{log_level::warn};
bool json{ false };
bool quiet{ false };
bool json{false};
bool quiet{false};
std::string log_pattern{ "%^%-9!l%-8n%$ %v" };
std::size_t log_backtrace{ 0 };
std::string log_pattern{"%^%-9!l%-8n%$ %v"};
std::size_t log_backtrace{0};
};
struct GraphicsParams
{
bool no_progress_bars{ false };
bool no_progress_bars{false};
Palette palette;
};
struct SrcParams
{
bool no_rc{ false };
bool no_env{ false };
bool no_rc{false};
bool no_env{false};
};
struct CommandParams
{
std::string caller_version{ "" };
std::string conda_version{ "3.8.0" };
std::string current_command{ "mamba" };
bool is_micromamba{ false };
std::string caller_version{""};
std::string conda_version{"3.8.0"};
std::string current_command{"mamba"};
bool is_micromamba{false};
};
struct ThreadsParams
{
std::size_t download_threads{ 5 };
int extract_threads{ 0 };
std::size_t download_threads{5};
int extract_threads{0};
};
struct PrefixParams
@ -271,7 +271,7 @@ namespace mamba
std::string channel_alias = "https://conda.anaconda.org";
std::map<std::string, AuthenticationInfo>& authentication_info();
std::vector<fs::u8path> token_locations{ "~/.continuum/anaconda-client/tokens" };
std::vector<fs::u8path> token_locations{"~/.continuum/anaconda-client/tokens"};
bool override_channels_enabled = true;
@ -279,13 +279,13 @@ namespace mamba
bool use_only_tar_bz2 = false;
std::vector<std::string> repodata_has_zst = { "https://conda.anaconda.org/conda-forge" };
std::vector<std::string> repodata_has_zst = {"https://conda.anaconda.org/conda-forge"};
// usernames on anaconda.org can have a underscore, which influences the
// first two characters
const std::regex token_regex{ "/t/([a-zA-Z0-9-_]{0,2}[a-zA-Z0-9-]*)" };
const std::regex http_basicauth_regex{ "(://|^)([^\\s]+):([^\\s]+)@" };
const std::regex scheme_regex{ "[a-z][a-z0-9]{0,11}://" };
const std::regex token_regex{"/t/([a-zA-Z0-9-_]{0,2}[a-zA-Z0-9-]*)"};
const std::regex http_basicauth_regex{"(://|^)([^\\s]+):([^\\s]+)@"};
const std::regex scheme_regex{"[a-z][a-z0-9]{0,11}://"};
static Context& instance();

View File

@ -50,9 +50,10 @@ namespace mamba
std::optional<std::type_index> yaml_error_type = std::nullopt
)
{
return mamba_error{ std::forward<StringT>(msg),
mamba_error_code::env_lockfile_parsing_failed,
EnvLockFileError{ error_code, yaml_error_type } };
return mamba_error{
std::forward<StringT>(msg),
mamba_error_code::env_lockfile_parsing_failed,
EnvLockFileError{error_code, yaml_error_type}};
}
};

View File

@ -70,7 +70,7 @@ namespace mamba
return;
}
std::scoped_lock lock{ threads_mutex };
std::scoped_lock lock{threads_mutex};
if (is_open) // Double check necessary for correctness
{
threads.emplace_back(std::forward<Task>(task), std::forward<Args>(args)...);
@ -91,7 +91,7 @@ namespace mamba
return;
}
std::scoped_lock lock{ threads_mutex };
std::scoped_lock lock{threads_mutex};
if (is_open) // Double check necessary for correctness
{
threads.push_back(std::move(thread));
@ -116,7 +116,7 @@ namespace mamba
invoke_close_handlers();
std::scoped_lock lock{ threads_mutex };
std::scoped_lock lock{threads_mutex};
for (auto&& t : threads)
{
t.join();
@ -133,7 +133,7 @@ namespace mamba
return;
}
std::scoped_lock lock{ handlers_mutex };
std::scoped_lock lock{handlers_mutex};
if (is_open) // Double check needed to avoid adding new handles while closing.
{
close_handlers.push_back(std::move(handler));
@ -142,7 +142,7 @@ namespace mamba
private:
std::atomic<bool> is_open{ true };
std::atomic<bool> is_open{true};
std::vector<std::thread> threads;
std::recursive_mutex threads_mutex; // TODO: replace by synchronized_value once available

View File

@ -42,7 +42,7 @@ namespace mamba
void extract_conda(
const fs::u8path& file,
const fs::u8path& dest_dir,
const std::vector<std::string>& parts = { "info", "pkg" }
const std::vector<std::string>& parts = {"info", "pkg"}
);
void extract(const fs::u8path& file, const fs::u8path& destination);
fs::u8path extract(const fs::u8path& file);

View File

@ -243,7 +243,7 @@ namespace mamba
{
fmt::text_style unavailable = fmt::fg(fmt::terminal_color::red);
fmt::text_style available = fmt::fg(fmt::terminal_color::green);
std::array<std::string_view, 4> indents = { "", " ", "├─ ", "└─ " };
std::array<std::string_view, 4> indents = {"", " ", "├─ ", "└─ "};
};
std::ostream& print_problem_tree_msg(

View File

@ -71,7 +71,7 @@ namespace mamba
{
auto make_remote_status()
{
return std::weak_ptr<Status>{ m_status };
return std::weak_ptr<Status>{m_status};
}
public:
@ -119,12 +119,12 @@ namespace mamba
// requested.
{ // We can use 'this' safely in this scope.
notify_begin_execution();
on_scope_exit _{ [&, this]
{
status.reset(); // Make sure we are not keeping the
// TaskSynchronizer waiting
notify_end_execution();
} };
on_scope_exit _{[&, this]
{
status.reset(); // Make sure we are not keeping the
// TaskSynchronizer waiting
notify_end_execution();
}};
std::invoke(new_work, std::forward<decltype(args)>(args)...);
}
};
@ -178,10 +178,10 @@ namespace mamba
struct Status
{
std::atomic<bool> join_requested{ false };
std::atomic<bool> join_requested{false};
};
std::atomic<int64_t> m_running_tasks{ 0 };
std::atomic<int64_t> m_running_tasks{0};
std::shared_ptr<Status> m_status = std::make_shared<Status>();
@ -196,7 +196,7 @@ namespace mamba
void notify_end_execution()
{
{
std::unique_lock exit_lock{ m_mutex };
std::unique_lock exit_lock{m_mutex};
--m_running_tasks;
}
m_task_end_condition.notify_one();
@ -209,7 +209,7 @@ namespace mamba
return;
}
std::unique_lock exit_lock{ m_mutex };
std::unique_lock exit_lock{m_mutex};
auto remote_status = make_remote_status();
m_status->join_requested = true;

View File

@ -27,7 +27,7 @@ namespace mamba
auto dev = std::random_device{};
std::generate_n(begin(seed), seed_len, std::ref(dev));
auto seed_seq = std::seed_seq(begin(seed), end(seed));
return T{ seed_seq };
return T{seed_seq};
}
template <typename T = std::mt19937>
@ -40,7 +40,7 @@ namespace mamba
template <typename T = int, typename G = std::mt19937>
inline T random_int(T min, T max, G& generator = local_random_generator())
{
return std::uniform_int_distribution<T>{ min, max }(generator);
return std::uniform_int_distribution<T>{min, max}(generator);
}
inline std::string generate_random_alphanumeric_string(std::size_t len)
@ -50,7 +50,7 @@ namespace mamba
"abcdefghijklmnopqrstuvwxyz";
auto& rng = local_random_generator<std::mt19937>();
auto dist = std::uniform_int_distribution{ {}, std::strlen(chars) - 1 };
auto dist = std::uniform_int_distribution{{}, std::strlen(chars) - 1};
auto result = std::string(len, '\0');
std::generate_n(begin(result), len, [&]() { return chars[dist(rng)]; });
return result;

View File

@ -234,7 +234,7 @@ namespace mamba
const Value& sep,
const Value& etc,
std::size_t threshold = 5,
std::pair<std::size_t, std::size_t> show = { 2, 1 }
std::pair<std::size_t, std::size_t> show = {2, 1}
);
/**
@ -255,7 +255,7 @@ namespace mamba
std::string_view sep = ", ",
std::string_view etc = "...",
std::size_t threshold = 5,
std::pair<std::size_t, std::size_t> show = { 2, 1 },
std::pair<std::size_t, std::size_t> show = {2, 1},
Joiner joiner = detail::PlusEqual{}
) -> typename Range::value_type;
;
@ -339,7 +339,7 @@ namespace mamba
[&should_strip](Char c) -> bool { return !should_strip(c); }
);
const auto start_idx = static_cast<std::size_t>(start_iter - input.cbegin());
return { input.substr(0, start_idx), input.substr(start_idx) };
return {input.substr(0, start_idx), input.substr(start_idx)};
}
}
@ -379,7 +379,7 @@ namespace mamba
[&should_strip](Char c) -> bool { return !should_strip(c); }
);
const auto past_end_idx = static_cast<std::size_t>(input.crend() - rstart_iter);
return { input.substr(0, past_end_idx), input.substr(past_end_idx) };
return {input.substr(0, past_end_idx), input.substr(past_end_idx)};
}
}
@ -415,7 +415,7 @@ namespace mamba
{
const auto [head, not_head] = lstrip_if_parts(input, should_strip);
const auto [body, tail] = rstrip_if_parts(not_head, std::move(should_strip));
return { head, body, tail };
return {head, body, tail};
}
}

View File

@ -255,7 +255,7 @@ namespace mamba::validation
static Key from_ed25519(std::string keyval)
{
return { "ed25519", "ed25519", keyval };
return {"ed25519", "ed25519", keyval};
}
};

View File

@ -68,7 +68,7 @@ namespace mamba::specs
std::string name = {};
/** The version of the package. */
Version version = Version(0, { { { 0 } } });
Version version = Version(0, {{{0}}});
/** The build string of the package. */
std::string build_string = {};

View File

@ -36,12 +36,12 @@ namespace mamba::util
template <typename To, typename From>
constexpr auto make_overflow_error(const From& val)
{
return std::overflow_error{ fmt::format(
return std::overflow_error{fmt::format(
"Value to cast ({}) is out of destination range ([{}, {}])",
val,
std::numeric_limits<To>::lowest(),
std::numeric_limits<To>::max()
) };
)};
};
}
@ -106,8 +106,7 @@ namespace mamba::util
if (cast_back != val)
{
throw std::runtime_error{
fmt::format("Casting from {} to {} loses precision", val, cast)
};
fmt::format("Casting from {} to {} loses precision", val, cast)};
}
return cast;
}

View File

@ -260,10 +260,10 @@ namespace mamba::util
auto it = std::lower_bound(begin(), end(), value, m_compare);
if ((it != end()) && (key_eq(*it, value)))
{
return { it, false };
return {it, false};
}
it = Base::insert(it, std::forward<U>(value));
return { it, true };
return {it, true};
}
template <typename K, typename C, typename A>

View File

@ -616,7 +616,7 @@ namespace mamba::util
template <typename UnaryFuncU>
PreorderVisitor(UnaryFuncU&& func)
: m_func{ std::forward<UnaryFuncU>(func) }
: m_func{std::forward<UnaryFuncU>(func)}
{
}
@ -639,7 +639,7 @@ namespace mamba::util
template <typename UnaryFuncU>
PostorderVisitor(UnaryFuncU&& func)
: m_func{ std::forward<UnaryFuncU>(func) }
: m_func{std::forward<UnaryFuncU>(func)}
{
}
@ -713,7 +713,7 @@ namespace mamba::util
{
target_visited = target_visited || (node == target);
}
} visitor{ {}, target };
} visitor{{}, target};
dfs_raw(graph, visitor, source);
return visitor.target_visited;
@ -757,7 +757,7 @@ namespace mamba::util
template <typename N, typename E>
bool DiGraph<N, E>::remove_edge(node_id from, node_id to)
{
m_edges.erase({ from, to }); // No-op if edge does not exists
m_edges.erase({from, to}); // No-op if edge does not exists
return Base::remove_edge(from, to);
}
@ -767,11 +767,11 @@ namespace mamba::util
// No-op if edge does not exists
for (const auto& to : successors(id))
{
m_edges.erase({ id, to });
m_edges.erase({id, to});
}
for (const auto& from : predecessors(id))
{
m_edges.erase({ from, id });
m_edges.erase({from, id});
}
return Base::remove_node(id);
}
@ -791,7 +791,7 @@ namespace mamba::util
template <typename N, typename E>
auto DiGraph<N, E>::edge(node_id from, node_id to) const -> const edge_t&
{
return edge({ from, to });
return edge({from, to});
}
template <typename N, typename E>
@ -803,7 +803,7 @@ namespace mamba::util
template <typename N, typename E>
auto DiGraph<N, E>::edge(node_id from, node_id to) -> edge_t&
{
return edge({ from, to });
return edge({from, to});
}
}
#endif

View File

@ -164,10 +164,10 @@ namespace mamba
{
std::vector<fs::u8path> res;
std::size_t total_size = 0;
std::vector<printers::FormattedString> header = { "Package file", "Size" };
std::vector<printers::FormattedString> header = {"Package file", "Size"};
mamba::printers::Table t(header);
t.set_alignment({ printers::alignment::left, printers::alignment::right });
t.set_padding({ 2, 4 });
t.set_alignment({printers::alignment::left, printers::alignment::right});
t.set_padding({2, 4});
for (auto* pkg_cache : caches.writable_caches())
{
@ -181,7 +181,7 @@ namespace mamba
|| ends_with(p.path().string(), ".conda")))
{
res.push_back(p.path());
rows.push_back({ p.path().filename().string(), get_file_size(p.file_size()) });
rows.push_back({p.path().filename().string(), get_file_size(p.file_size())});
total_size += p.file_size();
}
}
@ -194,7 +194,7 @@ namespace mamba
}
if (total_size)
{
t.add_rows({}, { { "Total size: ", get_file_size(total_size) } });
t.add_rows({}, {{"Total size: ", get_file_size(total_size)}});
t.print(std::cout);
}
return res;
@ -238,10 +238,10 @@ namespace mamba
{
std::vector<fs::u8path> res;
std::size_t total_size = 0;
std::vector<printers::FormattedString> header = { "Package folder", "Size" };
std::vector<printers::FormattedString> header = {"Package folder", "Size"};
mamba::printers::Table t(header);
t.set_alignment({ printers::alignment::left, printers::alignment::right });
t.set_padding({ 2, 4 });
t.set_alignment({printers::alignment::left, printers::alignment::right});
t.set_padding({2, 4});
for (auto* pkg_cache : caches.writable_caches())
{
@ -258,7 +258,7 @@ namespace mamba
}
res.push_back(p.path());
std::size_t folder_size = get_folder_size(p);
rows.push_back({ p.path().filename().string(), get_file_size(folder_size) });
rows.push_back({p.path().filename().string(), get_file_size(folder_size)});
total_size += folder_size;
}
}
@ -271,7 +271,7 @@ namespace mamba
}
if (total_size)
{
t.add_rows({}, { { "Total size: ", get_file_size(total_size) } });
t.add_rows({}, {{"Total size: ", get_file_size(total_size)}});
t.print(std::cout);
}
return res;

View File

@ -199,7 +199,7 @@ namespace mamba
{
if (names.empty())
{
p_impl->m_env_var_names = { "MAMBA_" + to_upper(p_impl->m_name) };
p_impl->m_env_var_names = {"MAMBA_" + to_upper(p_impl->m_name)};
}
else
{
@ -826,7 +826,7 @@ namespace mamba
std::vector<fs::u8path> fallback_envs_dirs_hook()
{
return { Context::instance().prefix_params.root_prefix / "envs" };
return {Context::instance().prefix_params.root_prefix / "envs"};
}
void envs_dirs_hook(std::vector<fs::u8path>& dirs)
@ -844,8 +844,9 @@ namespace mamba
std::vector<fs::u8path> fallback_pkgs_dirs_hook()
{
std::vector<fs::u8path> paths = { Context::instance().prefix_params.root_prefix / "pkgs",
env::home_directory() / ".mamba" / "pkgs" };
std::vector<fs::u8path> paths = {
Context::instance().prefix_params.root_prefix / "pkgs",
env::home_directory() / ".mamba" / "pkgs"};
#ifdef _WIN32
auto appdata = env::get("APPDATA");
if (appdata)
@ -888,7 +889,7 @@ namespace mamba
fs::u8path get_conda_root_prefix()
{
std::vector<std::string> args = { "conda", "config", "--show", "root_prefix", "--json" };
std::vector<std::string> args = {"conda", "config", "--show", "root_prefix", "--json"};
std::string out, err;
auto [status, ec] = reproc::run(
args,
@ -1059,7 +1060,7 @@ namespace mamba
Configurable("root_prefix", &ctx.prefix_params.root_prefix)
.group("Basic")
.set_env_var_names()
.needs({ "create_base", "rc_files" })
.needs({"create_base", "rc_files"})
.description("Path to the root prefix")
.set_post_merge_hook<fs::u8path>([&](fs::u8path& value)
{ return detail::root_prefix_hook(*this, value); })
@ -1071,26 +1072,24 @@ namespace mamba
.set_single_op_lifetime()
.description("Define if base environment will be initialized empty"));
insert(Configurable("target_prefix", &ctx.prefix_params.target_prefix)
.group("Basic")
.set_env_var_names()
.needs({ "root_prefix",
"envs_dirs",
"env_name",
"spec_file_env_name",
"use_target_prefix_fallback" })
.set_single_op_lifetime()
.description("Path to the target prefix")
.set_post_merge_hook<fs::u8path>(
[this](fs::u8path& value) { return detail::target_prefix_hook(*this, value); }
)
.set_post_context_hook([this]
{ return detail::post_target_prefix_rc_loading(*this); }));
insert(
Configurable("target_prefix", &ctx.prefix_params.target_prefix)
.group("Basic")
.set_env_var_names()
.needs({"root_prefix", "envs_dirs", "env_name", "spec_file_env_name", "use_target_prefix_fallback"}
)
.set_single_op_lifetime()
.description("Path to the target prefix")
.set_post_merge_hook<fs::u8path>([this](fs::u8path& value)
{ return detail::target_prefix_hook(*this, value); })
.set_post_context_hook([this]
{ return detail::post_target_prefix_rc_loading(*this); })
);
insert(Configurable("relocate_prefix", &ctx.prefix_params.relocate_prefix)
.group("Basic")
.set_env_var_names()
.needs({ "target_prefix" })
.needs({"target_prefix"})
.set_single_op_lifetime()
.description("Path to the relocation prefix"));
@ -1101,14 +1100,14 @@ namespace mamba
insert(Configurable("target_prefix_checks", MAMBA_NO_PREFIX_CHECK)
.group("Basic")
.needs({ "target_prefix", "rc_files" })
.needs({"target_prefix", "rc_files"})
.description("The type of checks performed on the target prefix")
.set_single_op_lifetime()
.set_post_merge_hook(detail::target_prefix_checks_hook));
insert(Configurable("env_name", std::string(""))
.group("Basic")
.needs({ "root_prefix", "spec_file_env_name", "envs_dirs" })
.needs({"root_prefix", "spec_file_env_name", "envs_dirs"})
.set_single_op_lifetime()
.set_post_merge_hook<std::string>([&](std::string& value)
{ return detail::env_name_hook(*this, value); })
@ -1117,8 +1116,8 @@ namespace mamba
insert(Configurable("envs_dirs", &ctx.envs_dirs)
.group("Basic")
.set_rc_configurable(RCConfigLevel::kHomeDir)
.set_env_var_names({ "CONDA_ENVS_DIRS" })
.needs({ "root_prefix" })
.set_env_var_names({"CONDA_ENVS_DIRS"})
.needs({"root_prefix"})
.set_fallback_value_hook(detail::fallback_envs_dirs_hook)
.set_post_merge_hook(detail::envs_dirs_hook)
.description("Possible locations of named environments"));
@ -1126,8 +1125,8 @@ namespace mamba
insert(Configurable("pkgs_dirs", &ctx.pkgs_dirs)
.group("Basic")
.set_rc_configurable()
.set_env_var_names({ "CONDA_PKGS_DIRS" })
.needs({ "root_prefix" })
.set_env_var_names({"CONDA_PKGS_DIRS"})
.needs({"root_prefix"})
.set_fallback_value_hook(detail::fallback_pkgs_dirs_hook)
.set_post_merge_hook(detail::pkgs_dirs_hook)
.description("Possible locations of packages caches"));
@ -1135,7 +1134,7 @@ namespace mamba
insert(Configurable("platform", &ctx.platform)
.group("Basic")
.set_rc_configurable()
.set_env_var_names({ "CONDA_SUBDIR", "MAMBA_PLATFORM" })
.set_env_var_names({"CONDA_SUBDIR", "MAMBA_PLATFORM"})
.description("The platform description")
.long_description(unindent(R"(
The plaftorm description points what channels
@ -1144,14 +1143,14 @@ namespace mamba
insert(Configurable("spec_file_env_name", std::string(""))
.group("Basic")
.needs({ "file_specs", "root_prefix" })
.needs({"file_specs", "root_prefix"})
.set_single_op_lifetime()
.set_post_merge_hook(detail::file_spec_env_name_hook)
.description("Name of the target prefix, specified in a YAML spec file"));
insert(Configurable("specs", std::vector<std::string>({}))
.group("Basic")
.needs({ "file_specs" }) // explicit file specs overwrite current specs
.needs({"file_specs"}) // explicit file specs overwrite current specs
.set_single_op_lifetime()
.description("Packages specification"));
@ -1185,9 +1184,9 @@ namespace mamba
insert(Configurable("channels", &ctx.channels)
.group("Channels")
.set_rc_configurable()
.set_env_var_names({ "CONDA_CHANNELS" })
.set_env_var_names({"CONDA_CHANNELS"})
.description("Define the list of channels")
.needs({ "file_specs" })
.needs({"file_specs"})
.long_description(unindent(R"(
The list of channels where the packages will be searched for.
See also 'channel_priority'.)"))
@ -1286,7 +1285,7 @@ namespace mamba
'ssl_verify' can be either an empty string (regular SSL verification),
the string "<false>" to indicate no SSL verification, or a path to
a directory with cert files, or a cert file..)"))
.needs({ "cacert_path", "offline" })
.needs({"cacert_path", "offline"})
.set_post_merge_hook<decltype(ctx.remote_fetch_params.ssl_verify)>(
[this](auto&... args) { return detail::ssl_verify_hook(*this, args...); }
));
@ -1396,7 +1395,7 @@ namespace mamba
Configurable("only_deps", false).group("Solver").description("Only install dependencies")
);
insert(Configurable("categories", std::vector<std::string>({ "main" }))
insert(Configurable("categories", std::vector<std::string>({"main"}))
.group("Solver")
.description("Package categories to consider when installing from a lock file"));
@ -1464,7 +1463,7 @@ namespace mamba
.group("Extract, Link & Install")
.set_rc_configurable()
.set_env_var_names()
.needs({ "always_copy" })
.needs({"always_copy"})
.set_post_merge_hook<decltype(ctx.always_softlink)>(
[&](decltype(ctx.always_softlink)& value)
{ return detail::always_softlink_hook(*this, value); }
@ -1488,7 +1487,7 @@ namespace mamba
insert(Configurable("safety_checks", &ctx.safety_checks)
.group("Extract, Link & Install")
.set_rc_configurable()
.set_env_var_names({ "CONDA_SAFETY_CHECKS", "MAMBA_SAFETY_CHECKS" })
.set_env_var_names({"CONDA_SAFETY_CHECKS", "MAMBA_SAFETY_CHECKS"})
.description("Safety checks policy ('enabled', 'warn', or 'disabled')")
.long_description(unindent(R"(
Enforce available safety guarantees during package installation. The
@ -1497,7 +1496,7 @@ namespace mamba
insert(Configurable("extra_safety_checks", &ctx.extra_safety_checks)
.group("Extract, Link & Install")
.set_rc_configurable()
.set_env_var_names({ "CONDA_EXTRA_SAFETY_CHECKS", "MAMBA_EXTRA_SAFETY_CHECKS" })
.set_env_var_names({"CONDA_EXTRA_SAFETY_CHECKS", "MAMBA_EXTRA_SAFETY_CHECKS"})
.description("Run extra verifications on packages")
.long_description(unindent(R"(
Spend extra time validating package contents. Currently, runs sha256
@ -1569,7 +1568,7 @@ namespace mamba
.group("Output, Prompt and Flow Control")
.set_rc_configurable()
.set_env_var_names()
.needs({ "json", "verbose" })
.needs({"json", "verbose"})
.description("Set the log level")
.set_fallback_value_hook<mamba::log_level>(
[this] { return detail::log_level_fallback_hook(*this); }
@ -1599,7 +1598,7 @@ namespace mamba
insert(Configurable("json", &ctx.output_params.json)
.group("Output, Prompt and Flow Control")
.set_rc_configurable()
.needs({ "print_config_only", "print_context_only" })
.needs({"print_config_only", "print_context_only"})
.set_env_var_names()
.description("Report all output as json"));
@ -1633,7 +1632,7 @@ namespace mamba
insert(Configurable("print_config_only", false)
.group("Output, Prompt and Flow Control")
.needs({ "debug" })
.needs({"debug"})
.set_post_merge_hook<bool>(
[&](bool& value) { return detail::print_config_only_hook(*this, value); }
)
@ -1641,7 +1640,7 @@ namespace mamba
insert(Configurable("print_context_only", false)
.group("Output, Prompt and Flow Control")
.needs({ "debug" })
.needs({"debug"})
.set_post_merge_hook<bool>(
[&](bool& value) { return detail::print_context_only_hook(*this, value); }
)
@ -1679,7 +1678,7 @@ namespace mamba
.group("Output, Prompt and Flow Control")
.set_rc_configurable()
.set_env_var_names()
.needs({ "json", "print_config_only", "print_context_only" })
.needs({"json", "print_config_only", "print_context_only"})
.description("Set quiet mode (print less output)"));
insert(Configurable("verbose", 0)
@ -1696,8 +1695,8 @@ namespace mamba
// Config
insert(Configurable("rc_files", std::vector<fs::u8path>({}))
.group("Config sources")
.set_env_var_names({ "MAMBARC", "CONDARC" })
.needs({ "no_rc" })
.set_env_var_names({"MAMBARC", "CONDARC"})
.needs({"no_rc"})
.set_post_merge_hook(detail::rc_files_hook)
.description("Paths to the configuration files to use"));
@ -1745,7 +1744,7 @@ namespace mamba
for (auto& g : group_order)
{
res.push_back({ g, map.at(g) });
res.push_back({g, map.at(g)});
}
return res;
@ -1758,34 +1757,43 @@ namespace mamba
std::vector<fs::u8path> system;
if constexpr (on_mac || on_linux)
{
system = { "/etc/conda/.condarc", "/etc/conda/condarc",
"/etc/conda/condarc.d/", "/etc/conda/.mambarc",
"/var/lib/conda/.condarc", "/var/lib/conda/condarc",
"/var/lib/conda/condarc.d/", "/var/lib/conda/.mambarc" };
system = {
"/etc/conda/.condarc",
"/etc/conda/condarc",
"/etc/conda/condarc.d/",
"/etc/conda/.mambarc",
"/var/lib/conda/.condarc",
"/var/lib/conda/condarc",
"/var/lib/conda/condarc.d/",
"/var/lib/conda/.mambarc"};
}
else
{
system = { "C:\\ProgramData\\conda\\.condarc",
"C:\\ProgramData\\conda\\condarc",
"C:\\ProgramData\\conda\\condarc.d",
"C:\\ProgramData\\conda\\.mambarc" };
system = {
"C:\\ProgramData\\conda\\.condarc",
"C:\\ProgramData\\conda\\condarc",
"C:\\ProgramData\\conda\\condarc.d",
"C:\\ProgramData\\conda\\.mambarc"};
}
std::vector<fs::u8path> root = { ctx.prefix_params.root_prefix / ".condarc",
ctx.prefix_params.root_prefix / "condarc",
ctx.prefix_params.root_prefix / "condarc.d",
ctx.prefix_params.root_prefix / ".mambarc" };
std::vector<fs::u8path> root = {
ctx.prefix_params.root_prefix / ".condarc",
ctx.prefix_params.root_prefix / "condarc",
ctx.prefix_params.root_prefix / "condarc.d",
ctx.prefix_params.root_prefix / ".mambarc"};
std::vector<fs::u8path> home = { env::home_directory() / ".conda/.condarc",
env::home_directory() / ".conda/condarc",
env::home_directory() / ".conda/condarc.d",
env::home_directory() / ".condarc",
env::home_directory() / ".mambarc" };
std::vector<fs::u8path> home = {
env::home_directory() / ".conda/.condarc",
env::home_directory() / ".conda/condarc",
env::home_directory() / ".conda/condarc.d",
env::home_directory() / ".condarc",
env::home_directory() / ".mambarc"};
std::vector<fs::u8path> prefix = { ctx.prefix_params.target_prefix / ".condarc",
ctx.prefix_params.target_prefix / "condarc",
ctx.prefix_params.target_prefix / "condarc.d",
ctx.prefix_params.target_prefix / ".mambarc" };
std::vector<fs::u8path> prefix = {
ctx.prefix_params.target_prefix / ".condarc",
ctx.prefix_params.target_prefix / "condarc",
ctx.prefix_params.target_prefix / "condarc.d",
ctx.prefix_params.target_prefix / ".mambarc"};
std::vector<fs::u8path> sources;
@ -2064,7 +2072,7 @@ namespace mamba
continue;
}
m_rc_yaml_nodes_cache.insert({ s, node });
m_rc_yaml_nodes_cache.insert({s, node});
}
m_valid_sources.push_back(s);
}

View File

@ -78,7 +78,7 @@ namespace mamba
std::map<std::string, nlohmann::json> items_map;
for (auto& [key, val] : items)
{
items_map.insert({ key, val });
items_map.insert({key, val});
}
Console::instance().json_write(items_map);
@ -119,36 +119,35 @@ namespace mamba
name += " (not found)";
}
items.push_back({ "environment", name });
items.push_back({ "env location", location });
items.push_back({"environment", name});
items.push_back({"env location", location});
// items.insert( { "shell level", { 1 } });
items.push_back({ "user config files",
{ (env::home_directory() / ".mambarc").string() } });
items.push_back({"user config files", {(env::home_directory() / ".mambarc").string()}});
std::vector<std::string> sources;
for (auto s : config.valid_sources())
{
sources.push_back(s.string());
};
items.push_back({ "populated config files", sources });
items.push_back({"populated config files", sources});
items.push_back({ "libmamba version", version() });
items.push_back({"libmamba version", version()});
if (ctx.command_params.is_micromamba && !ctx.command_params.caller_version.empty())
{
items.push_back({ "micromamba version", ctx.command_params.caller_version });
items.push_back({"micromamba version", ctx.command_params.caller_version});
}
items.push_back({ "curl version", curl_version() });
items.push_back({ "libarchive version", archive_version_details() });
items.push_back({"curl version", curl_version()});
items.push_back({"libarchive version", archive_version_details()});
std::vector<std::string> virtual_pkgs;
for (auto pkg : get_virtual_packages())
{
virtual_pkgs.push_back(concat(pkg.name, "=", pkg.version, "=", pkg.build_string));
}
items.push_back({ "virtual packages", virtual_pkgs });
items.push_back({"virtual packages", virtual_pkgs});
std::vector<std::string> channels = ctx.channels;
// Always append context channels
@ -162,11 +161,11 @@ namespace mamba
channel_urls.push_back(url);
}
}
items.push_back({ "channels", channel_urls });
items.push_back({"channels", channel_urls});
items.push_back({ "base environment", ctx.prefix_params.root_prefix.string() });
items.push_back({"base environment", ctx.prefix_params.root_prefix.string()});
items.push_back({ "platform", ctx.platform });
items.push_back({"platform", ctx.platform});
info_json_print(items);
info_pretty_print(items);

View File

@ -44,11 +44,9 @@ namespace mamba
{ return env::which("python", get_path_dirs(target_prefix)).string(); };
const std::unordered_map<std::string, command_args> other_pkg_mgr_install_instructions{
{ "pip",
{ get_python_path(), "-m", "pip", "install", "-r", spec_file, "--no-input" } },
{ "pip --no-deps",
{ get_python_path(), "-m", "pip", "install", "--no-deps", "-r", spec_file, "--no-input" } }
};
{"pip", {get_python_path(), "-m", "pip", "install", "-r", spec_file, "--no-input"}},
{"pip --no-deps",
{get_python_path(), "-m", "pip", "install", "--no-deps", "-r", spec_file, "--no-input"}}};
auto found_it = other_pkg_mgr_install_instructions.find(name);
if (found_it != other_pkg_mgr_install_instructions.end())
@ -166,10 +164,10 @@ namespace mamba
auto& truthy_values()
{
static std::map<std::string, int> vals{
{ "win", 0 },
{ "unix", 0 },
{ "osx", 0 },
{ "linux", 0 },
{"win", 0},
{"unix", 0},
{"osx", 0},
{"linux", 0},
};
const auto& ctx = Context::instance();
@ -458,7 +456,7 @@ namespace mamba
// add channels from specs
for (const auto& s : specs)
{
if (auto m = MatchSpec{ s, channel_context }; !m.channel.empty())
if (auto m = MatchSpec{s, channel_context}; !m.channel.empty())
{
ctx.channels.push_back(m.channel);
}
@ -469,7 +467,7 @@ namespace mamba
LOG_WARNING << "No 'channels' specified";
}
MPool pool{ channel_context };
MPool pool{channel_context};
// functions implied in 'and_then' coding-styles must return the same type
// which limits this syntax
/*auto exp_prefix_data = load_channels(pool, package_caches, is_retry)
@ -506,15 +504,17 @@ namespace mamba
MSolver solver(
pool,
{
{ SOLVER_FLAG_ALLOW_UNINSTALL, ctx.allow_uninstall },
{ SOLVER_FLAG_ALLOW_DOWNGRADE, ctx.allow_downgrade },
{ SOLVER_FLAG_STRICT_REPO_PRIORITY, ctx.channel_priority == ChannelPriority::kStrict },
{SOLVER_FLAG_ALLOW_UNINSTALL, ctx.allow_uninstall},
{SOLVER_FLAG_ALLOW_DOWNGRADE, ctx.allow_downgrade},
{SOLVER_FLAG_STRICT_REPO_PRIORITY, ctx.channel_priority == ChannelPriority::kStrict},
}
);
solver.set_postsolve_flags({ { MAMBA_NO_DEPS, no_deps },
{ MAMBA_ONLY_DEPS, only_deps },
{ MAMBA_FORCE_REINSTALL, force_reinstall } });
solver.set_postsolve_flags(
{{MAMBA_NO_DEPS, no_deps},
{MAMBA_ONLY_DEPS, only_deps},
{MAMBA_FORCE_REINSTALL, force_reinstall}}
);
if (freeze_installed && !prefix_pkgs.empty())
{
@ -574,8 +574,9 @@ namespace mamba
if (ctx.output_params.json)
{
Console::instance().json_write({ { "success", false },
{ "solver_problems", solver.all_problems() } });
Console::instance().json_write(
{{"success", false}, {"solver_problems", solver.all_problems()}}
);
}
throw mamba_error(
"Could not solve for environment specs",
@ -619,7 +620,7 @@ namespace mamba
bool create_env
)
{
MPool pool{ channel_context };
MPool pool{channel_context};
auto& ctx = Context::instance();
auto exp_prefix_data = PrefixData::create(ctx.prefix_params.target_prefix, channel_context);
if (!exp_prefix_data)
@ -722,9 +723,9 @@ namespace mamba
Console::instance().print(join(
"",
std::vector<std::string>({ "Empty environment created at prefix: ", prefix.string() })
std::vector<std::string>({"Empty environment created at prefix: ", prefix.string()})
));
Console::instance().json_write({ { "success", true } });
Console::instance().json_write({{"success", true}});
}
void create_target_directory(const fs::u8path prefix)

View File

@ -121,12 +121,14 @@ namespace mamba
std::sort(packages.begin(), packages.end(), compare_alphabetically);
// format and print table
printers::Table t({ "Name", "Version", "Build", "Channel" });
t.set_alignment({ printers::alignment::left,
printers::alignment::left,
printers::alignment::left,
printers::alignment::left });
t.set_padding({ 2, 2, 2, 2 });
printers::Table t({"Name", "Version", "Build", "Channel"});
t.set_alignment(
{printers::alignment::left,
printers::alignment::left,
printers::alignment::left,
printers::alignment::left}
);
t.set_padding({2, 2, 2, 2});
for (auto p : packages)
{
@ -136,7 +138,7 @@ namespace mamba
formatted_name = printers::FormattedString(p.name);
formatted_name.style = ctx.graphics_params.palette.user;
}
t.add_row({ formatted_name, p.version, p.build, p.channel });
t.add_row({formatted_name, p.version, p.build, p.channel});
}
t.print(std::cout);

View File

@ -87,11 +87,11 @@ namespace mamba
}
PrefixData& prefix_data = exp_prefix_data.value();
MPool pool{ channel_context };
MPool pool{channel_context};
MRepo(pool, prefix_data);
const fs::u8path pkgs_dirs(ctx.prefix_params.root_prefix / "pkgs");
MultiPackageCache package_caches({ pkgs_dirs });
MultiPackageCache package_caches({pkgs_dirs});
auto execute_transaction = [&](MTransaction& transaction)
{
@ -115,7 +115,7 @@ namespace mamba
specs.end(),
std::back_inserter(mspecs),
[&](const auto& spec_str) {
return MatchSpec{ spec_str, channel_context };
return MatchSpec{spec_str, channel_context};
}
);
auto transaction = MTransaction(pool, mspecs, {}, package_caches);
@ -126,10 +126,10 @@ namespace mamba
MSolver solver(
pool,
{
{ SOLVER_FLAG_ALLOW_DOWNGRADE, 1 },
{ SOLVER_FLAG_ALLOW_UNINSTALL, 1 },
{ SOLVER_FLAG_STRICT_REPO_PRIORITY,
ctx.channel_priority == ChannelPriority::kStrict },
{SOLVER_FLAG_ALLOW_DOWNGRADE, 1},
{SOLVER_FLAG_ALLOW_UNINSTALL, 1},
{SOLVER_FLAG_STRICT_REPO_PRIORITY,
ctx.channel_priority == ChannelPriority::kStrict},
}
);

View File

@ -33,7 +33,7 @@ namespace mamba
config.load();
ChannelContext channel_context;
MPool pool{ channel_context };
MPool pool{channel_context};
// bool installed = (type == QueryType::kDepends) || (type == QueryType::kWhoneeds);
MultiPackageCache package_caches(ctx.pkgs_dirs);
@ -144,7 +144,7 @@ namespace mamba
case QueryResultFormat::kRECURSIVETABLE:
res.sort("name").table(
std::cout,
{ "Name", "Version", "Build", concat("Depends:", query), "Channel" }
{"Name", "Version", "Build", concat("Depends:", query), "Channel"}
);
}
if (res.empty() && format != QueryResultFormat::kJSON)

View File

@ -95,11 +95,12 @@ namespace mamba
// TODO do we need to do something wtih `shell_prefix -> root_prefix?`?
if (ctx.output_params.json)
{
Console::instance().json_write({ { "success", true },
{ "operation", "shell_hook" },
{ "context", { { "shell_type", shell_type } } },
{ "actions",
{ { "print", { activator->hook(shell_type) } } } } });
Console::instance().json_write(
{{"success", true},
{"operation", "shell_hook"},
{"context", {{"shell_type", shell_type}}},
{"actions", {{"print", {activator->hook(shell_type)}}}}}
);
}
else
{

View File

@ -35,7 +35,7 @@ namespace mamba
// add channels from specs
for (const auto& s : update_specs)
{
if (auto m = MatchSpec{ s, channel_context }; !m.channel.empty())
if (auto m = MatchSpec{s, channel_context}; !m.channel.empty())
{
ctx.channels.push_back(m.channel);
}
@ -43,7 +43,7 @@ namespace mamba
int solver_flag = SOLVER_UPDATE;
MPool pool{ channel_context };
MPool pool{channel_context};
MultiPackageCache package_caches(ctx.pkgs_dirs);
auto exp_loaded = load_channels(pool, package_caches, 0);
@ -73,9 +73,9 @@ namespace mamba
MSolver solver(
pool,
{
{ SOLVER_FLAG_ALLOW_DOWNGRADE, ctx.allow_downgrade },
{ SOLVER_FLAG_ALLOW_UNINSTALL, ctx.allow_uninstall },
{ SOLVER_FLAG_STRICT_REPO_PRIORITY, ctx.channel_priority == ChannelPriority::kStrict },
{SOLVER_FLAG_ALLOW_DOWNGRADE, ctx.allow_downgrade},
{SOLVER_FLAG_ALLOW_UNINSTALL, ctx.allow_uninstall},
{SOLVER_FLAG_STRICT_REPO_PRIORITY, ctx.channel_priority == ChannelPriority::kStrict},
}
);

View File

@ -209,16 +209,17 @@ namespace mamba
{
if (on_win)
{
return { prefix,
prefix / "Library" / "mingw-w64" / "bin",
prefix / "Library" / "usr" / "bin",
prefix / "Library" / "bin",
prefix / "Scripts",
prefix / "bin" };
return {
prefix,
prefix / "Library" / "mingw-w64" / "bin",
prefix / "Library" / "usr" / "bin",
prefix / "Library" / "bin",
prefix / "Scripts",
prefix / "bin"};
}
else
{
return { prefix / "bin" };
return {prefix / "bin"};
}
}
@ -249,18 +250,19 @@ namespace mamba
{
if (on_linux)
{
path = { "/usr/bin" };
path = {"/usr/bin"};
}
else if (on_mac)
{
path = { "/usr/bin", "/bin", "/usr/sbin", "/sbin" };
path = {"/usr/bin", "/bin", "/usr/sbin", "/sbin"};
}
else
{
path = { "C:\\Windows\\system32",
"C:\\Windows",
"C:\\Windows\\System32\\Wbem",
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\" };
path = {
"C:\\Windows\\system32",
"C:\\Windows",
"C:\\Windows\\System32\\Wbem",
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\"};
}
}
return path;
@ -377,7 +379,7 @@ namespace mamba
}
else
{
envt.export_vars.push_back({ to_upper(k), v });
envt.export_vars.push_back({to_upper(k), v});
}
}
}
@ -423,10 +425,9 @@ namespace mamba
}
std::vector<std::pair<std::string, std::string>> env_vars_to_export = {
{ "path", new_path },
{ "conda_shlvl", std::to_string(conda_shlvl) },
{ "conda_prompt_modifier", conda_prompt_modifier }
};
{"path", new_path},
{"conda_shlvl", std::to_string(conda_shlvl)},
{"conda_prompt_modifier", conda_prompt_modifier}};
get_export_unset_vars(envt, env_vars_to_export);
// TODO figure out if this is all really necessary?
@ -474,11 +475,10 @@ namespace mamba
// script, we need something I suppose!)
envt.export_path = new_path;
std::vector<std::pair<std::string, std::string>> env_vars_to_export = {
{ "conda_prefix", "" },
{ "conda_shlvl", std::to_string(new_conda_shlvl) },
{ "conda_default_env", "" },
{ "conda_prompt_modifier", "" }
};
{"conda_prefix", ""},
{"conda_shlvl", std::to_string(new_conda_shlvl)},
{"conda_default_env", ""},
{"conda_prompt_modifier", ""}};
get_export_unset_vars(envt, env_vars_to_export);
}
else
@ -505,17 +505,16 @@ namespace mamba
}
std::vector<std::pair<std::string, std::string>> env_vars_to_export = {
{ "conda_prefix", new_prefix },
{ "conda_shlvl", std::to_string(new_conda_shlvl) },
{ "conda_default_env", conda_default_env },
{ "conda_prompt_modifier", conda_prompt_modifier }
};
{"conda_prefix", new_prefix},
{"conda_shlvl", std::to_string(new_conda_shlvl)},
{"conda_default_env", conda_default_env},
{"conda_prompt_modifier", conda_prompt_modifier}};
get_export_unset_vars(envt, env_vars_to_export);
for (auto& [k, v] : new_conda_environment_env_vars)
{
envt.export_vars.push_back({ k, v });
envt.export_vars.push_back({k, v});
}
envt.export_path = new_path;
@ -537,7 +536,7 @@ namespace mamba
std::string save_var = fmt::format("__CONDA_SHLVL_{}_{}", new_conda_shlvl, env_var.first);
if (m_env.find(save_var) != m_env.end())
{
envt.export_vars.push_back({ env_var.first, m_env[save_var] });
envt.export_vars.push_back({env_var.first, m_env[save_var]});
envt.unset_vars.push_back(save_var);
}
}
@ -620,7 +619,7 @@ namespace mamba
for (const auto& v : clobbering_env_vars)
{
conda_environment_env_vars.push_back(
{ fmt::format("__CONDA_SHLVL_{}_{}", old_conda_shlvl, v), m_env[v] }
{fmt::format("__CONDA_SHLVL_{}_{}", old_conda_shlvl, v), m_env[v]}
);
}
@ -633,16 +632,15 @@ namespace mamba
std::string new_path = add_prefix_to_path(prefix, old_conda_shlvl);
std::vector<std::pair<std::string, std::string>> env_vars_to_export{
{ "path", new_path },
{ "conda_prefix", prefix.string() },
{ "conda_shlvl", std::to_string(new_conda_shlvl) },
{ "conda_default_env", conda_default_env },
{ "conda_prompt_modifier", conda_prompt_modifier }
};
{"path", new_path},
{"conda_prefix", prefix.string()},
{"conda_shlvl", std::to_string(new_conda_shlvl)},
{"conda_default_env", conda_default_env},
{"conda_prompt_modifier", conda_prompt_modifier}};
for (auto& [k, v] : conda_environment_env_vars)
{
envt.export_vars.push_back({ k, v });
envt.export_vars.push_back({k, v});
}
if (old_conda_shlvl == 0)
@ -652,9 +650,10 @@ namespace mamba
else if (m_stack)
{
get_export_unset_vars(envt, env_vars_to_export);
envt.export_vars.push_back({ fmt::format("CONDA_PREFIX_{}", old_conda_shlvl),
old_conda_prefix });
envt.export_vars.push_back({ fmt::format("CONDA_STACKED_{}", new_conda_shlvl), "true" });
envt.export_vars.push_back(
{fmt::format("CONDA_PREFIX_{}", old_conda_shlvl), old_conda_prefix}
);
envt.export_vars.push_back({fmt::format("CONDA_STACKED_{}", new_conda_shlvl), "true"});
}
else
{
@ -671,17 +670,15 @@ namespace mamba
+ env_var.first; // % (new_conda_shlvl, env_var)
if (m_env.find(save_var) != m_env.end())
{
envt.export_vars.insert(
envt.export_vars.begin(),
{ env_var.first, m_env[save_var] }
);
envt.export_vars.insert(envt.export_vars.begin(), {env_var.first, m_env[save_var]});
}
}
env_vars_to_export[0] = { "PATH", new_path };
env_vars_to_export[0] = {"PATH", new_path};
get_export_unset_vars(envt, env_vars_to_export);
envt.export_vars.push_back({ fmt::format("CONDA_PREFIX_{}", old_conda_shlvl),
old_conda_prefix });
envt.export_vars.push_back(
{fmt::format("CONDA_PREFIX_{}", old_conda_shlvl), old_conda_prefix}
);
}
if (Context::instance().change_ps1)
@ -822,7 +819,7 @@ namespace mamba
{
// Defer to powerline (https://github.com/powerline/powerline) if it's in
// use.
return { "", "" };
return {"", ""};
}
auto current_prompt_modifier = env::get("CONDA_PROMPT_MODIFIER");
if (current_prompt_modifier)
@ -833,7 +830,7 @@ namespace mamba
// the proper escaping of single quotes that are already part of the string.
// Best solution appears to be https://stackoverflow.com/a/1250279
replace_all(ps1, "'", "'\"'\"'");
return { "PS1", conda_prompt_modifier + ps1 };
return {"PS1", conda_prompt_modifier + ps1};
}
std::string PosixActivator::shell_extension()
@ -946,7 +943,7 @@ namespace mamba
// the proper escaping of single quotes that are already part of the string.
// Best solution appears to be https://stackoverflow.com/a/1250279
replace_all(prompt, "'", "'\"'\"'");
return { "prompt", conda_prompt_modifier + prompt };
return {"prompt", conda_prompt_modifier + prompt};
}
@ -1004,7 +1001,7 @@ namespace mamba
std::pair<std::string, std::string>
CmdExeActivator::update_prompt(const std::string& /* conda_prompt_modifier */)
{
return { "", "" };
return {"", ""};
}
std::string CmdExeActivator::script(const EnvironmentTransform& env_transform)
@ -1080,7 +1077,7 @@ namespace mamba
std::pair<std::string, std::string>
PowerShellActivator::update_prompt(const std::string& /*conda_prompt_modifier*/)
{
return { "", "" };
return {"", ""};
}
std::string PowerShellActivator::script(const EnvironmentTransform& env_transform)
@ -1148,7 +1145,7 @@ namespace mamba
std::pair<std::string, std::string>
XonshActivator::update_prompt(const std::string& /*conda_prompt_modifier*/)
{
return { "", "" };
return {"", ""};
}
std::string XonshActivator::script(const EnvironmentTransform& env_transform)
@ -1217,7 +1214,7 @@ namespace mamba
std::pair<std::string, std::string>
FishActivator::update_prompt(const std::string& /*conda_prompt_modifier*/)
{
return { "", "" };
return {"", ""};
}
std::string FishActivator::script(const EnvironmentTransform& env_transform)

View File

@ -30,15 +30,15 @@ namespace mamba
namespace
{
const std::map<std::string, std::string> DEFAULT_CUSTOM_CHANNELS = {
{ "pkgs/pro", "https://repo.anaconda.com" }
};
{"pkgs/pro", "https://repo.anaconda.com"}};
const char UNKNOWN_CHANNEL[] = "<unknown>";
const std::set<std::string> INVALID_CHANNELS = { "<unknown>",
"None:///<unknown>",
"None",
"",
":///<unknown>" };
const std::set<std::string> INVALID_CHANNELS = {
"<unknown>",
"None:///<unknown>",
"None",
"",
":///<unknown>"};
const char LOCAL_CHANNELS_NAME[] = "local";
const char DEFAULT_CHANNELS_NAME[] = "defaults";
@ -46,10 +46,19 @@ namespace mamba
// ATTENTION names with substrings need to go longer -> smalle
// otherwise linux-ppc64 matches for linux-ppc64le etc!
const std::vector<std::string> KNOWN_PLATFORMS = {
"noarch", "linux-32", "linux-64", "linux-aarch64", "linux-armv6l",
"linux-armv7l", "linux-ppc64le", "linux-ppc64", "osx-64", "osx-arm64",
"win-32", "win-64", "zos-z"
};
"noarch",
"linux-32",
"linux-64",
"linux-aarch64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-ppc64",
"osx-64",
"osx-arm64",
"win-32",
"win-64",
"zos-z"};
} // namespace
// Specific functions, used only in this file
@ -352,12 +361,12 @@ namespace mamba
}
std::string platform = m_platforms[0];
return { { build_url(
return {{build_url(
auth(),
scheme(),
join_url(base, name(), platform, *package_filename()),
with_credential
) } };
)}};
}
else
{
@ -602,7 +611,7 @@ namespace mamba
chan.name() == UNKNOWN_CHANNEL ? "" : chan.name()
);
const auto& without_channel = chan.location();
for (const auto& auth : { with_channel, without_channel })
for (const auto& auth : {with_channel, without_channel})
{
auto it = ctx.authentication_info().find(auth);
if (it != ctx.authentication_info().end()
@ -722,8 +731,7 @@ namespace mamba
std::vector<std::string> local_channels = {
Context::instance().prefix_params.target_prefix.string() + "/conda-bld",
Context::instance().prefix_params.root_prefix.string() + "/conda-bld",
"~/conda-bld"
};
"~/conda-bld"};
std::vector<std::string> local_names;
local_names.reserve(local_channels.size());

View File

@ -12,8 +12,8 @@ namespace mamba
{
size_t ZstdStream::write(char* in, size_t size)
{
ZSTD_inBuffer input = { in, size, 0 };
ZSTD_outBuffer output = { buffer, BUFFER_SIZE, 0 };
ZSTD_inBuffer input = {in, size, 0};
ZSTD_outBuffer output = {buffer, BUFFER_SIZE, 0};
while (input.pos < input.size)
{

View File

@ -74,12 +74,13 @@ namespace mamba
prefix_params.root_prefix = env::get("MAMBA_ROOT_PREFIX").value_or("");
prefix_params.conda_prefix = prefix_params.root_prefix;
envs_dirs = { prefix_params.root_prefix / "envs" };
pkgs_dirs = { prefix_params.root_prefix / "pkgs",
fs::u8path("~") / ".mamba" / "pkgs"
envs_dirs = {prefix_params.root_prefix / "envs"};
pkgs_dirs = {
prefix_params.root_prefix / "pkgs",
fs::u8path("~") / ".mamba" / "pkgs"
#ifdef _WIN32
,
fs::u8path(env::get("APPDATA").value_or("")) / ".mamba" / "pkgs"
,
fs::u8path(env::get("APPDATA").value_or("")) / ".mamba" / "pkgs"
#endif
};
@ -167,7 +168,7 @@ namespace mamba
std::vector<std::string> Context::platforms()
{
return { platform, "noarch" };
return {platform, "noarch"};
}
std::map<std::string, AuthenticationInfo>& Context::authentication_info()
@ -211,7 +212,7 @@ namespace mamba
token_url = token_url.substr(0, token_url.size() - 6);
std::string token_content = read_contents(entry.path());
AuthenticationInfo auth_info{ AuthenticationType::kCondaToken, token_content };
AuthenticationInfo auth_info{AuthenticationType::kCondaToken, token_content};
m_authentication_info[token_url] = auth_info;
LOG_INFO << "Found token for " << token_url << " at " << entry.path();
}

View File

@ -592,7 +592,7 @@ namespace mamba
CURLMsg* msg = curl_multi_info_read(p_handle, &msgs_in_queue);
if (msg != nullptr)
{
return CURLMultiResponse{ msg->easy_handle, msg->data.result, msg->msg == CURLMSG_DONE };
return CURLMultiResponse{msg->easy_handle, msg->data.result, msg->msg == CURLMSG_DONE};
}
else
{

View File

@ -23,7 +23,7 @@ namespace mamba
read_package_info(ChannelContext& channel_context, const YAML::Node& package_node)
{
Package package{
/* .info = */ mamba::PackageInfo{ package_node["name"].as<std::string>() },
/* .info = */ mamba::PackageInfo{package_node["name"].as<std::string>()},
/* .is_optional = */
[&]
{
@ -58,7 +58,7 @@ namespace mamba
}
package.info.url = package_node["url"].as<std::string>();
const MatchSpec spec{ package.info.url, channel_context };
const MatchSpec spec{package.info.url, channel_context};
package.info.fn = spec.fn;
package.info.build_string = spec.build_string;
package.info.subdir = spec.subdir;
@ -169,7 +169,7 @@ namespace mamba
}
}
return EnvironmentLockFile{ std::move(metadata), std::move(packages) };
return EnvironmentLockFile{std::move(metadata), std::move(packages)};
}
}
@ -210,7 +210,7 @@ namespace mamba
file_path.string(),
err.what()
),
std::type_index{ typeid(err) }
std::type_index{typeid(err)}
));
}
catch (...)

View File

@ -24,9 +24,9 @@ namespace mamba
// See:
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/getenv-s-wgetenv-s?view=msvc-170
static std::mutex call_mutex;
std::scoped_lock ready_to_execute{ call_mutex }; // Calls to getenv_s kinds of
// functions are not thread-safe, this
// is to prevent related issues.
std::scoped_lock ready_to_execute{call_mutex}; // Calls to getenv_s kinds of
// functions are not thread-safe, this
// is to prevent related issues.
const auto on_failed = [&](errno_t error_code)
{
@ -86,9 +86,9 @@ namespace mamba
// See:
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/getenv-s-wgetenv-s?view=msvc-170
static std::mutex call_mutex;
std::scoped_lock ready_to_execute{ call_mutex }; // Calls to getenv_s kinds of
// functions are not thread-safe, this
// is to prevent related issues.
std::scoped_lock ready_to_execute{call_mutex}; // Calls to getenv_s kinds of
// functions are not thread-safe, this
// is to prevent related issues.
const std::wstring unicode_key = to_windows_unicode(key);
const std::wstring unicode_value = to_windows_unicode(value);

View File

@ -121,7 +121,7 @@ namespace mamba
// }
// else
{
search_dirs = std::vector<fs::u8path>{ env::home_directory() };
search_dirs = std::vector<fs::u8path>{env::home_directory()};
}
std::set<fs::u8path> all_env_paths;

View File

@ -8,7 +8,7 @@ namespace mamba
void MainExecutor::invoke_close_handlers()
{
std::scoped_lock lock{ handlers_mutex };
std::scoped_lock lock{handlers_mutex};
for (auto&& handler : close_handlers)
{
const auto result = safe_invoke(handler);

View File

@ -76,7 +76,7 @@ namespace mamba::path
}
}
// directory exists, now create empty file
std::ofstream outfile{ path.std_path(), std::ios::out };
std::ofstream outfile{path.std_path(), std::ios::out};
if (!outfile.good())
{
@ -147,7 +147,7 @@ namespace mamba::path
}
}
);
std::ofstream test_file{ test_file_path.std_path(), std::ios_base::out | std::ios_base::app };
std::ofstream test_file{test_file_path.std_path(), std::ios_base::out | std::ios_base::app};
return test_file.is_open();
}
} // namespace path

View File

@ -184,7 +184,7 @@ namespace mamba
conda_exe_f.write(reinterpret_cast<char*>(conda_exe), conda_exe_len);
conda_exe_f.close();
make_executable(m_context->target_prefix / script_exe);
return std::array<std::string, 2>{ win_script, script_exe.string() };
return std::array<std::string, 2>{win_script, script_exe.string()};
#else
if (!python_path.empty())
{
@ -363,14 +363,14 @@ namespace mamba
prefix,
Context::instance().dev,
false,
{ "@CALL", path.string() }
{"@CALL", path.string()}
);
command_args = { comspec.value(), "/d", "/c", script_file->path().string() };
command_args = {comspec.value(), "/d", "/c", script_file->path().string()};
}
else
{
command_args = { comspec.value(), "/d", "/c", path.string() };
command_args = {comspec.value(), "/d", "/c", path.string()};
}
}
@ -391,7 +391,7 @@ namespace mamba
prefix,
Context::instance().dev,
false,
{ ".", path.string() }
{".", path.string()}
);
command_args.push_back(shell_path.string());
command_args.push_back(script_file->path().string());
@ -880,8 +880,9 @@ namespace mamba
auto [sha256_in_prefix, final_path] = link_path(path, noarch_type == NoarchType::PYTHON);
files_record.push_back(final_path);
nlohmann::json json_record = { { "_path", final_path },
{ "sha256_in_prefix", sha256_in_prefix } };
nlohmann::json json_record = {
{"_path", final_path},
{"sha256_in_prefix", sha256_in_prefix}};
if (!path.sha256.empty())
{
@ -987,7 +988,7 @@ namespace mamba
out_json["extracted_package_dir"] = m_source.string();
// TODO find out what `1` means
out_json["link"] = { { "source", m_source.string() }, { "type", 1 } };
out_json["link"] = {{"source", m_source.string()}, {"type", 1}};
if (noarch_type == NoarchType::PYTHON)
{
@ -1014,8 +1015,9 @@ namespace mamba
std::vector<fs::u8path> pyc_files = compile_pyc_files(for_compilation);
for (const fs::u8path& pyc_path : pyc_files)
{
out_json["paths_data"]["paths"].push_back({ { "_path", pyc_path.string() },
{ "path_type", "pyc_file" } });
out_json["paths_data"]["paths"].push_back(
{{"_path", pyc_path.string()}, {"path_type", "pyc_file"}}
);
out_json["files"].push_back(pyc_path.string());
}
@ -1034,16 +1036,16 @@ namespace mamba
#ifdef _WIN32
out_json["paths_data"]["paths"].push_back(
{ { "_path", files[0] }, { "path_type", "windows_python_entry_point_script" } }
{{"_path", files[0]}, {"path_type", "windows_python_entry_point_script"}}
);
out_json["paths_data"]["paths"].push_back(
{ { "_path", files[1] }, { "path_type", "windows_python_entry_point_exe" } }
{{"_path", files[1]}, {"path_type", "windows_python_entry_point_exe"}}
);
out_json["files"].push_back(files[0]);
out_json["files"].push_back(files[1]);
#else
out_json["paths_data"]["paths"].push_back(
{ { "_path", files }, { "path_type", "unix_python_entry_point" } }
{{"_path", files}, {"path_type", "unix_python_entry_point"}}
);
out_json["files"].push_back(files);
#endif

View File

@ -40,7 +40,7 @@ namespace mamba
{
std::string tmp = s;
replace_all(tmp, " ", "");
return { tmp, "" };
return {tmp, ""};
}
else
{
@ -53,7 +53,7 @@ namespace mamba
{
std::string tmp = s;
replace_all(tmp, " ", "");
return { tmp, "" };
return {tmp, ""};
}
}
// c is either ' ' or pm1 is none of the forbidden chars
@ -61,7 +61,7 @@ namespace mamba
std::string v = s.substr(0, pos), b = s.substr(pos + 1);
replace_all(v, " ", "");
replace_all(b, " ", "");
return { v, b };
return {v, b};
}
}
@ -421,9 +421,14 @@ namespace mamba
}
std::vector<std::string> check = {
"build_number", "track_features", "features", "url",
"md5", "license", "license_family", "fn"
};
"build_number",
"track_features",
"features",
"url",
"md5",
"license",
"license_family",
"fn"};
if (!url.empty())
{

View File

@ -168,9 +168,9 @@ namespace mamba
}
const std::map<std::string, KNOWNFOLDERID> knownfolders = {
{ "programs", FOLDERID_Programs },
{ "profile", FOLDERID_Profile },
{ "documents", FOLDERID_Documents },
{"programs", FOLDERID_Programs},
{"profile", FOLDERID_Profile},
{"documents", FOLDERID_Documents},
};
fs::u8path get_folder(const std::string& id)
@ -252,13 +252,13 @@ namespace mamba
}
std::map<std::string, std::string> vars = {
{ "${PREFIX}", to_forward_slash(target_prefix) },
{ "${ROOT_PREFIX}", to_forward_slash(root_prefix) },
{ "${PY_VER}", py_ver },
{ "${MENU_DIR}", to_forward_slash(target_prefix / "Menu") },
{ "${DISTRIBUTION_NAME}", distribution_name },
{ "${ENV_NAME}", detail::get_formatted_env_name(target_prefix) },
{ "${PLATFORM}", platform_bitness },
{"${PREFIX}", to_forward_slash(target_prefix)},
{"${ROOT_PREFIX}", to_forward_slash(root_prefix)},
{"${PY_VER}", py_ver},
{"${MENU_DIR}", to_forward_slash(target_prefix / "Menu")},
{"${DISTRIBUTION_NAME}", distribution_name},
{"${ENV_NAME}", detail::get_formatted_env_name(target_prefix)},
{"${PLATFORM}", platform_bitness},
};
#ifdef _WIN32
@ -320,10 +320,10 @@ namespace mamba
const fs::u8path env_pyw = target_prefix / "pythonw.exe";
const auto cwp_path = root_prefix / "cwp.py";
std::vector<std::string> cwp_py_args(
{ cwp_path.string(), target_prefix.string(), env_py.string() }
{cwp_path.string(), target_prefix.string(), env_py.string()}
);
std::vector<std::string> cwp_pyw_args(
{ cwp_path.string(), target_prefix.string(), env_pyw.string() }
{cwp_path.string(), target_prefix.string(), env_pyw.string()}
);
fs::u8path target_dir = win::get_folder("programs") / menu_name;
@ -374,12 +374,12 @@ namespace mamba
else if (item.contains("webbrowser"))
{
script = root_pyw;
arguments = { "-m", "webbrowser", "-t", item["webbrowser"] };
arguments = {"-m", "webbrowser", "-t", item["webbrowser"]};
}
else if (item.contains("script"))
{
script = root_py;
arguments = { cwp_path.string(), target_prefix.string() };
arguments = {cwp_path.string(), target_prefix.string()};
auto tmp = split(item["script"], " ");
std::copy(tmp.begin(), tmp.end(), back_inserter(arguments));
extend_script_args(item, arguments);

View File

@ -78,7 +78,7 @@ namespace mamba
void
Table::add_rows(const std::string& header, const std::vector<std::vector<FormattedString>>& rs)
{
m_table.push_back({ header });
m_table.push_back({header});
for (auto& r : rs)
{
@ -548,7 +548,7 @@ namespace mamba
else
{
const std::lock_guard<std::mutex> lock(MessageLoggerData::m_mutex);
MessageLoggerData::m_buffer.push_back({ m_stream.str(), m_level });
MessageLoggerData::m_buffer.push_back({m_stream.str(), m_level});
}
}

View File

@ -309,7 +309,7 @@ namespace mamba
for (auto& dir_entry : fs::recursive_directory_iterator("."))
{
auto clean_path = dir_entry.path().lexically_relative("./");
files.push_back({ order(clean_path), clean_path });
files.push_back({order(clean_path), clean_path});
}
}
else
@ -318,7 +318,7 @@ namespace mamba
for (auto& dir_entry : fs::directory_iterator("."))
{
auto clean_path = dir_entry.path().lexically_relative("./");
files.push_back({ zip_order(clean_path), clean_path });
files.push_back({zip_order(clean_path), clean_path});
}
}
@ -740,11 +740,11 @@ namespace mamba
std::vector<std::string> args;
if (Context::instance().command_params.is_micromamba)
{
args = { get_self_exe_path().string(), "package", "extract", file.string(), dest.string() };
args = {get_self_exe_path().string(), "package", "extract", file.string(), dest.string()};
}
else
{
args = { "mamba-package", "extract", file.string(), dest.string() };
args = {"mamba-package", "extract", file.string(), dest.string()};
}
std::string out, err;

View File

@ -36,13 +36,14 @@ namespace mamba
auto s = split(l, " ");
if (s.size() == 1)
{
res[s[0]] = PrefixFileParse{ concat(PREFIX_PLACEHOLDER_1, PREFIX_PLACEHOLDER_2),
"text",
s[0] };
res[s[0]] = PrefixFileParse{
concat(PREFIX_PLACEHOLDER_1, PREFIX_PLACEHOLDER_2),
"text",
s[0]};
}
else if (s.size() == 3)
{
res[s[2]] = PrefixFileParse{ s[0], s[1], s[2] };
res[s[2]] = PrefixFileParse{s[0], s[1], s[2]};
}
else
{

View File

@ -30,7 +30,7 @@ namespace mamba
for (const auto& spec : specs)
{
MatchSpec ms{ spec, prefix_data.channel_context() };
MatchSpec ms{spec, prefix_data.channel_context()};
if (ms.name == "python")
{
return "";

View File

@ -115,7 +115,7 @@ namespace mamba
std::vector<Id> MPool::select_solvables(Id matchspec, bool sorted) const
{
auto solvables = pool().select_solvables({ SOLVER_SOLVABLE_PROVIDES, matchspec });
auto solvables = pool().select_solvables({SOLVER_SOLVABLE_PROVIDES, matchspec});
if (sorted)
{
@ -286,7 +286,7 @@ namespace mamba
{
if (const auto solv = pool().get_solvable(solv_id))
{
return { make_package_info(pool(), solv.value()) };
return {make_package_info(pool(), solv.value())};
}
return std::nullopt;
}

View File

@ -67,7 +67,7 @@ namespace mamba
{
LOG_DEBUG << "Adding virtual package: " << pkg.name << "=" << pkg.version << "="
<< pkg.build_string;
m_package_records.insert({ pkg.name, std::move(pkg) });
m_package_records.insert({pkg.name, std::move(pkg)});
}
}
@ -99,7 +99,7 @@ namespace mamba
for (const auto& dep : record->depends)
{
// Creating a matchspec to parse the name (there may be a channel)
auto ms = MatchSpec{ dep, m_channel_context };
auto ms = MatchSpec{dep, m_channel_context};
// Ignoring unmatched dependencies, the environment could be broken
// or it could be a matchspec
const auto from_iter = name_to_node_id.find(ms.name);
@ -113,7 +113,7 @@ namespace mamba
// Flip known problematic edges.
// This is made to adress cycles but there is no straightforward way to make
// a generic cycle handler so we instead force flip the given edges
static constexpr auto edges_to_flip = std::array{ std::pair{ "pip", "python" } };
static constexpr auto edges_to_flip = std::array{std::pair{"pip", "python"}};
for (const auto& [from, to] : edges_to_flip)
{
const auto from_iter = name_to_node_id.find(from);
@ -159,6 +159,6 @@ namespace mamba
nlohmann::json j;
infile >> j;
auto prec = PackageInfo(std::move(j));
m_package_records.insert({ prec.name, std::move(prec) });
m_package_records.insert({prec.name, std::move(prec)});
}
} // namespace mamba

View File

@ -157,7 +157,7 @@ namespace mamba
// TODO: bytes sould be size_t and the implementation is wrong
void to_human_readable_filesize(std::ostream& o, double bytes, std::size_t precision)
{
static constexpr const char* sizes[] = { " B", "kB", "MB", "GB", "TB", "PB" };
static constexpr const char* sizes[] = {" B", "kB", "MB", "GB", "TB", "PB"};
int order = 0;
while (bytes >= 1000 && order < (6 - 1))
{
@ -861,7 +861,7 @@ namespace mamba
std::vector<FieldRepr*> ProgressBarRepr::fields()
{
return { &prefix, &progress, &current, &separator, &total, &speed, &postfix, &elapsed };
return {&prefix, &progress, &current, &separator, &total, &speed, &postfix, &elapsed};
}
ProgressBarRepr& ProgressBarRepr::reset_fields()
@ -907,11 +907,11 @@ namespace mamba
std::vector<std::string> spinner;
if (!m_ascii_only)
{
spinner = { "", "", "", "", "", "", "", "", "", "" };
spinner = {"", "", "", "", "", "", "", "", "", ""};
}
else
{
spinner = { "|", "/", "-", "|", "\\", "|", "/", "-", "|", "\\" };
spinner = {"|", "/", "-", "|", "\\", "|", "/", "-", "|", "\\"};
}
constexpr int spinner_rounds = 2;
@ -1198,7 +1198,7 @@ namespace mamba
{
if (m_labels.count(label) == 0)
{
m_labels.insert({ label, { raw_bar(progress_bar) } });
m_labels.insert({label, {raw_bar(progress_bar)}});
}
else
{
@ -1853,12 +1853,10 @@ namespace mamba
std::lock_guard<std::mutex> lock(m_mutex);
if (m_aggregated_bars.count(label) == 0)
{
m_aggregated_bars.insert({ label,
std::make_unique<DefaultProgressBar>(
label,
std::numeric_limits<std::size_t>::max(),
100
) });
m_aggregated_bars.insert(
{label,
std::make_unique<DefaultProgressBar>(label, std::numeric_limits<std::size_t>::max(), 100)}
);
}
}

View File

@ -217,8 +217,8 @@ namespace mamba
duration_t m_period = std::chrono::milliseconds(100);
std::vector<progress_bar_ptr> m_progress_bars = {};
std::map<std::string, std::vector<ProgressBar*>> m_labels;
std::atomic<bool> m_marked_to_terminate{ false };
std::atomic<bool> m_watch_print_started{ false };
std::atomic<bool> m_marked_to_terminate{false};
std::atomic<bool> m_watch_print_started{false};
bool m_sort_bars = false;
std::size_t m_width = 0;

View File

@ -52,7 +52,7 @@ namespace mamba
{
solv::ObjQueue rec_solvables = {};
// the following prints the requested version
solv::ObjQueue job = { SOLVER_SOLVABLE_PROVIDES, req };
solv::ObjQueue job = {SOLVER_SOLVABLE_PROVIDES, req};
selection_solvables(pool, job.raw(), rec_solvables.raw());
if (rec_solvables.size() != 0)
@ -255,7 +255,7 @@ namespace mamba
throw std::runtime_error("Could not generate query for " + query);
}
solv::ObjQueue job = { SOLVER_SOLVABLE_PROVIDES, id };
solv::ObjQueue job = {SOLVER_SOLVABLE_PROVIDES, id};
query_result::dependency_graph g;
if (tree)
@ -268,7 +268,7 @@ namespace mamba
assert(pkg_info.has_value());
const auto node_id = g.add_node(std::move(pkg_info).value());
Solvable* const latest = pool_id2solvable(m_pool.get(), solvables.front());
std::map<Solvable*, size_t> visited = { { latest, node_id } };
std::map<Solvable*, size_t> visited = {{latest, node_id}};
reverse_walk_graph(m_pool, g, node_id, latest, visited);
}
}
@ -323,7 +323,7 @@ namespace mamba
assert(pkg_info.has_value());
const auto node_id = g.add_node(std::move(pkg_info).value());
std::map<Solvable*, size_t> visited = { { latest, node_id } };
std::map<Solvable*, size_t> visited = {{latest, node_id}};
std::map<std::string, size_t> not_found;
walk_graph(m_pool, g, node_id, latest, visited, not_found, depth);
}
@ -408,7 +408,7 @@ namespace mamba
std::ostream& query_result::table(std::ostream& out) const
{
return table(out, { "Name", "Version", "Build", "Channel" });
return table(out, {"Name", "Version", "Build", "Channel"});
}
namespace
@ -631,12 +631,13 @@ namespace mamba
std::string query_type = m_type == QueryType::kSEARCH
? "search"
: (m_type == QueryType::kDEPENDS ? "depends" : "whoneeds");
j["query"] = { { "query", MatchSpec{ m_query, channel_context }.conda_build_form() },
{ "type", query_type } };
j["query"] = {
{"query", MatchSpec{m_query, channel_context}.conda_build_form()},
{"type", query_type}};
std::string msg = m_pkg_id_list.empty() ? "No entries matching \"" + m_query + "\" found"
: "";
j["result"] = { { "msg", msg }, { "status", "OK" } };
j["result"] = {{"msg", msg}, {"status", "OK"}};
j["result"]["pkgs"] = nlohmann::json::array();
for (size_t i = 0; i < m_pkg_id_list.size(); ++i)

View File

@ -77,12 +77,12 @@ namespace mamba
// Keeping the solv-cpp header private
auto srepo(const MRepo& r) -> solv::ObjRepoViewConst
{
return solv::ObjRepoViewConst{ *const_cast<const ::Repo*>(r.repo()) };
return solv::ObjRepoViewConst{*const_cast<const ::Repo*>(r.repo())};
}
auto srepo(MRepo& r) -> solv::ObjRepoView
{
return solv::ObjRepoView{ *r.repo() };
return solv::ObjRepoView{*r.repo()};
}
}

View File

@ -62,11 +62,17 @@ namespace mamba
};
static std::vector alt_names{
"program", "application", "app", "code", "blob", "binary", "script",
"program",
"application",
"app",
"code",
"blob",
"binary",
"script",
};
static std::vector prefixes_bag(prefixes.cbegin(), prefixes.cend());
std::string selected_name{ program_name };
std::string selected_name{program_name};
while (true)
{
std::string selected_prefix;
@ -132,8 +138,7 @@ namespace mamba
proc_dir_path.string(),
error->what()
),
mamba_error_code::lockfile_failure
};
mamba_error_code::lockfile_failure};
}
else
{
@ -152,7 +157,7 @@ namespace mamba
const auto open_mode = std::ios::binary | std::ios::in;
for (auto&& entry : fs::directory_iterator{ proc_dir() })
for (auto&& entry : fs::directory_iterator{proc_dir()})
{
const auto file_location = entry.path();
if (file_location.extension() != ".json")
@ -160,7 +165,7 @@ namespace mamba
continue;
}
std::ifstream pid_file{ file_location.std_path(), open_mode };
std::ifstream pid_file{file_location.std_path(), open_mode};
if (!pid_file.is_open())
{
LOG_WARNING << fmt::format("failed to open {}", file_location.string());
@ -191,7 +196,7 @@ namespace mamba
const std::vector<std::string>& command,
LockFile proc_dir_lock
)
: location{ proc_dir() / fmt::format("{}.json", getpid()) }
: location{proc_dir() / fmt::format("{}.json", getpid())}
{
// Lock must be hold for the duraction of this constructor.
if (is_file_locking_allowed())
@ -396,7 +401,7 @@ namespace mamba
if (specific_process_name.empty())
{
const auto unique_name = generate_unique_process_name(*exe_name_it);
command.insert(exe_name_it, { { "-a" }, unique_name });
command.insert(exe_name_it, {{"-a"}, unique_name});
return unique_name;
}
else
@ -408,7 +413,7 @@ namespace mamba
specific_process_name
));
}
command.insert(exe_name_it, { { "-a" }, specific_process_name });
command.insert(exe_name_it, {{"-a"}, specific_process_name});
return specific_process_name;
}
}();
@ -449,10 +454,12 @@ namespace mamba
{
LOG_INFO << "Received SIGTERM on micromamba run - terminating process";
reproc::stop_actions sa;
sa.first = reproc::stop_action{ reproc::stop::terminate,
std::chrono::milliseconds(3000) };
sa.second = reproc::stop_action{ reproc::stop::kill,
std::chrono::milliseconds(3000) };
sa.first = reproc::stop_action{
reproc::stop::terminate,
std::chrono::milliseconds(3000)};
sa.second = reproc::stop_action{
reproc::stop::kill,
std::chrono::milliseconds(3000)};
proc.stop(sa);
}
);

View File

@ -118,7 +118,7 @@ namespace mamba
}
}
}
return { std::move(graph), std::move(conflicts), pbs.root_node() };
return {std::move(graph), std::move(conflicts), pbs.root_node()};
}
/***********************************************
@ -433,7 +433,7 @@ namespace mamba
old_to_new
);
}
return std::tuple{ std::move(new_graph), new_root_node, std::move(old_to_new) };
return std::tuple{std::move(new_graph), new_root_node, std::move(old_to_new)};
}
/**
@ -509,7 +509,7 @@ namespace mamba
}
merge_edges(pbs.graph(), graph, old_to_new);
auto conflicts = merge_conflicts(pbs.conflicts(), old_to_new);
return { std::move(graph), std::move(conflicts), root_node };
return {std::move(graph), std::move(conflicts), root_node};
}
CompressedProblemsGraph::CompressedProblemsGraph(graph_t graph, conflicts_t conflicts, node_id root_node)
@ -661,7 +661,7 @@ namespace mamba
{
versions.erase(std::unique(versions.begin(), versions.end()), versions.end());
}
return { join_trunc(versions, sep, etc, threshold), versions.size() };
return {join_trunc(versions, sep, etc, threshold), versions.size()};
}
template <typename T, typename A>
@ -684,7 +684,7 @@ namespace mamba
{
builds.erase(std::unique(builds.begin(), builds.end()), builds.end());
}
return { join_trunc(builds, sep, etc, threshold), builds.size() };
return {join_trunc(builds, sep, etc, threshold), builds.size()};
}
template <typename T, typename A>
@ -714,7 +714,7 @@ namespace mamba
versions_builds.end()
);
}
return { join_trunc(versions_builds, sep, etc, threshold), versions_builds.size() };
return {join_trunc(versions_builds, sep, etc, threshold), versions_builds.size()};
}
template <typename T, typename A>
@ -1067,7 +1067,7 @@ namespace mamba
out = children_begin;
}
return { out, ongoing.status };
return {out, ongoing.status};
}
auto TreeDFS::visit_node(node_id root_id, TreeNodeIter out) -> std::pair<TreeNodeIter, Status>
@ -1075,8 +1075,8 @@ namespace mamba
auto& ongoing = *(out++);
ongoing = TreeNode{
/* .ancestry= */ {},
/* .ids= */ { root_id },
/* .ids_from= */ { root_id },
/* .ids= */ {root_id},
/* .ids_from= */ {root_id},
/* .type= */ node_type(root_id),
/* .type_from= */ node_type(root_id),
/* .status= */ {}, // Placeholder updated
@ -1094,7 +1094,7 @@ namespace mamba
auto& ongoing = *(out++);
ongoing = TreeNode{
/* .ancestry= */ concat(from.ancestry, position),
/* .ids= */ { id },
/* .ids= */ {id},
/* .ids_from= */ from.ids,
/* .type= */ node_type(id),
/* .type_from= */ from.type,
@ -1116,7 +1116,7 @@ namespace mamba
if (const auto status = m_node_visited[id]; status.has_value())
{
return { out, status.value() };
return {out, status.value()};
}
Status status = true;
@ -1151,7 +1151,7 @@ namespace mamba
status = !node_not_installable(id) && status;
m_node_visited[id] = status;
return { out, status };
return {out, status};
}
/**

View File

@ -97,7 +97,7 @@ namespace mamba
#ifdef _WIN32
std::wstring get_autorun_registry_key(const std::wstring& reg_path)
{
winreg::RegKey key{ HKEY_CURRENT_USER, reg_path };
winreg::RegKey key{HKEY_CURRENT_USER, reg_path};
std::wstring content;
try
{
@ -119,7 +119,7 @@ namespace mamba
fmt::styled(to_utf8(value), Context::instance().graphics_params.palette.success)
);
winreg::RegKey key{ HKEY_CURRENT_USER, reg_path };
winreg::RegKey key{HKEY_CURRENT_USER, reg_path};
key.SetStringValue(L"AutoRun", value);
}
@ -253,7 +253,7 @@ namespace mamba
std::string out, err;
try
{
std::vector<std::string> args{ command, path };
std::vector<std::string> args{command, path};
if (is_a_path_env)
{
args.push_back("--path");
@ -654,11 +654,12 @@ namespace mamba
auto scripts_activate_bat = root_prefix / "Scripts" / "activate.bat";
auto mamba_hook_bat = root_prefix / "condabin" / "mamba_hook.bat";
for (auto& f : { micromamba_bat,
_mamba_activate_bat,
condabin_activate_bat,
scripts_activate_bat,
mamba_hook_bat })
for (auto& f :
{micromamba_bat,
_mamba_activate_bat,
condabin_activate_bat,
scripts_activate_bat,
mamba_hook_bat})
{
if (fs::exists(f))
{
@ -674,7 +675,7 @@ namespace mamba
// remove condabin and Scripts if empty
auto condabin = root_prefix / "condabin";
auto scripts = root_prefix / "Scripts";
for (auto& d : { condabin, scripts })
for (auto& d : {condabin, scripts})
{
if (fs::exists(d) && fs::is_empty(d))
{
@ -988,7 +989,7 @@ namespace mamba
{
std::string out, err;
auto [status, ec] = reproc::run(
std::vector<std::string>{ exe, "-NoProfile", "-Command", profile_var },
std::vector<std::string>{exe, "-NoProfile", "-Command", profile_var},
reproc::options{},
reproc::sink::string(out),
reproc::sink::string(err)
@ -1054,7 +1055,7 @@ namespace mamba
else if (shell == "powershell")
{
std::set<std::string> pwsh_profiles;
for (auto& exe : std::vector<std::string>{ "powershell", "pwsh", "pwsh-preview" })
for (auto& exe : std::vector<std::string>{"powershell", "pwsh", "pwsh-preview"})
{
auto profile_path = find_powershell_paths(exe);
if (!profile_path.empty())
@ -1122,7 +1123,7 @@ namespace mamba
else if (shell == "powershell")
{
std::set<std::string> pwsh_profiles;
for (auto& exe : std::vector<std::string>{ "powershell", "pwsh", "pwsh-preview" })
for (auto& exe : std::vector<std::string>{"powershell", "pwsh", "pwsh-preview"})
{
auto profile_path = find_powershell_paths(exe);
if (!profile_path.empty())
@ -1172,7 +1173,7 @@ namespace mamba
fs::u8path home = env::home_directory();
std::vector<std::string> result;
std::vector<std::string> supported_shells = { "bash", "zsh", "xonsh", "csh", "fish" };
std::vector<std::string> supported_shells = {"bash", "zsh", "xonsh", "csh", "fish"};
for (const std::string& shell : supported_shells)
{
fs::u8path config_path = config_path_for_shell(shell);
@ -1198,7 +1199,7 @@ namespace mamba
// powershell
{
std::set<std::string> pwsh_profiles;
for (auto& exe : std::vector<std::string>{ "powershell", "pwsh", "pwsh-preview" })
for (auto& exe : std::vector<std::string>{"powershell", "pwsh", "pwsh-preview"})
{
auto profile_path = find_powershell_paths(exe);
if (!profile_path.empty() && fs::exists(profile_path))

View File

@ -104,7 +104,7 @@ namespace mamba
//--- Concurrency resources / thread-handling
//------------------------------------------------------------------
static std::atomic<MainExecutor*> main_executor{ nullptr };
static std::atomic<MainExecutor*> main_executor{nullptr};
static std::unique_ptr<MainExecutor> default_executor;
static std::mutex default_executor_mutex; // TODO: replace by sychronized_value once available
@ -114,7 +114,7 @@ namespace mamba
if (!main_executor)
{
// When no MainExecutor was created before we create a static one.
std::scoped_lock lock{ default_executor_mutex };
std::scoped_lock lock{default_executor_mutex};
if (!main_executor) // double check necessary to avoid data race
{
default_executor = std::make_unique<MainExecutor>();
@ -127,7 +127,7 @@ namespace mamba
void MainExecutor::stop_default()
{
std::scoped_lock lock{ default_executor_mutex };
std::scoped_lock lock{default_executor_mutex};
default_executor.reset();
}

View File

@ -121,7 +121,7 @@ namespace mamba
{
for (const auto& job : jobs)
{
MatchSpec ms{ job, m_pool.channel_context() };
MatchSpec ms{job, m_pool.channel_context()};
int job_type = job_flag & SOLVER_JOBMASK;
if (job_type & SOLVER_INSTALL)
@ -167,7 +167,7 @@ namespace mamba
{
m_jobs->push_back(
SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES,
m_pool.matchspec2id({ job, m_pool.channel_context() })
m_pool.matchspec2id({job, m_pool.channel_context()})
);
}
@ -199,7 +199,7 @@ namespace mamba
// as one of its constrains.
// Then we lock this solvable and force the re-checking of its dependencies.
const auto pin_ms = MatchSpec{ pin, m_pool.channel_context() };
const auto pin_ms = MatchSpec{pin, m_pool.channel_context()};
m_pinned_specs.push_back(pin_ms);
auto& pool = m_pool.pool();
@ -219,7 +219,7 @@ namespace mamba
std::string const cons_solv_name = fmt::format("pin-{}", m_pinned_specs.size());
cons_solv.set_name(cons_solv_name);
cons_solv.set_version("1");
cons_solv.add_constraints(solv::ObjQueue{ m_pool.matchspec2id(pin_ms) });
cons_solv.add_constraints(solv::ObjQueue{m_pool.matchspec2id(pin_ms)});
// Solvable need to provide itself
cons_solv.add_self_provide();
@ -230,7 +230,7 @@ namespace mamba
// Lock the dummy solvable so that it stays install.
// Force verify the dummy solvable dependencies, as this is not the default for
// installed packages.
return add_jobs({ cons_solv_name }, SOLVER_LOCK & SOLVER_VERIFY);
return add_jobs({cons_solv_name}, SOLVER_LOCK & SOLVER_VERIFY);
}
void MSolver::add_pins(const std::vector<std::string>& pins)
@ -317,7 +317,7 @@ namespace mamba
const bool success = solver().solve(m_pool.pool(), *m_jobs);
m_is_solved = true;
LOG_INFO << "Problem count: " << solver().problem_count();
Console::instance().json_write({ { "success", success } });
Console::instance().json_write({{"success", success}});
return success;
}
@ -417,8 +417,8 @@ namespace mamba
print_problem_tree_msg(
out,
cp_pbs,
{ /* .unavailable= */ ctx.graphics_params.palette.failure,
/* .available= */ ctx.graphics_params.palette.success }
{/* .unavailable= */ ctx.graphics_params.palette.failure,
/* .available= */ ctx.graphics_params.palette.success}
);
return out;
}
@ -504,8 +504,8 @@ namespace mamba
};
ProblemsGraphCreator::ProblemsGraphCreator(const MSolver& solver, const MPool& pool)
: m_solver{ solver }
, m_pool{ pool }
: m_solver{solver}
, m_pool{pool}
{
m_root_node = m_graph.add_node(RootNode());
parse_problems();
@ -513,7 +513,7 @@ namespace mamba
ProblemsGraph ProblemsGraphCreator::problem_graph() &&
{
return { std::move(m_graph), std::move(m_conflicts), m_root_node };
return {std::move(m_graph), std::move(m_conflicts), m_root_node};
}
auto ProblemsGraphCreator::add_solvable(solv::SolvableId solv_id, node_t&& node, bool update)
@ -550,7 +550,7 @@ namespace mamba
added = true;
auto pkg_info = m_pool.id2pkginfo(solv_id);
assert(pkg_info.has_value());
node_id to_id = add_solvable(solv_id, PackageNode{ std::move(pkg_info).value() }, false);
node_id to_id = add_solvable(solv_id, PackageNode{std::move(pkg_info).value()}, false);
m_graph.add_edge(from_id, to_id, edge);
}
return added;
@ -581,15 +581,15 @@ namespace mamba
}
auto src_id = add_solvable(
problem.source_id,
PackageNode{ std::move(source).value() }
PackageNode{std::move(source).value()}
);
node_id tgt_id = add_solvable(
problem.target_id,
PackageNode{ std::move(target).value() }
PackageNode{std::move(target).value()}
);
node_id cons_id = add_solvable(
problem.dep_id,
ConstraintNode{ { dep.value(), channel_context } }
ConstraintNode{{dep.value(), channel_context}}
);
MatchSpec edge(dep.value(), channel_context);
m_graph.add_edge(src_id, cons_id, std::move(edge));
@ -609,7 +609,7 @@ namespace mamba
}
auto src_id = add_solvable(
problem.source_id,
PackageNode{ std::move(source).value() }
PackageNode{std::move(source).value()}
);
MatchSpec edge(dep.value(), channel_context);
bool added = add_expanded_deps_edges(src_id, problem.dep_id, edge);
@ -652,7 +652,7 @@ namespace mamba
MatchSpec edge(dep.value(), channel_context);
node_id dep_id = add_solvable(
problem.dep_id,
UnresolvedDependencyNode{ { std::move(dep).value(), channel_context } }
UnresolvedDependencyNode{{std::move(dep).value(), channel_context}}
);
m_graph.add_edge(m_root_node, dep_id, std::move(edge));
break;
@ -671,11 +671,11 @@ namespace mamba
MatchSpec edge(dep.value(), channel_context);
node_id src_id = add_solvable(
problem.source_id,
PackageNode{ std::move(source).value() }
PackageNode{std::move(source).value()}
);
node_id dep_id = add_solvable(
problem.dep_id,
UnresolvedDependencyNode{ { std::move(dep).value(), channel_context } }
UnresolvedDependencyNode{{std::move(dep).value(), channel_context}}
);
m_graph.add_edge(src_id, dep_id, std::move(edge));
break;
@ -694,11 +694,11 @@ namespace mamba
}
node_id src_id = add_solvable(
problem.source_id,
PackageNode{ std::move(source).value() }
PackageNode{std::move(source).value()}
);
node_id tgt_id = add_solvable(
problem.target_id,
PackageNode{ std::move(target).value() }
PackageNode{std::move(target).value()}
);
add_conflict(src_id, tgt_id);
break;

View File

@ -63,8 +63,9 @@ namespace mamba
{
if (contains(c, channel->location()) && contains(c, channel->name()))
{
has_zst = { true,
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()) };
has_zst = {
true,
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now())};
return true;
break;
}
@ -137,8 +138,7 @@ namespace mamba
{
m.has_zst = {
j["has_zst"]["value"].get<bool>(),
parse_utc_timestamp(j["has_zst"]["last_checked"].get<std::string>(), err_code)
};
parse_utc_timestamp(j["has_zst"]["last_checked"].get<std::string>(), err_code)};
}
}
catch (const std::exception& e)
@ -462,7 +462,7 @@ namespace mamba
if (ends_with(target.get_url(), ".zst"))
{
this->m_metadata.has_zst = { target.get_http_status() == 200, utc_time_now() };
this->m_metadata.has_zst = {target.get_http_status() == 200, utc_time_now()};
}
return true;
}

View File

@ -140,7 +140,7 @@ namespace mamba
// TODO why is this only using the last job?
const auto q = m_pool.pool().select_solvables(job);
const bool remove_success = q.size() >= specs_to_remove.size();
Console::instance().json_write({ { "success", remove_success } });
Console::instance().json_write({{"success", remove_success}});
// find repo __explicit_specs__ and install all packages from it
auto repo = solv::ObjRepoView(*mrepo.repo());
@ -169,7 +169,7 @@ namespace mamba
{
Console::instance().json_down("actions");
Console::instance().json_write(
{ { "PREFIX", Context::instance().prefix_params.target_prefix.string() } }
{{"PREFIX", Context::instance().prefix_params.target_prefix.string()}}
);
}
@ -227,7 +227,7 @@ namespace mamba
add_spec += version;
}
m_history_entry.update.push_back(
MatchSpec{ add_spec, m_pool.channel_context() }.str()
MatchSpec{add_spec, m_pool.channel_context()}.str()
);
}
}
@ -259,7 +259,7 @@ namespace mamba
{
Console::instance().json_down("actions");
Console::instance().json_write(
{ { "PREFIX", Context::instance().prefix_params.target_prefix.string() } }
{{"PREFIX", Context::instance().prefix_params.target_prefix.string()}}
);
}
@ -558,12 +558,12 @@ namespace mamba
{
Console::instance().json_up();
}
Console::instance().json_write({ { "dry_run", ctx.dry_run },
{ "prefix", ctx.prefix_params.target_prefix.string() } });
Console::instance().json_write(
{{"dry_run", ctx.dry_run}, {"prefix", ctx.prefix_params.target_prefix.string()}}
);
if (empty())
{
Console::instance().json_write({ { "message",
"All requested packages already installed" } });
Console::instance().json_write({{"message", "All requested packages already installed"}});
}
if (ctx.dry_run)
@ -1065,13 +1065,15 @@ namespace mamba
Console::instance().print(" No specs added or removed.\n");
}
printers::Table t({ "Package", "Version", "Build", "Channel", "Size" });
t.set_alignment({ printers::alignment::left,
printers::alignment::right,
printers::alignment::left,
printers::alignment::left,
printers::alignment::right });
t.set_padding({ 2, 2, 2, 2, 5 });
printers::Table t({"Package", "Version", "Build", "Channel", "Size"});
t.set_alignment(
{printers::alignment::left,
printers::alignment::right,
printers::alignment::left,
printers::alignment::left,
printers::alignment::right}
);
t.set_padding({2, 2, 2, 2, 5});
solv::ObjQueue classes = {};
solv::ObjQueue pkgs = {};
@ -1154,11 +1156,13 @@ namespace mamba
assert(chan_name != "__explicit_specs__");
}
r.push_back({ name,
printers::FormattedString(std::string(s.version())),
printers::FormattedString(std::string(s.build_string())),
printers::FormattedString(cut_repo_name(chan_name)),
dlsize_s });
r.push_back(
{name,
printers::FormattedString(std::string(s.version())),
printers::FormattedString(std::string(s.build_string())),
printers::FormattedString(cut_repo_name(chan_name)),
dlsize_s}
);
};
const auto& pool = m_pool.pool();
@ -1266,7 +1270,7 @@ namespace mamba
summary << "\n Total download: ";
to_human_readable_filesize(summary, double(total_size));
summary << "\n";
t.add_row({ summary.str() });
t.add_row({summary.str()});
auto out = Console::stream();
t.print(out);
}
@ -1365,11 +1369,11 @@ namespace mamba
pip_specs.push_back(package.name + " @ " + package.url + "#sha256=" + package.sha256);
}
other_specs.push_back(
{ "pip --no-deps", pip_specs, fs::absolute(env_lockfile_path.parent_path()).string() }
{"pip --no-deps", pip_specs, fs::absolute(env_lockfile_path.parent_path()).string()}
);
}
return MTransaction{ pool, packages.conda, package_caches };
return MTransaction{pool, packages.conda, package_caches};
}
} // namespace mamba

View File

@ -191,9 +191,8 @@ namespace mamba
std::signal(SIGPIPE, SIG_IGN);
#endif
const auto complete_python_path = target_prefix / python_path;
std::vector<std::string> command = {
complete_python_path.string(), "-Wi", "-m", "compileall", "-q", "-l", "-i", "-"
};
std::vector<std::string>
command = {complete_python_path.string(), "-Wi", "-m", "compileall", "-q", "-l", "-i", "-"};
auto py_ver_split = split(python_version, ".");
@ -206,10 +205,11 @@ namespace mamba
compile_python_sources(compileall_f);
compileall_f.close();
command = { complete_python_path.string(),
"-Wi",
"-u",
m_pyc_compileall->path().string() };
command = {
complete_python_path.string(),
"-Wi",
"-u",
m_pyc_compileall->path().string()};
}
}
catch (const std::exception& e)
@ -235,9 +235,9 @@ namespace mamba
options.env.extra = envmap;
options.stop = {
{ reproc::stop::wait, reproc::milliseconds(10000) },
{ reproc::stop::terminate, reproc::milliseconds(5000) },
{ reproc::stop::kill, reproc::milliseconds(2000) },
{reproc::stop::wait, reproc::milliseconds(10000)},
{reproc::stop::terminate, reproc::milliseconds(5000)},
{reproc::stop::kill, reproc::milliseconds(2000)},
};
options.redirect.out.type = reproc::redirect::pipe;
@ -321,9 +321,9 @@ namespace mamba
int status = 0;
std::tie(status, ec) = m_pyc_process->stop({
{ reproc::stop::wait, reproc::milliseconds(100000) },
{ reproc::stop::terminate, reproc::milliseconds(5000) },
{ reproc::stop::kill, reproc::milliseconds(2000) },
{reproc::stop::wait, reproc::milliseconds(100000)},
{reproc::stop::terminate, reproc::milliseconds(5000)},
{reproc::stop::kill, reproc::milliseconds(2000)},
});
if (ec || status != 0)
{

View File

@ -479,10 +479,18 @@ namespace mamba
namespace
{
const std::vector<std::string> CURLUPART_NAMES = { "url", "scheme", "user",
"password", "options", "host",
"port", "path", "query",
"fragment", "zoneid" };
const std::vector<std::string> CURLUPART_NAMES = {
"url",
"scheme",
"user",
"password",
"options",
"host",
"port",
"path",
"query",
"fragment",
"zoneid"};
}
std::string URLHandler::get_part(CURLUPart part) const

View File

@ -981,7 +981,7 @@ namespace mamba
}
const auto absolute_file_path = fs::absolute(file_path);
std::scoped_lock lock{ mutex };
std::scoped_lock lock{mutex};
const auto it = locked_files.find(absolute_file_path);
if (it != locked_files.end())
@ -998,7 +998,7 @@ namespace mamba
[&]
{
auto lockedfile = std::make_shared<LockFileOwner>(absolute_file_path, timeout);
auto tracker = std::weak_ptr{ lockedfile };
auto tracker = std::weak_ptr{lockedfile};
locked_files.insert_or_assign(absolute_file_path, std::move(tracker));
fd_to_locked_path.insert_or_assign(lockedfile->fd(), absolute_file_path);
assert(is_lockfile_locked(*lockedfile));
@ -1011,7 +1011,7 @@ namespace mamba
bool is_locked(const fs::u8path& file_path) const
{
const auto absolute_file_path = fs::absolute(file_path);
std::scoped_lock lock{ mutex };
std::scoped_lock lock{mutex};
auto it = locked_files.find(file_path);
if (it != locked_files.end())
{
@ -1026,7 +1026,7 @@ namespace mamba
// note: the resulting value will be obsolete before returning.
bool is_locked(int fd) const
{
std::scoped_lock lock{ mutex };
std::scoped_lock lock{mutex};
const auto it = fd_to_locked_path.find(fd);
if (it != fd_to_locked_path.end())
{
@ -1040,7 +1040,7 @@ namespace mamba
private:
std::atomic_bool m_is_file_locking_allowed{ true };
std::atomic_bool m_is_file_locking_allowed{true};
// TODO: replace by something like boost::multiindex or equivalent to avoid having to
// handle 2 hashmaps
@ -1091,7 +1091,7 @@ namespace mamba
LockFile& LockFile::operator=(LockFile&&) = default;
LockFile::LockFile(const fs::u8path& path, const std::chrono::seconds& timeout)
: impl{ files_locked_by_this_process.acquire_lock(path, timeout) }
: impl{files_locked_by_this_process.acquire_lock(path, timeout)}
{
}
@ -1129,8 +1129,9 @@ namespace mamba
}
// In other cases, something is wrong.
throw mamba_error{ fmt::format("failed to check if path is locked : '{}'", path.string()),
mamba_error_code::lockfile_failure };
throw mamba_error{
fmt::format("failed to check if path is locked : '{}'", path.string()),
mamba_error_code::lockfile_failure};
}
_lseek(fd, MAMBA_LOCK_POS, SEEK_SET);
char buffer[1];
@ -1468,7 +1469,7 @@ namespace mamba
cmd
);
command_args = { comspec.value(), "/D", "/C", script_file->path().string() };
command_args = {comspec.value(), "/D", "/C", script_file->path().string()};
}
else
{
@ -1562,7 +1563,7 @@ namespace mamba
}
else
{
options = { scheme + "://" + host, scheme, "all://" + host, "all" };
options = {scheme + "://" + host, scheme, "all://" + host, "all"};
}
for (auto& option : options)

View File

@ -233,7 +233,7 @@ namespace mamba
}
std::string out, err;
std::vector<std::string> args = { env::get("COMSPEC").value_or(""), "/c", "ver" };
std::vector<std::string> args = {env::get("COMSPEC").value_or(""), "/c", "ver"};
auto [status, ec] = reproc::run(
args,
reproc::options{},
@ -289,7 +289,7 @@ namespace mamba
// an XML file
// that contains the same information. However, then we'd either need an xml
// parser or some other crude method to read the data
std::vector<std::string> args = { "sw_vers", "-productVersion" };
std::vector<std::string> args = {"sw_vers", "-productVersion"};
auto [status, ec] = reproc::run(
args,
reproc::options{},
@ -323,7 +323,7 @@ namespace mamba
}
std::string out, err;
std::vector<std::string> args = { "uname", "-r" };
std::vector<std::string> args = {"uname", "-r"};
auto [status, ec] = reproc::run(
args,
reproc::options{},
@ -692,7 +692,7 @@ namespace mamba
options.redirect.err = silence;
}
const std::vector<std::string> cmd = { "/usr/bin/codesign", "-s", "-", "-f", path.string() };
const std::vector<std::string> cmd = {"/usr/bin/codesign", "-s", "-", "-f", path.string()};
auto [status, ec] = reproc::run(cmd, options);
if (ec)
{

View File

@ -363,9 +363,9 @@ namespace mamba
std::size_t const start = input.find_first_not_of(chars);
if (start == std::basic_string_view<Char>::npos)
{
return { input, std::basic_string_view<Char>{} };
return {input, std::basic_string_view<Char>{}};
}
return { input.substr(0, start), input.substr(start) };
return {input.substr(0, start), input.substr(start)};
}
}
@ -400,9 +400,9 @@ namespace mamba
std::size_t const end = input.find_last_not_of(chars);
if (end == std::basic_string_view<Char>::npos)
{
return { std::basic_string_view<Char>{}, input };
return {std::basic_string_view<Char>{}, input};
}
return { input.substr(0, end + 1), input.substr(end + 1) };
return {input.substr(0, end + 1), input.substr(end + 1)};
}
}
@ -437,11 +437,11 @@ namespace mamba
std::size_t const start = input.find_first_not_of(chars);
if (start == std::basic_string_view<Char>::npos)
{
return { input, {}, {} };
return {input, {}, {}};
}
std::size_t const end = input.find_last_not_of(chars) + 1;
std::size_t const length = end - start;
return { input.substr(0, start), input.substr(start, length), input.substr(end) };
return {input.substr(0, start), input.substr(start, length), input.substr(end)};
}
}
@ -648,7 +648,7 @@ namespace mamba
std::string get_common_parts(std::string_view str1, std::string_view str2, std::string_view sep)
{
std::string common_str{ str1 };
std::string common_str{str1};
while ((str2.find(common_str) == std::string::npos))
{
if (common_str.find(sep) != std::string::npos)

View File

@ -293,13 +293,13 @@ namespace mamba::validation
{
std::array<unsigned char, MAMBA_ED25519_KEYSIZE_BYTES> pk, sk;
generate_ed25519_keypair(pk.data(), sk.data());
return { pk, sk };
return {pk, sk};
}
std::pair<std::string, std::string> generate_ed25519_keypair_hex()
{
auto pair = generate_ed25519_keypair();
return { ::mamba::hex_string(pair.first), ::mamba::hex_string(pair.second) };
return {::mamba::hex_string(pair.first), ::mamba::hex_string(pair.second)};
}
int sign(const std::string& data, const unsigned char* sk, unsigned char* signature)
@ -509,7 +509,7 @@ namespace mamba::validation
RoleKeys RolePubKeys::to_role_keys() const
{
return { pubkeys, threshold };
return {pubkeys, threshold};
}
RoleFullKeys::RoleFullKeys(const std::map<std::string, Key>& keys_, const std::size_t& threshold_)
@ -528,7 +528,7 @@ namespace mamba::validation
{
keyids.push_back(k.first);
}
return { keyids, threshold };
return {keyids, threshold};
}
void check_timestamp_metadata_format(const std::string& ts)
@ -576,11 +576,11 @@ namespace mamba::validation
if (spec_version_major == 0)
{
// Return the most recent possible upgrade first
return { "1", split_spec_version[0] + "." + std::to_string(spec_version_minor + 1) };
return {"1", split_spec_version[0] + "." + std::to_string(spec_version_minor + 1)};
}
else
{
return { std::to_string(spec_version_major + 1) };
return {std::to_string(spec_version_major + 1)};
}
}
@ -1058,16 +1058,15 @@ namespace mamba::validation
// upgrade first
for (auto& s : upgrade_spec)
{
files.push_back(
mamba::join(".", std::vector<std::string>({ new_v, "sv" + s, "root.json" }))
files.push_back(mamba::join(".", std::vector<std::string>({new_v, "sv" + s, "root.json"}))
);
}
// compatible next
files.push_back(
mamba::join(".", std::vector<std::string>({ new_v, "sv" + compat_spec, "root.json" }))
mamba::join(".", std::vector<std::string>({new_v, "sv" + compat_spec, "root.json"}))
);
// then finally undefined spec
files.push_back(mamba::join(".", std::vector<std::string>({ new_v, "root.json" })));
files.push_back(mamba::join(".", std::vector<std::string>({new_v, "root.json"})));
return files;
}
@ -1179,12 +1178,12 @@ namespace mamba::validation
std::set<std::string> RootImpl::mandatory_defined_roles() const
{
return { "root", "snapshot", "targets", "timestamp" };
return {"root", "snapshot", "targets", "timestamp"};
}
std::set<std::string> RootImpl::optionally_defined_roles() const
{
return { "mirrors" };
return {"mirrors"};
}
void
@ -1199,7 +1198,7 @@ namespace mamba::validation
{
try
{
role_keys.insert({ keyid, keys.at(keyid) });
role_keys.insert({keyid, keys.at(keyid)});
}
catch (const std::out_of_range&)
{
@ -1208,7 +1207,7 @@ namespace mamba::validation
throw role_metadata_error();
}
}
m_defined_roles.insert({ it.first, { role_keys, it.second.threshold } });
m_defined_roles.insert({it.first, {role_keys, it.second.threshold}});
}
}
@ -1293,7 +1292,7 @@ namespace mamba::validation
pgp_trailer = s.second["other_headers"];
}
unique_sigs.insert(RoleSignature({ s.first, s.second.at("signature"), pgp_trailer }));
unique_sigs.insert(RoleSignature({s.first, s.second.at("signature"), pgp_trailer}));
}
return unique_sigs;
@ -1375,8 +1374,8 @@ namespace mamba::validation
v1_equivalent_root["roles"]["root"] = m_defined_roles.at("root").to_roles();
v1_equivalent_root["roles"]["targets"] = m_defined_roles.at("key_mgr").to_roles();
v1_equivalent_root["roles"]["snapshot"] = RoleKeys({ std::vector<std::string>(), 1 });
v1_equivalent_root["roles"]["timestamp"] = RoleKeys({ std::vector<std::string>(), 1 });
v1_equivalent_root["roles"]["snapshot"] = RoleKeys({std::vector<std::string>(), 1});
v1_equivalent_root["roles"]["timestamp"] = RoleKeys({std::vector<std::string>(), 1});
std::map<std::string, Key> v1_keys = m_defined_roles.at("root").to_keys();
auto key_mgr_keys = m_defined_roles.at("key_mgr").to_keys();
@ -1398,7 +1397,7 @@ namespace mamba::validation
sign(j.dump(), sk, sig_bin.data());
auto sig_hex = ::mamba::hex_string(sig_bin);
return { pk, sig_hex };
return {pk, sig_hex};
}
RoleFullKeys RootImpl::self_keys() const
@ -1408,7 +1407,7 @@ namespace mamba::validation
std::set<std::string> RootImpl::mandatory_defined_roles() const
{
return { "root", "key_mgr" };
return {"root", "key_mgr"};
}
std::set<std::string> RootImpl::optionally_defined_roles() const
@ -1424,9 +1423,9 @@ namespace mamba::validation
std::map<std::string, Key> role_keys;
for (auto& key : it.second.pubkeys)
{
role_keys.insert({ key, Key::from_ed25519(key) });
role_keys.insert({key, Key::from_ed25519(key)});
}
m_defined_roles.insert({ it.first, { role_keys, it.second.threshold } });
m_defined_roles.insert({it.first, {role_keys, it.second.threshold}});
}
}
@ -1654,7 +1653,7 @@ namespace mamba::validation
std::set<std::string> KeyMgrRole::mandatory_defined_roles() const
{
return { "pkg_mgr" };
return {"pkg_mgr"};
}
std::set<std::string> KeyMgrRole::optionally_defined_roles() const
@ -1670,9 +1669,9 @@ namespace mamba::validation
std::map<std::string, Key> role_keys;
for (auto& key : it.second.pubkeys)
{
role_keys.insert({ key, Key::from_ed25519(key) });
role_keys.insert({key, Key::from_ed25519(key)});
}
m_defined_roles.insert({ it.first, { role_keys, it.second.threshold } });
m_defined_roles.insert({it.first, {role_keys, it.second.threshold}});
}
}
@ -1773,9 +1772,9 @@ namespace mamba::validation
std::map<std::string, Key> role_keys;
for (auto& key : it.second.pubkeys)
{
role_keys.insert({ key, Key::from_ed25519(key) });
role_keys.insert({key, Key::from_ed25519(key)});
}
m_defined_roles.insert({ it.first, { role_keys, it.second.threshold } });
m_defined_roles.insert({it.first, {role_keys, it.second.threshold}});
}
}
@ -1843,7 +1842,7 @@ namespace mamba::validation
pgp_trailer = s.second["other_headers"];
}
unique_sigs.insert(RoleSignature({ s.first, s.second.at("signature"), pgp_trailer }));
unique_sigs.insert(RoleSignature({s.first, s.second.at("signature"), pgp_trailer}));
}
return unique_sigs;
@ -1930,27 +1929,27 @@ namespace mamba::validation
void to_json(json& j, const Key& key)
{
j = json{ { "keytype", key.keytype }, { "scheme", key.scheme }, { "keyval", key.keyval } };
j = json{{"keytype", key.keytype}, {"scheme", key.scheme}, {"keyval", key.keyval}};
}
void to_json(json& j, const RoleKeys& role_keys)
{
j = json{ { "keyids", role_keys.keyids }, { "threshold", role_keys.threshold } };
j = json{{"keyids", role_keys.keyids}, {"threshold", role_keys.threshold}};
}
void to_json(json& j, const RolePubKeys& role_keys)
{
j = json{ { "pubkeys", role_keys.pubkeys }, { "threshold", role_keys.threshold } };
j = json{{"pubkeys", role_keys.pubkeys}, {"threshold", role_keys.threshold}};
}
void to_json(json& j, const RoleFullKeys& k)
{
j = json{ { "keys", k.keys }, { "threshold", k.threshold } };
j = json{{"keys", k.keys}, {"threshold", k.threshold}};
}
void to_json(json& j, const RoleSignature& role_sig)
{
j = json{ { "keyid", role_sig.keyid }, { "sig", role_sig.sig } };
j = json{{"keyid", role_sig.keyid}, {"sig", role_sig.sig}};
if (!role_sig.pgp_trailer.empty())
{
j["other_headers"] = role_sig.pgp_trailer;
@ -1959,7 +1958,7 @@ namespace mamba::validation
void to_json(json& j, const RoleBase* role)
{
j = json{ { "version", role->version() }, { "expires", role->expires() } };
j = json{{"version", role->version()}, {"expires", role->expires()}};
}
void from_json(const json& j, Key& key)

View File

@ -43,7 +43,7 @@ namespace mamba
const char* version = "";
#ifdef __linux__
std::vector<char> ver;
const size_t n = confstr(_CS_GNU_LIBC_VERSION, NULL, size_t{ 0 });
const size_t n = confstr(_CS_GNU_LIBC_VERSION, NULL, size_t{0});
if (n > 0)
{
@ -66,7 +66,7 @@ namespace mamba
}
std::string out, err;
std::vector<std::string> args = { "nvidia-smi", "--query", "-u", "-x" };
std::vector<std::string> args = {"nvidia-smi", "--query", "-u", "-x"};
auto [status, ec] = reproc::run(
args,
reproc::options{},
@ -105,7 +105,7 @@ namespace mamba
{
std::string f = (p.path() / "nvidia-smi.exe").string();
LOG_DEBUG << "Found nvidia-smi in: " << f;
std::vector<std::string> command = { f, "--query", "-u", "-x" };
std::vector<std::string> command = {f, "--query", "-u", "-x"};
auto [_ /*cmd_status*/, cmd_ec] = reproc::run(
command,
reproc::options{},

View File

@ -107,7 +107,7 @@ namespace mamba::solv
flag,
/* .create= */ 0
);
return (id == 0) ? std::nullopt : std::optional(DependencyId{ id });
return (id == 0) ? std::nullopt : std::optional(DependencyId{id});
}
auto ObjPool::add_dependency(StringId name_id, RelationFlag flag, StringId version_id)
@ -193,7 +193,7 @@ namespace mamba::solv
// No function exists to create a repo id
assert(raw()->repos[raw()->nrepos - 1] == repo_ptr);
assert(repo_ptr != nullptr);
return { raw()->nrepos - 1, ObjRepoView{ *repo_ptr } };
return {raw()->nrepos - 1, ObjRepoView{*repo_ptr}};
}
auto ObjPool::has_repo(RepoId id) const -> bool
@ -209,7 +209,7 @@ namespace mamba::solv
}
auto* repo_ptr = ::pool_id2repo(raw(), id);
assert(repo_ptr != nullptr);
return { ObjRepoView{ *repo_ptr } };
return {ObjRepoView{*repo_ptr}};
}
auto ObjPool::get_repo(RepoId id) const -> std::optional<ObjRepoViewConst>
@ -221,7 +221,7 @@ namespace mamba::solv
// Safe const_cast because we make the Repo deep const
const auto* repo_ptr = ::pool_id2repo(const_cast<::Pool*>(raw()), id);
assert(repo_ptr != nullptr);
return { ObjRepoViewConst{ *repo_ptr } };
return {ObjRepoViewConst{*repo_ptr}};
}
auto ObjPool::repo_count() const -> std::size_t
@ -245,7 +245,7 @@ namespace mamba::solv
{
if (const auto* const installed_ptr = raw()->installed)
{
return ObjRepoViewConst{ *installed_ptr };
return ObjRepoViewConst{*installed_ptr};
}
return std::nullopt;
}
@ -254,7 +254,7 @@ namespace mamba::solv
{
if (auto* const installed_ptr = raw()->installed)
{
return ObjRepoView{ *installed_ptr };
return ObjRepoView{*installed_ptr};
}
return std::nullopt;
}
@ -280,7 +280,7 @@ namespace mamba::solv
{
if (const ::Solvable* s = ::pool_id2solvable(raw(), id))
{
return ObjSolvableViewConst{ *s };
return ObjSolvableViewConst{*s};
}
}
return std::nullopt;
@ -292,7 +292,7 @@ namespace mamba::solv
{
if (::Solvable* s = ::pool_id2solvable(raw(), id))
{
return ObjSolvableView{ *s };
return ObjSolvableView{*s};
}
}
return std::nullopt;

View File

@ -212,7 +212,7 @@ namespace mamba::solv
auto ObjQueue::rbegin() -> reverse_iterator
{
return std::reverse_iterator{ end() };
return std::reverse_iterator{end()};
}
auto ObjQueue::rbegin() const -> const_reverse_iterator
@ -222,12 +222,12 @@ namespace mamba::solv
auto ObjQueue::crbegin() const -> const_reverse_iterator
{
return std::reverse_iterator{ end() };
return std::reverse_iterator{end()};
}
auto ObjQueue::rend() -> reverse_iterator
{
return std::reverse_iterator{ begin() };
return std::reverse_iterator{begin()};
}
auto ObjQueue::rend() const -> const_reverse_iterator
@ -237,7 +237,7 @@ namespace mamba::solv
auto ObjQueue::crend() const -> const_reverse_iterator
{
return std::reverse_iterator{ begin() };
return std::reverse_iterator{begin()};
}
auto ObjQueue::data() -> pointer

View File

@ -42,7 +42,7 @@ namespace mamba::solv
}
ObjRepoViewConst::ObjRepoViewConst(const ::Repo& repo) noexcept
: m_repo{ &repo }
: m_repo{&repo}
{
}
@ -94,7 +94,7 @@ namespace mamba::solv
{
if (const ::Solvable* s = get_solvable_ptr(raw(), id))
{
return { ObjSolvableViewConst{ *s } };
return {ObjSolvableViewConst{*s}};
}
return std::nullopt;
}
@ -133,8 +133,8 @@ namespace mamba::solv
};
CFile::CFile(std::FILE* ptr, std::string name)
: m_ptr{ ptr }
, m_name{ name }
: m_ptr{ptr}
, m_name{name}
{
}
@ -163,7 +163,7 @@ namespace mamba::solv
{
throw std::system_error(GetLastError(), std::generic_category());
}
return { ptr, path.string() };
return {ptr, path.string()};
#else
std::string name = path.string();
std::FILE* ptr = std::fopen(name.c_str(), mode);
@ -171,7 +171,7 @@ namespace mamba::solv
{
throw std::system_error(errno, std::generic_category());
}
return { ptr, std::move(name) };
return {ptr, std::move(name)};
#endif
}
@ -211,7 +211,7 @@ namespace mamba::solv
***********************************/
ObjRepoView::ObjRepoView(::Repo& repo) noexcept
: ObjRepoViewConst{ repo }
: ObjRepoViewConst{repo}
{
}
@ -273,7 +273,7 @@ namespace mamba::solv
{
if (::Solvable* s = get_solvable_ptr(raw(), id))
{
return { ObjSolvableView{ *s } };
return {ObjSolvableView{*s}};
}
return std::nullopt;
}
@ -311,7 +311,7 @@ namespace mamba::solv
{
return {};
}
return { ptr };
return {ptr};
}
// Can only read key/value on solvable, but the special SOLVID_META is used for a fake

View File

@ -308,7 +308,7 @@ namespace mamba::solv
const ::Solvable* s = nullptr;
FOR_REPO_SOLVABLES(repo, id, s)
{
auto solvable = ObjSolvableViewConst{ *s };
auto solvable = ObjSolvableViewConst{*s};
if constexpr (std::is_same_v<decltype(func(solvable)), LoopControl>)
{
if (func(solvable) == LoopControl::Break)
@ -331,7 +331,7 @@ namespace mamba::solv
::Solvable* s = nullptr;
FOR_REPO_SOLVABLES(repo, id, s)
{
auto solvable = ObjSolvableView{ *s };
auto solvable = ObjSolvableView{*s};
if constexpr (std::is_same_v<decltype(func(solvable)), LoopControl>)
{
if (func(solvable) == LoopControl::Break)

View File

@ -24,7 +24,7 @@ namespace mamba::solv
********************************************/
ObjSolvableViewConst::ObjSolvableViewConst(const ::Solvable& solvable) noexcept
: m_solvable{ &solvable }
: m_solvable{&solvable}
{
}
@ -48,7 +48,7 @@ namespace mamba::solv
***************************************/
ObjSolvableView::ObjSolvableView(::Solvable& solvable) noexcept
: ObjSolvableViewConst{ solvable }
: ObjSolvableViewConst{solvable}
{
}
@ -72,7 +72,7 @@ namespace mamba::solv
{
return {};
}
return { ptr };
return {ptr};
}
/**

View File

@ -220,9 +220,9 @@ namespace mamba::solv
const auto type = ::solver_ruleinfo(const_cast<::Solver*>(raw()), id, &from_id, &to_id, &dep_id);
return {
/* .from_id= */ (from_id != 0) ? std::optional{ from_id } : std::nullopt,
/* .to_id= */ (to_id != 0) ? std::optional{ to_id } : std::nullopt,
/* .dep_id= */ (dep_id != 0) ? std::optional{ dep_id } : std::nullopt,
/* .from_id= */ (from_id != 0) ? std::optional{from_id} : std::nullopt,
/* .to_id= */ (to_id != 0) ? std::optional{to_id} : std::nullopt,
/* .dep_id= */ (dep_id != 0) ? std::optional{dep_id} : std::nullopt,
/* .type= */ type,
/* .klass= */ ::solver_ruleclass(const_cast<::Solver*>(raw()), id),
};

View File

@ -44,11 +44,11 @@ namespace mamba::solv
auto ObjTransaction::from_solvables(const ObjPool& pool, const ObjQueue& solvables)
-> ObjTransaction
{
return ObjTransaction{ ::transaction_create_decisionq(
return ObjTransaction{::transaction_create_decisionq(
const_cast<::Pool*>(pool.raw()),
const_cast<::Queue*>(solvables.raw()),
nullptr
) };
)};
}
namespace
{
@ -61,8 +61,7 @@ namespace mamba::solv
auto ObjTransaction::from_solver(const ObjPool& pool, const ObjSolver& solver) -> ObjTransaction
{
auto trans = ObjTransaction{ ::solver_create_transaction(const_cast<::Solver*>(solver.raw())
) };
auto trans = ObjTransaction{::solver_create_transaction(const_cast<::Solver*>(solver.raw()))};
assert_same_pool(pool, trans);
return trans;
}
@ -110,7 +109,7 @@ namespace mamba::solv
{
if (auto id = ::transaction_obs_pkg(const_cast<::Transaction*>(raw()), step); id != 0)
{
return { id };
return {id};
}
}
return std::nullopt;

View File

@ -47,8 +47,8 @@ namespace mamba::specs
NLOHMANN_JSON_SERIALIZE_ENUM(
NoArchType,
{
{ NoArchType::Generic, "generic" },
{ NoArchType::Python, "python" },
{NoArchType::Generic, "generic"},
{NoArchType::Python, "python"},
}
)

View File

@ -55,20 +55,20 @@ namespace mamba::specs
***************************************/
VersionPartAtom::VersionPartAtom(std::size_t numeral) noexcept
: m_numeral{ numeral }
: m_numeral{numeral}
{
}
VersionPartAtom::VersionPartAtom(std::size_t numeral, std::string_view literal)
: m_literal{ to_lower(literal) }
, m_numeral{ numeral }
: m_literal{to_lower(literal)}
, m_numeral{numeral}
{
}
template <typename Char>
VersionPartAtom::VersionPartAtom(std::size_t numeral, std::basic_string<Char>&& literal)
: m_literal{ to_lower(std::move(literal)) }
, m_numeral{ numeral }
: m_literal{to_lower(std::move(literal))}
, m_numeral{numeral}
{
}
@ -146,7 +146,7 @@ namespace mamba::specs
{
// More efficient thatn three way comparison because of edge cases
auto attrs = [](const VersionPartAtom& a) -> std::tuple<std::size_t, const std::string&> {
return { a.numeral(), a.literal() };
return {a.numeral(), a.literal()};
};
return attrs(*this) == attrs(other);
}
@ -182,9 +182,9 @@ namespace mamba::specs
*******************************/
Version::Version(std::size_t epoch, CommonVersion&& version, CommonVersion&& local) noexcept
: m_version{ std::move(version) }
, m_local{ std::move(local) }
, m_epoch{ epoch }
: m_version{std::move(version)}
, m_local{std::move(local)}
, m_epoch{epoch}
{
}
@ -344,7 +344,7 @@ namespace mamba::specs
auto make_string_view(Iter first, Iter last) -> std::string_view
{
const auto size = util::safe_num_cast<std::size_t>(last - first);
return { first, size };
return {first, size};
}
template <typename Int>
@ -367,7 +367,7 @@ namespace mamba::specs
// No epoch is specified
if (delim_pos == std::string_view::npos) // TODO(C++20) [[likely]]
{
return { Int(0), str };
return {Int(0), str};
}
if (delim_pos == 0)
{
@ -386,7 +386,7 @@ namespace mamba::specs
);
}
// Found an epoch
return { maybe_int.value(), str.substr(delim_pos + 1) };
return {maybe_int.value(), str.substr(delim_pos + 1)};
}
template <typename Int>
@ -395,14 +395,14 @@ namespace mamba::specs
const auto [integer_str, rest] = lstrip_if_parts(str, [](char c) { return is_digit(c); });
auto maybe_integer = to_int<Int>(integer_str);
assert(maybe_integer.has_value());
return { maybe_integer.value(), rest };
return {maybe_integer.value(), rest};
}
auto parse_leading_literal(std::string_view str)
-> std::pair<std::string_view, std::string_view>
{
const auto [literal, rest] = lstrip_if_parts(str, [](char c) { return !is_digit(c); });
return { literal, rest };
return {literal, rest};
}
auto parse_leading_part_atom(std::string_view str)
@ -422,7 +422,7 @@ namespace mamba::specs
tail = str;
}
std::tie(literal, tail) = parse_leading_literal(tail);
return { { numeral, literal }, tail };
return {{numeral, literal}, tail};
}
auto parse_part(std::string_view str) -> VersionPart
@ -480,7 +480,7 @@ namespace mamba::specs
Version::part_delim_alt,
Version::part_delim_special,
};
static constexpr auto delims = std::string_view{ delims_buf.data(), delims_buf.size() };
static constexpr auto delims = std::string_view{delims_buf.data(), delims_buf.size()};
CommonVersion parts = {};
auto tail = str;
@ -518,7 +518,7 @@ namespace mamba::specs
// No local is specified
if (delim_pos == std::string_view::npos) // TODO(C++20) [[likely]]
{
return { str, {} };
return {str, {}};
}
// local specified but empty
if (delim_pos + 1 == str.size())
@ -527,7 +527,7 @@ namespace mamba::specs
fmt::format("Empty local version delimited by '{}'.", Version::local_delim)
);
}
return { str.substr(0, delim_pos), parse_common_version(str.substr(delim_pos + 1)) };
return {str.substr(0, delim_pos), parse_common_version(str.substr(delim_pos + 1))};
}
auto parse_version(std::string_view str) -> CommonVersion

View File

@ -16,6 +16,6 @@ namespace mamba
std::array<int, 3> version_arr()
{
return { LIBMAMBA_VERSION_MAJOR, LIBMAMBA_VERSION_MINOR, LIBMAMBA_VERSION_PATCH };
return {LIBMAMBA_VERSION_MAJOR, LIBMAMBA_VERSION_MINOR, LIBMAMBA_VERSION_PATCH};
}
}

View File

@ -86,7 +86,7 @@ namespace mamba
CHECK_EQ(c.name(), "conda-forge");
CHECK_EQ(c.canonical_name(), "conda-forge");
// CHECK_EQ(c.url(), "conda-forge");
CHECK_EQ(c.platforms(), std::vector<std::string>({ platform, "noarch" }));
CHECK_EQ(c.platforms(), std::vector<std::string>({platform, "noarch"}));
ctx.channel_alias = "https://conda.anaconda.org";
}
@ -97,13 +97,13 @@ namespace mamba
auto& ctx = Context::instance();
auto old_default_channels = ctx.default_channels;
ctx.channel_alias = "https://ali.as/";
ctx.default_channels = { "prefix" };
ctx.channels = { "prefix-and-more" };
ctx.default_channels = {"prefix"};
ctx.channels = {"prefix-and-more"};
ChannelContext channel_context;
auto base = std::string("https://ali.as/prefix-and-more/");
auto& chan = channel_context.make_channel(base);
std::vector<std::string> expected_urls = { base + platform, base + "noarch" };
std::vector<std::string> expected_urls = {base + platform, base + "noarch"};
CHECK_EQ(chan.urls(), expected_urls);
ctx.channel_alias = "https://conda.anaconda.org";
@ -118,8 +118,8 @@ namespace mamba
auto& ctx = Context::instance();
ctx.channel_alias = "https://mydomain.com/channels/";
ctx.custom_channels = {
{ "test_channel", "file:///tmp" },
{ "some_channel", "https://conda.mydomain.xyz/" },
{"test_channel", "file:///tmp"},
{"some_channel", "https://conda.mydomain.xyz/"},
};
ChannelContext channel_context;
@ -136,9 +136,11 @@ namespace mamba
CHECK_EQ(c.location(), "/tmp");
CHECK_EQ(c.name(), "test_channel");
CHECK_EQ(c.canonical_name(), "test_channel");
CHECK_EQ(c.platforms(), std::vector<std::string>({ platform, "noarch" }));
std::vector<std::string> exp_urls({ std::string("file:///tmp/test_channel/") + platform,
std::string("file:///tmp/test_channel/noarch") });
CHECK_EQ(c.platforms(), std::vector<std::string>({platform, "noarch"}));
std::vector<std::string> exp_urls(
{std::string("file:///tmp/test_channel/") + platform,
std::string("file:///tmp/test_channel/noarch")}
);
CHECK_EQ(c.urls(), exp_urls);
}
@ -149,10 +151,10 @@ namespace mamba
CHECK_EQ(c.location(), "conda.mydomain.xyz");
CHECK_EQ(c.name(), "some_channel");
CHECK_EQ(c.canonical_name(), "some_channel");
CHECK_EQ(c.platforms(), std::vector<std::string>({ platform, "noarch" }));
CHECK_EQ(c.platforms(), std::vector<std::string>({platform, "noarch"}));
std::vector<std::string> exp_urls(
{ std::string("https://conda.mydomain.xyz/some_channel/") + platform,
std::string("https://conda.mydomain.xyz/some_channel/noarch") }
{std::string("https://conda.mydomain.xyz/some_channel/") + platform,
std::string("https://conda.mydomain.xyz/some_channel/noarch")}
);
CHECK_EQ(c.urls(), exp_urls);
}
@ -169,34 +171,32 @@ namespace mamba
ctx.custom_multichannels["xtest"] = std::vector<std::string>{
"https://mydomain.com/conda-forge",
"https://mydomain.com/bioconda",
"https://mydomain.com/snakepit"
};
"https://mydomain.com/snakepit"};
ctx.custom_multichannels["ytest"] = std::vector<std::string>{
"https://otherdomain.com/conda-forge",
"https://otherdomain.com/bioconda",
"https://otherdomain.com/snakepit"
};
"https://otherdomain.com/snakepit"};
ChannelContext channel_context;
auto x = channel_context.get_channels({ "xtest" });
auto x = channel_context.get_channels({"xtest"});
CHECK_EQ(x.size(), 3);
auto* c1 = x[0];
std::vector<std::string> exp_urls(
{ std::string("https://mydomain.com/conda-forge/") + platform,
std::string("https://mydomain.com/conda-forge/noarch") }
{std::string("https://mydomain.com/conda-forge/") + platform,
std::string("https://mydomain.com/conda-forge/noarch")}
);
CHECK_EQ(c1->urls(), exp_urls);
std::vector<std::string> exp_urlsy3(
{ std::string("https://otherdomain.com/snakepit/") + platform,
std::string("https://otherdomain.com/snakepit/noarch") }
{std::string("https://otherdomain.com/snakepit/") + platform,
std::string("https://otherdomain.com/snakepit/noarch")}
);
auto y = channel_context.get_channels({ "ytest" });
auto y = channel_context.get_channels({"ytest"});
auto* y3 = y[2];
CHECK_EQ(y3->urls(), exp_urlsy3);
@ -218,12 +218,11 @@ namespace mamba
ctx.custom_multichannels["everything"] = std::vector<std::string>{
"conda-forge",
"https://mydomain.com/bioconda",
"xyz"
};
"xyz"};
ChannelContext channel_context;
auto x = channel_context.get_channels({ "everything" });
auto x = channel_context.get_channels({"everything"});
CHECK_EQ(x.size(), 3);
auto* c1 = x[0];
@ -231,22 +230,22 @@ namespace mamba
auto* c3 = x[2];
std::vector<std::string> exp_urls(
{ std::string("https://condaforge.org/channels/conda-forge/") + platform,
std::string("https://condaforge.org/channels/conda-forge/noarch") }
{std::string("https://condaforge.org/channels/conda-forge/") + platform,
std::string("https://condaforge.org/channels/conda-forge/noarch")}
);
CHECK_EQ(c1->urls(), exp_urls);
std::vector<std::string> exp_urls2(
{ std::string("https://mydomain.com/bioconda/") + platform,
std::string("https://mydomain.com/bioconda/noarch") }
{std::string("https://mydomain.com/bioconda/") + platform,
std::string("https://mydomain.com/bioconda/noarch")}
);
CHECK_EQ(c2->urls(), exp_urls2);
std::vector<std::string> exp_urls3(
{ std::string("https://mydomain.xyz/xyzchannel/xyz/") + platform,
std::string("https://mydomain.xyz/xyzchannel/xyz/noarch") }
{std::string("https://mydomain.xyz/xyzchannel/xyz/") + platform,
std::string("https://mydomain.xyz/xyzchannel/xyz/noarch")}
);
CHECK_EQ(c3->urls(), exp_urls3);
@ -261,22 +260,22 @@ namespace mamba
auto& ctx = Context::instance();
ChannelContext channel_context;
auto x = channel_context.get_channels({ "defaults" });
auto x = channel_context.get_channels({"defaults"});
#if !defined(_WIN32)
const Channel* c1 = x[0];
const Channel* c2 = x[1];
CHECK_EQ(c1->name(), "pkgs/main");
std::vector<std::string> exp_urls(
{ std::string("https://repo.anaconda.com/pkgs/main/") + platform,
std::string("https://repo.anaconda.com/pkgs/main/noarch") }
{std::string("https://repo.anaconda.com/pkgs/main/") + platform,
std::string("https://repo.anaconda.com/pkgs/main/noarch")}
);
CHECK_EQ(c1->urls(), exp_urls);
CHECK_EQ(c2->name(), "pkgs/r");
std::vector<std::string> exp_urls2(
{ std::string("https://repo.anaconda.com/pkgs/r/") + platform,
std::string("https://repo.anaconda.com/pkgs/r/noarch") }
{std::string("https://repo.anaconda.com/pkgs/r/") + platform,
std::string("https://repo.anaconda.com/pkgs/r/noarch")}
);
CHECK_EQ(c2->urls(), exp_urls2);
@ -290,23 +289,24 @@ namespace mamba
TEST_CASE("custom_default_channels")
{
auto& ctx = Context::instance();
ctx.default_channels = { "https://mamba.com/test/channel",
"https://mamba.com/stable/channel" };
ctx.default_channels = {
"https://mamba.com/test/channel",
"https://mamba.com/stable/channel"};
ChannelContext channel_context;
auto x = channel_context.get_channels({ "defaults" });
auto x = channel_context.get_channels({"defaults"});
const Channel* c1 = x[0];
const Channel* c2 = x[1];
CHECK_EQ(c1->name(), "test/channel");
std::vector<std::string> exp_urls(
{ std::string("https://mamba.com/test/channel/") + platform,
std::string("https://mamba.com/test/channel/noarch") }
{std::string("https://mamba.com/test/channel/") + platform,
std::string("https://mamba.com/test/channel/noarch")}
);
CHECK_EQ(c1->urls(), exp_urls);
std::vector<std::string> exp_urls2(
{ std::string("https://mamba.com/stable/channel/") + platform,
std::string("https://mamba.com/stable/channel/noarch") }
{std::string("https://mamba.com/stable/channel/") + platform,
std::string("https://mamba.com/stable/channel/noarch")}
);
CHECK_EQ(c2->urls(), exp_urls2);
@ -321,8 +321,8 @@ namespace mamba
{
auto& ctx = Context::instance();
ctx.custom_channels = {
{ "test_channel", "https://server.com/private/channels" },
{ "random/test_channel", "https://server.com/random/channels" },
{"test_channel", "https://server.com/private/channels"},
{"random/test_channel", "https://server.com/random/channels"},
};
ChannelContext channel_context;
@ -333,10 +333,10 @@ namespace mamba
CHECK_EQ(c.location(), "server.com/private/channels");
CHECK_EQ(c.name(), "test_channel");
CHECK_EQ(c.canonical_name(), "test_channel");
CHECK_EQ(c.platforms(), std::vector<std::string>({ platform, "noarch" }));
CHECK_EQ(c.platforms(), std::vector<std::string>({platform, "noarch"}));
std::vector<std::string> exp_urls(
{ std::string("https://server.com/private/channels/test_channel/") + platform,
std::string("https://server.com/private/channels/test_channel/noarch") }
{std::string("https://server.com/private/channels/test_channel/") + platform,
std::string("https://server.com/private/channels/test_channel/noarch")}
);
CHECK_EQ(c.urls(), exp_urls);
}
@ -348,12 +348,11 @@ namespace mamba
CHECK_EQ(c.location(), "server.com/private/channels");
CHECK_EQ(c.name(), "test_channel/mylabel/xyz");
CHECK_EQ(c.canonical_name(), "test_channel/mylabel/xyz");
CHECK_EQ(c.platforms(), std::vector<std::string>({ platform, "noarch" }));
CHECK_EQ(c.platforms(), std::vector<std::string>({platform, "noarch"}));
std::vector<std::string> exp_urls(
{ std::string("https://server.com/private/channels/test_channel/mylabel/xyz/")
+ platform,
std::string("https://server.com/private/channels/test_channel/mylabel/xyz/noarch"
) }
{std::string("https://server.com/private/channels/test_channel/mylabel/xyz/")
+ platform,
std::string("https://server.com/private/channels/test_channel/mylabel/xyz/noarch")}
);
CHECK_EQ(c.urls(), exp_urls);
}
@ -365,11 +364,11 @@ namespace mamba
CHECK_EQ(c.location(), "server.com/random/channels");
CHECK_EQ(c.name(), "random/test_channel/pkg");
CHECK_EQ(c.canonical_name(), "random/test_channel/pkg");
CHECK_EQ(c.platforms(), std::vector<std::string>({ platform, "noarch" }));
CHECK_EQ(c.platforms(), std::vector<std::string>({platform, "noarch"}));
std::vector<std::string> exp_urls(
{ std::string("https://server.com/random/channels/random/test_channel/pkg/")
+ platform,
std::string("https://server.com/random/channels/random/test_channel/pkg/noarch") }
{std::string("https://server.com/random/channels/random/test_channel/pkg/")
+ platform,
std::string("https://server.com/random/channels/random/test_channel/pkg/noarch")}
);
CHECK_EQ(c.urls(), exp_urls);
}
@ -390,7 +389,7 @@ namespace mamba
CHECK_EQ(c.location(), "repo.mamba.pm");
CHECK_EQ(c.name(), "conda-forge");
CHECK_EQ(c.canonical_name(), "https://repo.mamba.pm/conda-forge");
CHECK_EQ(c.platforms(), std::vector<std::string>({ platform, "noarch" }));
CHECK_EQ(c.platforms(), std::vector<std::string>({platform, "noarch"}));
}
TEST_CASE("make_channel")
@ -402,7 +401,7 @@ namespace mamba
CHECK_EQ(c.location(), "conda.anaconda.org");
CHECK_EQ(c.name(), "conda-forge");
CHECK_EQ(c.canonical_name(), "conda-forge");
CHECK_EQ(c.platforms(), std::vector<std::string>({ platform, "noarch" }));
CHECK_EQ(c.platforms(), std::vector<std::string>({platform, "noarch"}));
std::string value2 = "https://repo.anaconda.com/pkgs/main[" + platform + "]";
const Channel& c2 = channel_context.make_channel(value2);
@ -410,7 +409,7 @@ namespace mamba
CHECK_EQ(c2.location(), "repo.anaconda.com");
CHECK_EQ(c2.name(), "pkgs/main");
CHECK_EQ(c2.canonical_name(), "https://repo.anaconda.com/pkgs/main");
CHECK_EQ(c2.platforms(), std::vector<std::string>({ platform }));
CHECK_EQ(c2.platforms(), std::vector<std::string>({platform}));
std::string value3 = "https://conda.anaconda.org/conda-forge[" + platform + "]";
const Channel& c3 = channel_context.make_channel(value3);
@ -418,7 +417,7 @@ namespace mamba
CHECK_EQ(c3.location(), c.location());
CHECK_EQ(c3.name(), c.name());
CHECK_EQ(c3.canonical_name(), c.canonical_name());
CHECK_EQ(c3.platforms(), std::vector<std::string>({ platform }));
CHECK_EQ(c3.platforms(), std::vector<std::string>({platform}));
std::string value4 = "/home/mamba/test/channel_b";
const Channel& c4 = channel_context.make_channel(value4);
@ -432,7 +431,7 @@ namespace mamba
CHECK_EQ(c4.canonical_name(), "file:///home/mamba/test/channel_b");
#endif
CHECK_EQ(c4.name(), "channel_b");
CHECK_EQ(c4.platforms(), std::vector<std::string>({ platform, "noarch" }));
CHECK_EQ(c4.platforms(), std::vector<std::string>({platform, "noarch"}));
std::string value5 = "/home/mamba/test/channel_b[" + platform + "]";
const Channel& c5 = channel_context.make_channel(value5);
@ -445,25 +444,25 @@ namespace mamba
CHECK_EQ(c5.canonical_name(), "file:///home/mamba/test/channel_b");
#endif
CHECK_EQ(c5.name(), "channel_b");
CHECK_EQ(c5.platforms(), std::vector<std::string>({ platform }));
CHECK_EQ(c5.platforms(), std::vector<std::string>({platform}));
std::string value6a = "http://localhost:8000/conda-forge[noarch]";
const Channel& c6a = channel_context.make_channel(value6a);
CHECK_EQ(
c6a.urls(false),
std::vector<std::string>({ "http://localhost:8000/conda-forge/noarch" })
std::vector<std::string>({"http://localhost:8000/conda-forge/noarch"})
);
std::string value6b = "http://localhost:8000/conda_mirror/conda-forge[noarch]";
const Channel& c6b = channel_context.make_channel(value6b);
CHECK_EQ(
c6b.urls(false),
std::vector<std::string>({ "http://localhost:8000/conda_mirror/conda-forge/noarch" })
std::vector<std::string>({"http://localhost:8000/conda_mirror/conda-forge/noarch"})
);
std::string value7 = "conda-forge[noarch,arbitrary]";
const Channel& c7 = channel_context.make_channel(value7);
CHECK_EQ(c7.platforms(), std::vector<std::string>({ "noarch", "arbitrary" }));
CHECK_EQ(c7.platforms(), std::vector<std::string>({"noarch", "arbitrary"}));
}
TEST_CASE("urls")
@ -473,16 +472,20 @@ namespace mamba
const Channel& c = channel_context.make_channel(value);
CHECK_EQ(
c.urls(),
std::vector<std::string>({ "https://conda.anaconda.org/conda-forge/noarch",
"https://conda.anaconda.org/conda-forge/win-64",
"https://conda.anaconda.org/conda-forge/arbitrary" })
std::vector<std::string>(
{"https://conda.anaconda.org/conda-forge/noarch",
"https://conda.anaconda.org/conda-forge/win-64",
"https://conda.anaconda.org/conda-forge/arbitrary"}
)
);
const Channel& c1 = channel_context.make_channel("https://conda.anaconda.org/conda-forge");
CHECK_EQ(
c1.urls(),
std::vector<std::string>({ "https://conda.anaconda.org/conda-forge/" + platform,
"https://conda.anaconda.org/conda-forge/noarch" })
std::vector<std::string>(
{"https://conda.anaconda.org/conda-forge/" + platform,
"https://conda.anaconda.org/conda-forge/noarch"}
)
);
}
@ -491,8 +494,7 @@ namespace mamba
auto& ctx = Context::instance();
ctx.authentication_info()["conda.anaconda.org"] = AuthenticationInfo{
AuthenticationType::kCondaToken,
"my-12345-token"
};
"my-12345-token"};
ChannelContext channel_context;
@ -501,11 +503,11 @@ namespace mamba
CHECK_EQ(
chan.urls(true),
std::vector<std::string>{
{ "https://conda.anaconda.org/t/my-12345-token/conda-forge/noarch" } }
{"https://conda.anaconda.org/t/my-12345-token/conda-forge/noarch"}}
);
CHECK_EQ(
chan.urls(false),
std::vector<std::string>{ { "https://conda.anaconda.org/conda-forge/noarch" } }
std::vector<std::string>{{"https://conda.anaconda.org/conda-forge/noarch"}}
);
}
@ -514,12 +516,10 @@ namespace mamba
auto& ctx = Context::instance();
ctx.authentication_info()["conda.anaconda.org"] = AuthenticationInfo{
AuthenticationType::kCondaToken,
"base-token"
};
"base-token"};
ctx.authentication_info()["conda.anaconda.org/conda-forge"] = AuthenticationInfo{
AuthenticationType::kCondaToken,
"channel-token"
};
"channel-token"};
ChannelContext channel_context;
@ -535,8 +535,9 @@ namespace mamba
const Channel& c = channel_context.make_channel("C:\\test\\channel");
CHECK_EQ(
c.urls(false),
std::vector<std::string>({ "file:///C:/test/channel/win-64",
"file:///C:/test/channel/noarch" })
std::vector<std::string>(
{"file:///C:/test/channel/win-64", "file:///C:/test/channel/noarch"}
)
);
}
else
@ -544,8 +545,9 @@ namespace mamba
const Channel& c = channel_context.make_channel("/test/channel");
CHECK_EQ(
c.urls(false),
std::vector<std::string>({ std::string("file:///test/channel/") + platform,
"file:///test/channel/noarch" })
std::vector<std::string>(
{std::string("file:///test/channel/") + platform, "file:///test/channel/noarch"}
)
);
}
}
@ -556,8 +558,9 @@ namespace mamba
const Channel& c = channel_context.make_channel("http://localhost:8000/");
CHECK_EQ(c.platform_url("win-64", false), "http://localhost:8000/win-64");
CHECK_EQ(c.base_url(), "http://localhost:8000");
std::vector<std::string> expected_urls({ std::string("http://localhost:8000/") + platform,
"http://localhost:8000/noarch" });
std::vector<std::string> expected_urls(
{std::string("http://localhost:8000/") + platform, "http://localhost:8000/noarch"}
);
CHECK_EQ(c.urls(true), expected_urls);
const Channel& c4 = channel_context.make_channel("http://localhost:8000");
CHECK_EQ(c4.platform_url("linux-64", false), "http://localhost:8000/linux-64");
@ -574,9 +577,9 @@ namespace mamba
);
std::vector<std::string> expected_urls2(
{ std::string("https://localhost:8000/t/xy-12345678-1234-1234-1234-123456789012/")
+ platform,
"https://localhost:8000/t/xy-12345678-1234-1234-1234-123456789012/noarch" }
{std::string("https://localhost:8000/t/xy-12345678-1234-1234-1234-123456789012/")
+ platform,
"https://localhost:8000/t/xy-12345678-1234-1234-1234-123456789012/noarch"}
);
CHECK_EQ(c3.urls(true), expected_urls2);

View File

@ -60,7 +60,7 @@ namespace mamba
out_file.close();
config.reset_configurables();
config.at("rc_files").set_value<std::vector<fs::u8path>>({ unique_location });
config.at("rc_files").set_value<std::vector<fs::u8path>>({unique_location});
config.load();
}
@ -169,7 +169,7 @@ namespace mamba
- test2
- test1)");
std::vector<std::string> rcs = { rc1, rc2 };
std::vector<std::string> rcs = {rc1, rc2};
load_test_config(rcs);
REQUIRE_EQ(config.sources().size(), 2);
@ -286,7 +286,7 @@ namespace mamba
- test10
override_channels_enabled: false)");
load_test_config({ rc1, rc2 });
load_test_config({rc1, rc2});
REQUIRE_EQ(config.sources().size(), 2);
REQUIRE_EQ(config.valid_sources().size(), 2);
@ -337,7 +337,7 @@ namespace mamba
- c11
- c32
- c21)");
load_test_config({ rc1, rc2, rc3 });
load_test_config({rc1, rc2, rc3});
CHECK_EQ(config.dump(), unindent(R"(
channels:
@ -408,7 +408,7 @@ namespace mamba
- c11
- c32
- c21)");
load_test_config({ rc1, rc2, rc3 });
load_test_config({rc1, rc2, rc3});
CHECK_EQ(config.dump(), unindent(R"(
default_channels:
@ -474,10 +474,10 @@ namespace mamba
std::string rc1 = "channel_alias: http://repo.mamba.pm/";
std::string rc2 = "channel_alias: https://conda.anaconda.org/";
load_test_config({ rc1, rc2 });
load_test_config({rc1, rc2});
CHECK_EQ(config.dump(), "channel_alias: http://repo.mamba.pm/");
load_test_config({ rc2, rc1 });
load_test_config({rc2, rc1});
CHECK_EQ(config.dump(), "channel_alias: https://conda.anaconda.org/");
env::set("MAMBA_CHANNEL_ALIAS", "https://foo.bar");
@ -512,10 +512,10 @@ namespace mamba
std::string rc1 = "pkgs_dirs:\n - " + cache1;
std::string rc2 = "pkgs_dirs:\n - " + cache2;
load_test_config({ rc1, rc2 });
load_test_config({rc1, rc2});
CHECK_EQ(config.dump(), "pkgs_dirs:\n - " + cache1 + "\n - " + cache2);
load_test_config({ rc2, rc1 });
load_test_config({rc2, rc1});
CHECK_EQ(config.dump(), "pkgs_dirs:\n - " + cache2 + "\n - " + cache1);
std::string cache3 = (env::home_directory() / "baz").string();
@ -557,7 +557,7 @@ namespace mamba
CHECK_EQ(
config.dump(
MAMBA_SHOW_CONFIG_VALUES | MAMBA_SHOW_CONFIG_SRCS | MAMBA_SHOW_ALL_CONFIGS,
{ "pkgs_dirs" }
{"pkgs_dirs"}
),
unindent((R"(
pkgs_dirs:
@ -629,11 +629,11 @@ namespace mamba
std::string rc1 = "ssl_verify: true";
std::string rc2 = "ssl_verify: false";
load_test_config({ rc1, rc2 });
load_test_config({rc1, rc2});
CHECK_EQ(config.at("ssl_verify").value<std::string>(), "<system>");
CHECK_EQ(ctx.remote_fetch_params.ssl_verify, "<system>");
load_test_config({ rc2, rc1 });
load_test_config({rc2, rc1});
CHECK_EQ(config.at("ssl_verify").value<std::string>(), "<false>");
CHECK_EQ(ctx.remote_fetch_params.ssl_verify, "<false>");
@ -721,8 +721,7 @@ namespace mamba
https: bar)");
load_test_config(rc);
auto& actual = config.at("proxy_servers").value<std::map<std::string, std::string>>();
std::map<std::string, std::string> expected = { { "http", "foo" },
{ "https", "bar" } };
std::map<std::string, std::string> expected = {{"http", "foo"}, {"https", "bar"}};
CHECK_EQ(actual, expected);
CHECK_EQ(ctx.proxy_servers, expected);
@ -772,11 +771,11 @@ namespace mamba
std::string rc2 = std::string(#NAME) + ": false"; \
if (config.at(#NAME).rc_configurable()) \
{ \
load_test_config({ rc1, rc2 }); \
load_test_config({rc1, rc2}); \
CHECK(config.at(#NAME).value<bool>()); \
CHECK(CTX); \
\
load_test_config({ rc2, rc1 }); \
load_test_config({rc2, rc1}); \
CHECK_FALSE(config.at(#NAME).value<bool>()); \
CHECK_FALSE(CTX); \
} \
@ -799,7 +798,7 @@ namespace mamba
expected = std::string(#NAME) + ": true # '" + env_name + "'"; \
} \
int dump_opts = MAMBA_SHOW_CONFIG_VALUES | MAMBA_SHOW_CONFIG_SRCS; \
CHECK_EQ((config.dump(dump_opts, { #NAME })), expected); \
CHECK_EQ((config.dump(dump_opts, {#NAME})), expected); \
CHECK(config.at(#NAME).value<bool>()); \
CHECK(CTX); \
\
@ -812,7 +811,7 @@ namespace mamba
expected = std::string(#NAME) + ": true # 'API' > '" + env_name + "'"; \
} \
config.at(#NAME).set_yaml_value("true").compute(); \
CHECK_EQ((config.dump(dump_opts, { #NAME })), expected); \
CHECK_EQ((config.dump(dump_opts, {#NAME})), expected); \
CHECK(config.at(#NAME).value<bool>()); \
CHECK(CTX); \
\
@ -835,21 +834,21 @@ namespace mamba
std::string rc2 = "channel_priority: strict";
std::string rc3 = "channel_priority: disabled";
load_test_config({ rc1, rc2, rc3 });
load_test_config({rc1, rc2, rc3});
CHECK_EQ(
config.at("channel_priority").value<ChannelPriority>(),
ChannelPriority::kFlexible
);
CHECK(ctx.channel_priority == ChannelPriority::kFlexible);
load_test_config({ rc3, rc1, rc2 });
load_test_config({rc3, rc1, rc2});
CHECK_EQ(
config.at("channel_priority").value<ChannelPriority>(),
ChannelPriority::kDisabled
);
CHECK(ctx.channel_priority == ChannelPriority::kDisabled);
load_test_config({ rc2, rc1, rc3 });
load_test_config({rc2, rc1, rc3});
CHECK_EQ(
config.at("channel_priority").value<ChannelPriority>(),
ChannelPriority::kStrict
@ -906,7 +905,7 @@ namespace mamba
- bokeh
- matplotlib)");
load_test_config({ rc1, rc2, rc3 });
load_test_config({rc1, rc2, rc3});
CHECK_EQ(config.dump(), unindent(R"(
pinned_packages:
- jupyterlab=3
@ -915,10 +914,10 @@ namespace mamba
- bokeh)"));
CHECK_EQ(
ctx.pinned_packages,
std::vector<std::string>({ "jupyterlab=3", "numpy=1.19", "matplotlib", "bokeh" })
std::vector<std::string>({"jupyterlab=3", "numpy=1.19", "matplotlib", "bokeh"})
);
load_test_config({ rc2, rc1, rc3 });
load_test_config({rc2, rc1, rc3});
REQUIRE(config.at("pinned_packages").yaml_value());
CHECK_EQ(config.dump(), unindent(R"(
pinned_packages:
@ -928,7 +927,7 @@ namespace mamba
- bokeh)"));
CHECK_EQ(
ctx.pinned_packages,
std::vector<std::string>({ "matplotlib", "numpy=1.19", "jupyterlab=3", "bokeh" })
std::vector<std::string>({"matplotlib", "numpy=1.19", "jupyterlab=3", "bokeh"})
);
env::set("MAMBA_PINNED_PACKAGES", "mpl=10.2,xtensor");
@ -951,7 +950,7 @@ namespace mamba
);
CHECK_EQ(
ctx.pinned_packages,
std::vector<std::string>({ "mpl=10.2", "xtensor", "jupyterlab=3", "numpy=1.19" })
std::vector<std::string>({"mpl=10.2", "xtensor", "jupyterlab=3", "numpy=1.19"})
);
config.at("pinned_packages").set_yaml_value("pytest").compute();
@ -971,7 +970,7 @@ namespace mamba
CHECK_EQ(
ctx.pinned_packages,
std::vector<std::string>(
{ "pytest", "mpl=10.2", "xtensor", "jupyterlab=3", "numpy=1.19" }
{"pytest", "mpl=10.2", "xtensor", "jupyterlab=3", "numpy=1.19"}
)
);
@ -1008,18 +1007,18 @@ namespace mamba
std::string rc2 = "safety_checks: warn";
std::string rc3 = "safety_checks: disabled";
load_test_config({ rc1, rc2, rc3 });
load_test_config({rc1, rc2, rc3});
CHECK_EQ(
config.at("safety_checks").value<VerificationLevel>(),
VerificationLevel::kEnabled
);
CHECK_EQ(ctx.safety_checks, VerificationLevel::kEnabled);
load_test_config({ rc2, rc1, rc3 });
load_test_config({rc2, rc1, rc3});
CHECK_EQ(config.at("safety_checks").value<VerificationLevel>(), VerificationLevel::kWarn);
CHECK_EQ(ctx.safety_checks, VerificationLevel::kWarn);
load_test_config({ rc3, rc1, rc3 });
load_test_config({rc3, rc1, rc3});
CHECK_EQ(
config.at("safety_checks").value<VerificationLevel>(),
VerificationLevel::kDisabled

View File

@ -309,18 +309,25 @@ namespace mamba
{
using param_type = std::tuple<std::string, char, bool>;
std::vector<param_type> param_values = {
std::make_tuple("y", 'y', true), std::make_tuple("yes", 'y', true),
std::make_tuple("Y", 'y', true), std::make_tuple("Yes", 'y', true),
std::make_tuple("", 'y', true), std::make_tuple("n", 'y', false),
std::make_tuple("no", 'y', false), std::make_tuple("N", 'y', false),
std::make_tuple("y", 'y', true),
std::make_tuple("yes", 'y', true),
std::make_tuple("Y", 'y', true),
std::make_tuple("Yes", 'y', true),
std::make_tuple("", 'y', true),
std::make_tuple("n", 'y', false),
std::make_tuple("no", 'y', false),
std::make_tuple("N", 'y', false),
std::make_tuple("No", 'y', false),
std::make_tuple("y", 'n', true), std::make_tuple("yes", 'n', true),
std::make_tuple("Y", 'n', true), std::make_tuple("Yes", 'n', true),
std::make_tuple("", 'n', false), std::make_tuple("n", 'n', false),
std::make_tuple("no", 'n', false), std::make_tuple("N", 'n', false),
std::make_tuple("No", 'n', false)
};
std::make_tuple("y", 'n', true),
std::make_tuple("yes", 'n', true),
std::make_tuple("Y", 'n', true),
std::make_tuple("Yes", 'n', true),
std::make_tuple("", 'n', false),
std::make_tuple("n", 'n', false),
std::make_tuple("no", 'n', false),
std::make_tuple("N", 'n', false),
std::make_tuple("No", 'n', false)};
for (const auto& p : param_values)
{
@ -343,7 +350,7 @@ namespace mamba
{
auto& ctx = Context::instance();
ctx.prefix_params.root_prefix = "/home/user/micromamba/";
ctx.envs_dirs = { ctx.prefix_params.root_prefix / "envs" };
ctx.envs_dirs = {ctx.prefix_params.root_prefix / "envs"};
fs::u8path prefix = "/home/user/micromamba/envs/testprefix";
CHECK_EQ(env_name(prefix), "testprefix");
@ -500,35 +507,35 @@ namespace mamba
{
if (!on_win)
{
std::vector<std::string> args1 = { "python", "-c", "print('is\ngreat')" };
std::vector<std::string> args1 = {"python", "-c", "print('is\ngreat')"};
CHECK_EQ(quote_for_shell(args1), "python -c 'print('\"'\"'is\ngreat'\"'\"')'");
std::vector<std::string> args2 = { "python", "-c", "print(\"is great\")" };
std::vector<std::string> args2 = {"python", "-c", "print(\"is great\")"};
CHECK_EQ(quote_for_shell(args2), "python -c 'print(\"is great\")'");
std::vector<std::string> args3 = { "python", "very nice", "print(\"is great\")" };
std::vector<std::string> args3 = {"python", "very nice", "print(\"is great\")"};
CHECK_EQ(quote_for_shell(args3), "python 'very nice' 'print(\"is great\")'");
std::vector<std::string> args4 = { "pyt \t tab", "very nice", "print(\"is great\")" };
std::vector<std::string> args4 = {"pyt \t tab", "very nice", "print(\"is great\")"};
CHECK_EQ(quote_for_shell(args4), "'pyt \t tab' 'very nice' 'print(\"is great\")'");
std::vector<std::string> args5 = { "echo", "(" };
std::vector<std::string> args5 = {"echo", "("};
CHECK_EQ(quote_for_shell(args5), "echo '('");
std::vector<std::string> args6 = { "echo", "foo'bar\nspam" };
std::vector<std::string> args6 = {"echo", "foo'bar\nspam"};
CHECK_EQ(quote_for_shell(args6), "echo 'foo'\"'\"'bar\nspam'");
}
std::vector<std::string> args1 = { "a b c", "d", "e" };
std::vector<std::string> args1 = {"a b c", "d", "e"};
CHECK_EQ(quote_for_shell(args1, "cmdexe"), "\"a b c\" d e");
std::vector<std::string> args2 = { "ab\"c", "\\", "d" };
std::vector<std::string> args2 = {"ab\"c", "\\", "d"};
CHECK_EQ(quote_for_shell(args2, "cmdexe"), "ab\\\"c \\ d");
std::vector<std::string> args3 = { "ab\"c", " \\", "d" };
std::vector<std::string> args3 = {"ab\"c", " \\", "d"};
CHECK_EQ(quote_for_shell(args3, "cmdexe"), "ab\\\"c \" \\\\\" d");
std::vector<std::string> args4 = { "a\\\\\\b", "de fg", "h" };
std::vector<std::string> args4 = {"a\\\\\\b", "de fg", "h"};
CHECK_EQ(quote_for_shell(args4, "cmdexe"), "a\\\\\\b \"de fg\" h");
std::vector<std::string> args5 = { "a\\\"b", "c", "d" };
std::vector<std::string> args5 = {"a\\\"b", "c", "d"};
CHECK_EQ(quote_for_shell(args5, "cmdexe"), "a\\\\\\\"b c d");
std::vector<std::string> args6 = { "a\\\\b c", "d", "e" };
std::vector<std::string> args6 = {"a\\\\b c", "d", "e"};
CHECK_EQ(quote_for_shell(args6, "cmdexe"), "\"a\\\\b c\" d e");
std::vector<std::string> args7 = { "a\\\\b\\ c", "d", "e" };
std::vector<std::string> args7 = {"a\\\\b\\ c", "d", "e"};
CHECK_EQ(quote_for_shell(args7, "cmdexe"), "\"a\\\\b\\ c\" d e");
std::vector<std::string> args8 = { "ab", "" };
std::vector<std::string> args8 = {"ab", ""};
CHECK_EQ(quote_for_shell(args8, "cmdexe"), "ab \"\"");
}
@ -587,7 +594,7 @@ namespace mamba
{
TEST_CASE("parse_mod_etag")
{
fs::u8path cache_folder = fs::u8path{ test_data_dir / "repodata_json_cache" };
fs::u8path cache_folder = fs::u8path{test_data_dir / "repodata_json_cache"};
auto mq = detail::read_metadata(cache_folder / "test_1.json");
CHECK(mq.has_value());
auto j = mq.value();

View File

@ -47,19 +47,19 @@ namespace mamba
using V = std::vector<std::string>;
auto res = detail::read_yaml_file(test_data_dir / "env_file/env_1.yaml");
CHECK_EQ(res.name, "env_1");
CHECK_EQ(res.channels, V({ "conda-forge", "bioconda" }));
CHECK_EQ(res.dependencies, V({ "test1", "test2", "test3" }));
CHECK_EQ(res.channels, V({"conda-forge", "bioconda"}));
CHECK_EQ(res.dependencies, V({"test1", "test2", "test3"}));
CHECK_FALSE(res.others_pkg_mgrs_specs.size());
auto res2 = detail::read_yaml_file(test_data_dir / "env_file/env_2.yaml");
CHECK_EQ(res2.name, "env_2");
CHECK_EQ(res2.channels, V({ "conda-forge", "bioconda" }));
CHECK_EQ(res2.channels, V({"conda-forge", "bioconda"}));
#ifdef __linux__
CHECK_EQ(res2.dependencies, V({ "test1-unix", "test1-linux", "test2-linux", "test4" }));
CHECK_EQ(res2.dependencies, V({"test1-unix", "test1-linux", "test2-linux", "test4"}));
#elif __APPLE__
CHECK_EQ(res2.dependencies, V({ "test1-unix", "test1-osx", "test4" }));
CHECK_EQ(res2.dependencies, V({"test1-unix", "test1-osx", "test4"}));
#elif _WIN32
CHECK_EQ(res2.dependencies, V({ "test1-win", "test4" }));
CHECK_EQ(res2.dependencies, V({"test1-win", "test4"}));
#endif
CHECK_FALSE(res2.others_pkg_mgrs_specs.size());
}
@ -69,13 +69,13 @@ namespace mamba
using V = std::vector<std::string>;
auto res = detail::read_yaml_file(test_data_dir / "env_file/env_3.yaml");
CHECK_EQ(res.name, "env_3");
CHECK_EQ(res.channels, V({ "conda-forge", "bioconda" }));
CHECK_EQ(res.dependencies, V({ "test1", "test2", "test3", "pip" }));
CHECK_EQ(res.channels, V({"conda-forge", "bioconda"}));
CHECK_EQ(res.dependencies, V({"test1", "test2", "test3", "pip"}));
CHECK_EQ(res.others_pkg_mgrs_specs.size(), 1);
auto o = res.others_pkg_mgrs_specs[0];
CHECK_EQ(o.pkg_mgr, "pip");
CHECK_EQ(o.deps, V({ "pytest", "numpy" }));
CHECK_EQ(o.deps, V({"pytest", "numpy"}));
CHECK_EQ(o.cwd, fs::absolute(test_data_dir / "env_file"));
}
}

View File

@ -32,7 +32,7 @@ namespace mamba
const auto& error_details = EnvLockFileError::get_details(error);
CHECK_EQ(file_parsing_error_code::parsing_failure, error_details.parsing_error_code);
REQUIRE(error_details.yaml_error_type);
const std::type_index bad_file_error_id{ typeid(YAML::BadFile) };
const std::type_index bad_file_error_id{typeid(YAML::BadFile)};
CHECK_EQ(bad_file_error_id, error_details.yaml_error_type.value());
// NOTE: one could attempt to check if opening a file which is not an YAML file
@ -44,8 +44,8 @@ namespace mamba
TEST_CASE("invalid_version_fails")
{
ChannelContext channel_context;
const fs::u8path invalid_version_lockfile_path{ test_data_dir
/ "env_lockfile/bad_version-lock.yaml" };
const fs::u8path invalid_version_lockfile_path{
test_data_dir / "env_lockfile/bad_version-lock.yaml"};
const auto maybe_lockfile = read_environment_lockfile(
channel_context,
invalid_version_lockfile_path
@ -60,7 +60,7 @@ namespace mamba
TEST_CASE("valid_no_package_succeed")
{
ChannelContext channel_context;
const fs::u8path lockfile_path{ test_data_dir / "env_lockfile/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(channel_context, lockfile_path);
REQUIRE_MESSAGE(maybe_lockfile, maybe_lockfile.error().what());
const auto lockfile = maybe_lockfile.value();
@ -70,7 +70,7 @@ namespace mamba
TEST_CASE("invalid_package_fails")
{
ChannelContext channel_context;
const fs::u8path lockfile_path{ test_data_dir / "env_lockfile/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(channel_context, lockfile_path);
REQUIRE_FALSE(maybe_lockfile);
const auto error = maybe_lockfile.error();
@ -82,8 +82,7 @@ namespace mamba
TEST_CASE("valid_one_package_succeed")
{
ChannelContext channel_context;
const fs::u8path lockfile_path{ test_data_dir
/ "env_lockfile/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(channel_context, lockfile_path);
REQUIRE_MESSAGE(maybe_lockfile, maybe_lockfile.error().what());
const auto lockfile = maybe_lockfile.value();
@ -94,8 +93,7 @@ namespace mamba
{
ChannelContext channel_context;
const fs::u8path lockfile_path{
test_data_dir / "env_lockfile/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(channel_context, lockfile_path);
REQUIRE_MESSAGE(maybe_lockfile, maybe_lockfile.error().what());
const auto lockfile = maybe_lockfile.value();
@ -105,8 +103,8 @@ namespace mamba
TEST_CASE("valid_multiple_packages_succeed")
{
ChannelContext channel_context;
const fs::u8path lockfile_path{ test_data_dir
/ "env_lockfile/good_multiple_packages-lock.yaml" };
const fs::u8path lockfile_path{
test_data_dir / "env_lockfile/good_multiple_packages-lock.yaml"};
const auto maybe_lockfile = read_environment_lockfile(channel_context, lockfile_path);
REQUIRE_MESSAGE(maybe_lockfile, maybe_lockfile.error().what());
const auto lockfile = maybe_lockfile.value();
@ -116,8 +114,8 @@ namespace mamba
TEST_CASE("get_specific_packages")
{
ChannelContext channel_context;
const fs::u8path lockfile_path{ test_data_dir
/ "env_lockfile/good_multiple_packages-lock.yaml" };
const fs::u8path lockfile_path{
test_data_dir / "env_lockfile/good_multiple_packages-lock.yaml"};
const auto lockfile = read_environment_lockfile(channel_context, lockfile_path).value();
CHECK(lockfile.get_packages_for("", "", "").empty());
{
@ -134,11 +132,11 @@ namespace mamba
TEST_CASE("create_transaction_with_categories")
{
const fs::u8path lockfile_path{ test_data_dir
/ "env_lockfile/good_multiple_categories-lock.yaml" };
const fs::u8path lockfile_path{
test_data_dir / "env_lockfile/good_multiple_categories-lock.yaml"};
ChannelContext channel_context;
MPool pool{ channel_context };
mamba::MultiPackageCache pkg_cache({ "/tmp/" });
MPool pool{channel_context};
mamba::MultiPackageCache pkg_cache({"/tmp/"});
auto& ctx = Context::instance();
@ -168,10 +166,10 @@ namespace mamba
}
};
check_categories({ "main" }, 3, 5);
check_categories({ "main", "dev" }, 31, 6);
check_categories({ "dev" }, 28, 1);
check_categories({ "nonesuch" }, 0, 0);
check_categories({"main"}, 3, 5);
check_categories({"main", "dev"}, 31, 6);
check_categories({"dev"}, 28, 1);
check_categories({"nonesuch"}, 0, 0);
ctx.platform = ctx.host_platform;
}
@ -188,12 +186,12 @@ namespace mamba
CHECK(is_env_lockfile_name("../../some/dir/something-lock.yaml"));
CHECK(is_env_lockfile_name("../../some/dir/something-lock.yml"));
CHECK(is_env_lockfile_name(fs::u8path{ "something-lock.yaml" }.string()));
CHECK(is_env_lockfile_name(fs::u8path{ "something-lock.yml" }.string()));
CHECK(is_env_lockfile_name(fs::u8path{ "/some/dir/something-lock.yaml" }.string()));
CHECK(is_env_lockfile_name(fs::u8path{ "/some/dir/something-lock.yml" }.string()));
CHECK(is_env_lockfile_name(fs::u8path{ "../../some/dir/something-lock.yaml" }.string()));
CHECK(is_env_lockfile_name(fs::u8path{ "../../some/dir/something-lock.yml" }.string()));
CHECK(is_env_lockfile_name(fs::u8path{"something-lock.yaml"}.string()));
CHECK(is_env_lockfile_name(fs::u8path{"something-lock.yml"}.string()));
CHECK(is_env_lockfile_name(fs::u8path{"/some/dir/something-lock.yaml"}.string()));
CHECK(is_env_lockfile_name(fs::u8path{"/some/dir/something-lock.yml"}.string()));
CHECK(is_env_lockfile_name(fs::u8path{"../../some/dir/something-lock.yaml"}.string()));
CHECK(is_env_lockfile_name(fs::u8path{"../../some/dir/something-lock.yml"}.string()));
CHECK_FALSE(is_env_lockfile_name("something"));
CHECK_FALSE(is_env_lockfile_name("something-lock"));
@ -207,10 +205,10 @@ namespace mamba
CHECK_FALSE(is_env_lockfile_name("../../some/dir/something.yaml"));
CHECK_FALSE(is_env_lockfile_name("../../some/dir/something.yml"));
CHECK_FALSE(is_env_lockfile_name(fs::u8path{ "something" }.string()));
CHECK_FALSE(is_env_lockfile_name(fs::u8path{ "something-lock" }.string()));
CHECK_FALSE(is_env_lockfile_name(fs::u8path{ "/some/dir/something" }.string()));
CHECK_FALSE(is_env_lockfile_name(fs::u8path{ "../../some/dir/something" }.string()));
CHECK_FALSE(is_env_lockfile_name(fs::u8path{"something"}.string()));
CHECK_FALSE(is_env_lockfile_name(fs::u8path{"something-lock"}.string()));
CHECK_FALSE(is_env_lockfile_name(fs::u8path{"/some/dir/something"}.string()));
CHECK_FALSE(is_env_lockfile_name(fs::u8path{"../../some/dir/something"}.string()));
}
}

View File

@ -68,7 +68,7 @@ namespace mamba
{
constexpr std::size_t arbitrary_task_count = 2048;
constexpr std::size_t arbitrary_tasks_per_generator = 24;
std::atomic<int> counter{ 0 };
std::atomic<int> counter{0};
{
MainExecutor executor;
@ -85,7 +85,7 @@ namespace mamba
{
constexpr std::size_t arbitrary_task_count = 2048;
constexpr std::size_t arbitrary_tasks_per_generator = 36;
std::atomic<int> counter{ 0 };
std::atomic<int> counter{0};
{
MainExecutor executor;

View File

@ -19,7 +19,7 @@ namespace mamba
TEST_CASE("normalized_separators")
{
static constexpr auto value = u8"a/b/c";
std::filesystem::path x{ value };
std::filesystem::path x{value};
const auto y = fs::normalized_separators(x);
#if defined(_WIN32)
REQUIRE_EQ(y.u8string(), u8R"(a\b\c)");
@ -84,7 +84,7 @@ namespace mamba
{
const auto path_to_search_from = file_dir.parent_path();
fs::recursive_directory_iterator it{ path_to_search_from };
fs::recursive_directory_iterator it{path_to_search_from};
auto first_entry = *it;
CHECK_EQ(first_entry.path(), file_path.parent_path());
auto secibd_entry = *(++it);
@ -190,8 +190,9 @@ namespace mamba
const auto readonly_file_path = tmp_dir / "fs-readonly-file";
{
std::ofstream readonly_file{ readonly_file_path.std_path(),
readonly_file.binary | readonly_file.trunc };
std::ofstream readonly_file{
readonly_file_path.std_path(),
readonly_file.binary | readonly_file.trunc};
readonly_file << "delete me" << std::endl;
}
@ -236,8 +237,9 @@ namespace mamba
const auto readonly_file_path = dir_path
/ fmt::format("readonly-file-{}", file_idx);
{
std::ofstream readonly_file{ readonly_file_path.std_path(),
readonly_file.binary | readonly_file.trunc };
std::ofstream readonly_file{
readonly_file_path.std_path(),
readonly_file.binary | readonly_file.trunc};
readonly_file << "delete me" << std::endl;
}
@ -271,7 +273,7 @@ namespace mamba
return subdirs;
};
std::vector<fs::u8path> dirs{ tmp_dir };
std::vector<fs::u8path> dirs{tmp_dir};
for (int depth = 0; depth < tree_depth; ++depth)
{
dirs = create_subdirs(dirs);

View File

@ -82,7 +82,7 @@ namespace mamba
}
};
auto result = safe_invoke(DoNotDoThisAtHome{ did_move_happened });
auto result = safe_invoke(DoNotDoThisAtHome{did_move_happened});
CHECK_FALSE(result);
CHECK_MESSAGE(ends_with(result.error().what(), "unknown error"), result.error().what());
CHECK(did_move_happened);

View File

@ -66,7 +66,7 @@ namespace mamba
{
TEST_CASE_FIXTURE(LockDirTest, "basics")
{
mamba::LockFile lock{ tempdir_path };
mamba::LockFile lock{tempdir_path};
CHECK(lock);
{
auto new_lock = std::move(lock);
@ -135,7 +135,7 @@ namespace mamba
CHECK(mamba::LockFile::is_locked(lock));
// Check lock status from another process
args = { lock_exe, "is-locked", lock.lockfile_path().string() };
args = {lock_exe, "is-locked", lock.lockfile_path().string()};
out.clear();
err.clear();
reproc::run(
@ -157,7 +157,7 @@ namespace mamba
CHECK(is_locked);
// Try to lock from another process
args = { lock_exe, "lock", "--timeout=1", tempdir_path.string() };
args = {lock_exe, "lock", "--timeout=1", tempdir_path.string()};
out.clear();
err.clear();
reproc::run(
@ -182,7 +182,7 @@ namespace mamba
fs::u8path lock_path = tempdir_path / (tempdir_path.filename().string() + ".lock");
CHECK_FALSE(fs::exists(lock_path));
args = { lock_exe, "is-locked", lock_path.string() };
args = {lock_exe, "is-locked", lock_path.string()};
out.clear();
err.clear();
reproc::run(args, reproc::options{}, reproc::sink::string(out), reproc::sink::string(err));
@ -225,13 +225,13 @@ namespace mamba
TEST_CASE_FIXTURE(LockFileTest, "same_pid")
{
{
LockFile lock{ tempfile_path };
LockFile lock{tempfile_path};
CHECK(lock.is_locked());
CHECK(fs::exists(lock.lockfile_path()));
CHECK_EQ(lock.count_lock_owners(), 1);
{
LockFile other_lock{ tempfile_path };
LockFile other_lock{tempfile_path};
CHECK(other_lock.is_locked());
CHECK_EQ(other_lock.count_lock_owners(), 2);
CHECK_EQ(lock.count_lock_owners(), 2);
@ -259,7 +259,7 @@ namespace mamba
CHECK(mamba::LockFile::is_locked(lock));
// Check lock status from another process
args = { lock_exe, "is-locked", lock.lockfile_path().string() };
args = {lock_exe, "is-locked", lock.lockfile_path().string()};
out.clear();
err.clear();
reproc::run(
@ -281,7 +281,7 @@ namespace mamba
CHECK(is_locked);
// Try to lock from another process
args = { lock_exe, "lock", "--timeout=1", tempfile_path.string() };
args = {lock_exe, "lock", "--timeout=1", tempfile_path.string()};
out.clear();
err.clear();
reproc::run(
@ -306,7 +306,7 @@ namespace mamba
fs::u8path lock_path = tempfile_path.string() + ".lock";
CHECK_FALSE(fs::exists(lock_path));
args = { lock_exe, "is-locked", lock_path.string() };
args = {lock_exe, "is-locked", lock_path.string()};
out.clear();
err.clear();
reproc::run(args, reproc::options{}, reproc::sink::string(out), reproc::sink::string(err));

View File

@ -31,63 +31,63 @@ namespace mamba
PrefixData& prefix_data = sprefix_data.value();
REQUIRE_EQ(prefix_data.records().size(), 0);
specs = { "python" };
specs = {"python"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "python-test" };
specs = {"python-test"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "python=3" };
specs = {"python=3"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "python==3.8" };
specs = {"python==3.8"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "python==3.8.3" };
specs = {"python==3.8.3"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "numpy" };
specs = {"numpy"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
PackageInfo pkg_info("python", "3.7.10", "abcde", 0);
prefix_data.add_packages({ pkg_info });
prefix_data.add_packages({pkg_info});
REQUIRE_EQ(prefix_data.records().size(), 1);
specs = { "python" };
specs = {"python"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "numpy" };
specs = {"numpy"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "python 3.7.*");
specs = { "python-test" };
specs = {"python-test"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "python 3.7.*");
specs = { "python==3" };
specs = {"python==3"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "python=3.*" };
specs = {"python=3.*"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "python=3.8" };
specs = {"python=3.8"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "python=3.8.3" };
specs = {"python=3.8.3"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
specs = { "numpy", "python" };
specs = {"numpy", "python"};
pin = python_pin(prefix_data, specs);
CHECK_EQ(pin, "");
}

View File

@ -53,7 +53,7 @@ TEST_SUITE("conflict_map")
TEST_CASE("remove")
{
auto c = conflict_map<std::size_t>({ { 1, 1 }, { 1, 2 }, { 1, 3 }, { 2, 4 } });
auto c = conflict_map<std::size_t>({{1, 1}, {1, 2}, {1, 3}, {2, 4}});
REQUIRE_EQ(c.size(), 4);
REQUIRE(c.in_conflict(2, 4));
@ -148,12 +148,9 @@ namespace
);
const auto repodata_f = create_repodata_json(tmp_dir.path, packages);
auto pool = MPool{ channel_context };
MRepo(pool, "some-name", repodata_f, RepoMetadata{ /* .url= */ "some-url" });
auto solver = MSolver(
std::move(pool),
std::vector{ std::pair{ SOLVER_FLAG_ALLOW_DOWNGRADE, 1 } }
);
auto pool = MPool{channel_context};
MRepo(pool, "some-name", repodata_f, RepoMetadata{/* .url= */ "some-url"});
auto solver = MSolver(std::move(pool), std::vector{std::pair{SOLVER_FLAG_ALLOW_DOWNGRADE, 1}});
solver.add_jobs(specs, SOLVER_INSTALL);
return solver;
@ -162,7 +159,7 @@ namespace
TEST_CASE("Test create_problem utility")
{
auto solver = create_problem(std::array{ mkpkg("foo", "0.1.0", {}) }, { "foo" });
auto solver = create_problem(std::array{mkpkg("foo", "0.1.0", {})}, {"foo"});
const auto solved = solver.try_solve();
REQUIRE(solved);
}
@ -177,7 +174,7 @@ namespace
mkpkg("A", "0.2.0"),
mkpkg("A", "0.3.0"),
},
{ "A=0.4.0" }
{"A=0.4.0"}
);
}
@ -191,61 +188,61 @@ namespace
{
return create_problem(
std::array{
mkpkg("menu", "1.5.0", { "dropdown=2.*" }),
mkpkg("menu", "1.4.0", { "dropdown=2.*" }),
mkpkg("menu", "1.3.0", { "dropdown=2.*" }),
mkpkg("menu", "1.2.0", { "dropdown=2.*" }),
mkpkg("menu", "1.1.0", { "dropdown=2.*" }),
mkpkg("menu", "1.0.0", { "dropdown=1.*" }),
mkpkg("dropdown", "2.3.0", { "icons=2.*" }),
mkpkg("dropdown", "2.2.0", { "icons=2.*" }),
mkpkg("dropdown", "2.1.0", { "icons=2.*" }),
mkpkg("dropdown", "2.0.0", { "icons=2.*" }),
mkpkg("dropdown", "1.8.0", { "icons=1.*", "intl=3.*" }),
mkpkg("menu", "1.5.0", {"dropdown=2.*"}),
mkpkg("menu", "1.4.0", {"dropdown=2.*"}),
mkpkg("menu", "1.3.0", {"dropdown=2.*"}),
mkpkg("menu", "1.2.0", {"dropdown=2.*"}),
mkpkg("menu", "1.1.0", {"dropdown=2.*"}),
mkpkg("menu", "1.0.0", {"dropdown=1.*"}),
mkpkg("dropdown", "2.3.0", {"icons=2.*"}),
mkpkg("dropdown", "2.2.0", {"icons=2.*"}),
mkpkg("dropdown", "2.1.0", {"icons=2.*"}),
mkpkg("dropdown", "2.0.0", {"icons=2.*"}),
mkpkg("dropdown", "1.8.0", {"icons=1.*", "intl=3.*"}),
mkpkg("icons", "2.0.0"),
mkpkg("icons", "1.0.0"),
mkpkg("intl", "5.0.0"),
mkpkg("intl", "4.0.0"),
mkpkg("intl", "3.0.0"),
},
{ "menu", "icons=1.*", "intl=5.*" }
{"menu", "icons=1.*", "intl=5.*"}
);
}
auto create_pubgrub_hard_(bool missing_package) -> MSolver
{
auto packages = std::vector{
mkpkg("menu", "2.1.0", { "dropdown>=2.1", "emoji" }),
mkpkg("menu", "2.0.1", { "dropdown>=2", "emoji" }),
mkpkg("menu", "2.0.0", { "dropdown>=2", "emoji" }),
mkpkg("menu", "1.5.0", { "dropdown=2.*", "emoji" }),
mkpkg("menu", "1.4.0", { "dropdown=2.*", "emoji" }),
mkpkg("menu", "1.3.0", { "dropdown=2.*" }),
mkpkg("menu", "1.2.0", { "dropdown=2.*" }),
mkpkg("menu", "1.1.0", { "dropdown=1.*" }),
mkpkg("menu", "1.0.0", { "dropdown=1.*" }),
mkpkg("emoji", "1.1.0", { "libicons=2.*" }),
mkpkg("emoji", "1.0.0", { "libicons=2.*" }),
mkpkg("dropdown", "2.3.0", { "libicons=2.*" }),
mkpkg("dropdown", "2.2.0", { "libicons=2.*" }),
mkpkg("dropdown", "2.1.0", { "libicons=2.*" }),
mkpkg("dropdown", "2.0.0", { "libicons=2.*" }),
mkpkg("dropdown", "1.8.0", { "libicons=1.*", "intl=3.*" }),
mkpkg("dropdown", "1.7.0", { "libicons=1.*", "intl=3.*" }),
mkpkg("dropdown", "1.6.0", { "libicons=1.*", "intl=3.*" }),
mkpkg("pyicons", "2.0.0", { "libicons=2.*" }),
mkpkg("pyicons", "1.1.0", { "libicons=1.2.*" }),
mkpkg("pyicons", "1.0.0", { "libicons=1.*" }),
mkpkg("pretty", "1.1.0", { "pyicons=1.1.*" }),
mkpkg("pretty", "1.0.1", { "pyicons=1.*" }),
mkpkg("pretty", "1.0.0", { "pyicons=1.*" }),
mkpkg("menu", "2.1.0", {"dropdown>=2.1", "emoji"}),
mkpkg("menu", "2.0.1", {"dropdown>=2", "emoji"}),
mkpkg("menu", "2.0.0", {"dropdown>=2", "emoji"}),
mkpkg("menu", "1.5.0", {"dropdown=2.*", "emoji"}),
mkpkg("menu", "1.4.0", {"dropdown=2.*", "emoji"}),
mkpkg("menu", "1.3.0", {"dropdown=2.*"}),
mkpkg("menu", "1.2.0", {"dropdown=2.*"}),
mkpkg("menu", "1.1.0", {"dropdown=1.*"}),
mkpkg("menu", "1.0.0", {"dropdown=1.*"}),
mkpkg("emoji", "1.1.0", {"libicons=2.*"}),
mkpkg("emoji", "1.0.0", {"libicons=2.*"}),
mkpkg("dropdown", "2.3.0", {"libicons=2.*"}),
mkpkg("dropdown", "2.2.0", {"libicons=2.*"}),
mkpkg("dropdown", "2.1.0", {"libicons=2.*"}),
mkpkg("dropdown", "2.0.0", {"libicons=2.*"}),
mkpkg("dropdown", "1.8.0", {"libicons=1.*", "intl=3.*"}),
mkpkg("dropdown", "1.7.0", {"libicons=1.*", "intl=3.*"}),
mkpkg("dropdown", "1.6.0", {"libicons=1.*", "intl=3.*"}),
mkpkg("pyicons", "2.0.0", {"libicons=2.*"}),
mkpkg("pyicons", "1.1.0", {"libicons=1.2.*"}),
mkpkg("pyicons", "1.0.0", {"libicons=1.*"}),
mkpkg("pretty", "1.1.0", {"pyicons=1.1.*"}),
mkpkg("pretty", "1.0.1", {"pyicons=1.*"}),
mkpkg("pretty", "1.0.0", {"pyicons=1.*"}),
mkpkg("intl", "5.0.0"),
mkpkg("intl", "4.0.0"),
mkpkg("intl", "3.2.0"),
mkpkg("intl", "3.1.0"),
mkpkg("intl", "3.0.0"),
mkpkg("intl-mod", "1.0.0", { "intl=5.0.*" }),
mkpkg("intl-mod", "1.0.1", { "intl=5.0.*" }),
mkpkg("intl-mod", "1.0.0", {"intl=5.0.*"}),
mkpkg("intl-mod", "1.0.1", {"intl=5.0.*"}),
mkpkg("libicons", "2.1.0"),
mkpkg("libicons", "2.0.1"),
mkpkg("libicons", "2.0.0"),
@ -256,15 +253,12 @@ namespace
if (missing_package)
{
packages.push_back(mkpkg("dropdown", "2.9.3", { "libnothere>1.0" }));
packages.push_back(mkpkg("dropdown", "2.9.2", { "libicons>10.0", "libnothere>1.0" }));
packages.push_back(mkpkg("dropdown", "2.9.1", { "libicons>10.0", "libnothere>1.0" }));
packages.push_back(mkpkg("dropdown", "2.9.0", { "libicons>10.0" }));
packages.push_back(mkpkg("dropdown", "2.9.3", {"libnothere>1.0"}));
packages.push_back(mkpkg("dropdown", "2.9.2", {"libicons>10.0", "libnothere>1.0"}));
packages.push_back(mkpkg("dropdown", "2.9.1", {"libicons>10.0", "libnothere>1.0"}));
packages.push_back(mkpkg("dropdown", "2.9.0", {"libicons>10.0"}));
}
return create_problem(
packages,
{ "menu", "pyicons=1.*", "intl=5.*", "intl-mod", "pretty>=1.0" }
);
return create_problem(packages, {"menu", "pyicons=1.*", "intl=5.*", "intl-mod", "pretty>=1.0"});
}
/**
@ -332,9 +326,9 @@ namespace
*/
auto create_conda_forge(
std::vector<std::string>&& specs,
const std::vector<PackageInfo>& virtual_packages = { mkpkg("__glibc", "2.17.0") },
std::vector<std::string>&& channels = { "conda-forge" },
const std::vector<std::string>& platforms = { "linux-64", "noarch" }
const std::vector<PackageInfo>& virtual_packages = {mkpkg("__glibc", "2.17.0")},
std::vector<std::string>&& channels = {"conda-forge"},
const std::vector<std::string>& platforms = {"linux-64", "noarch"}
) -> MSolver
{
ChannelContext channel_context = {};
@ -347,11 +341,11 @@ namespace
PrefixData::create(tmp_dir.path / "prefix", channel_context)
);
prefix_data.add_packages(virtual_packages);
auto pool = MPool{ channel_context };
auto repo = MRepo{ pool, prefix_data };
auto pool = MPool{channel_context};
auto repo = MRepo{pool, prefix_data};
repo.set_installed();
auto cache = MultiPackageCache({ tmp_dir.path / "cache" });
auto cache = MultiPackageCache({tmp_dir.path / "cache"});
create_cache_dir(cache.first_writable_path());
bool prev_progress_bars_value = Context::instance().graphics_params.no_progress_bars;
@ -359,10 +353,7 @@ namespace
load_channels(pool, cache, make_platform_channels(std::move(channels), platforms));
Context::instance().graphics_params.no_progress_bars = prev_progress_bars_value;
auto solver = MSolver(
std::move(pool),
std::vector{ std::pair{ SOLVER_FLAG_ALLOW_DOWNGRADE, 1 } }
);
auto solver = MSolver(std::move(pool), std::vector{std::pair{SOLVER_FLAG_ALLOW_DOWNGRADE, 1}});
solver.add_jobs(specs, SOLVER_INSTALL);
return solver;
@ -371,7 +362,7 @@ namespace
TEST_CASE("Test create_conda_forge utility ")
{
auto solver = create_conda_forge({ "xtensor>=0.7" });
auto solver = create_conda_forge({"xtensor>=0.7"});
const auto solved = solver.try_solve();
REQUIRE(solved);
}
@ -380,50 +371,50 @@ namespace
{
auto create_pytorch_cpu() -> MSolver
{
return create_conda_forge({ "python=2.7", "pytorch=1.12" });
return create_conda_forge({"python=2.7", "pytorch=1.12"});
}
auto create_pytorch_cuda() -> MSolver
{
return create_conda_forge(
{ "python=2.7", "pytorch=1.12" },
{ mkpkg("__glibc", "2.17.0"), mkpkg("__cuda", "10.2.0") }
{"python=2.7", "pytorch=1.12"},
{mkpkg("__glibc", "2.17.0"), mkpkg("__cuda", "10.2.0")}
);
}
auto create_cudatoolkit() -> MSolver
{
return create_conda_forge(
{ "python=3.7", "cudatoolkit=11.1", "cudnn=8.0", "pytorch=1.8", "torchvision=0.9=*py37_cu111*" },
{ mkpkg("__glibc", "2.17.0"), mkpkg("__cuda", "11.1") }
{"python=3.7", "cudatoolkit=11.1", "cudnn=8.0", "pytorch=1.8", "torchvision=0.9=*py37_cu111*"},
{mkpkg("__glibc", "2.17.0"), mkpkg("__cuda", "11.1")}
);
}
auto create_jpeg9b() -> MSolver
{
return create_conda_forge({ "python=3.7", "jpeg=9b" });
return create_conda_forge({"python=3.7", "jpeg=9b"});
}
auto create_r_base() -> MSolver
{
return create_conda_forge(
{ "r-base=3.5.* ", "pandas=0", "numpy<1.20.0", "matplotlib=2", "r-matchit=4.*" }
{"r-base=3.5.* ", "pandas=0", "numpy<1.20.0", "matplotlib=2", "r-matchit=4.*"}
);
}
auto create_scip() -> MSolver
{
return create_conda_forge({ "scip=8.*", "pyscipopt<4.0" });
return create_conda_forge({"scip=8.*", "pyscipopt<4.0"});
}
auto create_double_python() -> MSolver
{
return create_conda_forge({ "python=3.9.*", "python=3.10.*" });
return create_conda_forge({"python=3.9.*", "python=3.10.*"});
}
auto create_numba() -> MSolver
{
return create_conda_forge({ "python=3.11", "numba<0.56" });
return create_conda_forge({"python=3.11", "numba<0.56"});
}
template <typename NodeVariant>
@ -450,7 +441,7 @@ TEST_CASE("NamedList")
static constexpr std::size_t n_packages = 9;
for (std::size_t minor = 1; minor <= n_packages; ++minor)
{
l.insert({ mkpkg("pkg", fmt::format("0.{}.0", minor)) });
l.insert({mkpkg("pkg", fmt::format("0.{}.0", minor))});
}
CHECK_EQ(l.size(), n_packages);
CHECK_EQ(l.name(), "pkg");
@ -482,18 +473,18 @@ TEST_CASE("Create problem graph")
using CpPbGr = CompressedProblemsGraph;
const auto issues = std::array{
std::pair{ "Basic conflict", &create_basic_conflict },
std::pair{ "PubGrub example", &create_pubgrub },
std::pair{ "Harder PubGrub example", &create_pubgrub_hard },
std::pair{ "PubGrub example with missing packages", &create_pubgrub_missing },
std::pair{ "PyTorch CPU", &create_pytorch_cpu },
std::pair{ "PyTorch Cuda", &create_pytorch_cuda },
std::pair{ "Cuda Toolkit", &create_cudatoolkit },
std::pair{ "Jpeg", &create_jpeg9b },
std::pair{ "R base", &create_r_base },
std::pair{ "SCIP", &create_scip },
std::pair{ "Two different Python", &create_double_python },
std::pair{ "Numba", &create_numba },
std::pair{"Basic conflict", &create_basic_conflict},
std::pair{"PubGrub example", &create_pubgrub},
std::pair{"Harder PubGrub example", &create_pubgrub_hard},
std::pair{"PubGrub example with missing packages", &create_pubgrub_missing},
std::pair{"PyTorch CPU", &create_pytorch_cpu},
std::pair{"PyTorch Cuda", &create_pytorch_cuda},
std::pair{"Cuda Toolkit", &create_cudatoolkit},
std::pair{"Jpeg", &create_jpeg9b},
std::pair{"R base", &create_r_base},
std::pair{"SCIP", &create_scip},
std::pair{"Two different Python", &create_double_python},
std::pair{"Numba", &create_numba},
};
for (const auto& [name, factory] : issues)

View File

@ -53,10 +53,18 @@ TEST_SUITE("system_env")
{
// We check that normal pre-defined variables are accessible and do not fail access even if
// some of these values have unicode.
const std::vector<std::string> predefined_keys{ "PATH", "OS", "PATHEXT",
"ProgramData", "SystemRoot", "windir",
"APPDATA", "COMPUTERNAME", "TEMP",
"UserName", "USERPROFILE" };
const std::vector<std::string> predefined_keys{
"PATH",
"OS",
"PATHEXT",
"ProgramData",
"SystemRoot",
"windir",
"APPDATA",
"COMPUTERNAME",
"TEMP",
"UserName",
"USERPROFILE"};
for (const auto& key : predefined_keys)
{

View File

@ -128,11 +128,11 @@ namespace mamba
std::string sequence;
TaskSynchronizer task_sync;
const auto unlock_duration = std::chrono::seconds{ 1 };
std::atomic<bool> task_started{ false };
std::atomic<bool> task_continue{ false };
std::atomic<bool> unlocker_ready{ false };
std::atomic<bool> unlocker_start{ false };
const auto unlock_duration = std::chrono::seconds{1};
std::atomic<bool> task_started{false};
std::atomic<bool> task_continue{false};
std::atomic<bool> unlocker_ready{false};
std::atomic<bool> unlocker_start{false};
auto ft_task = std::async(
std::launch::async,

View File

@ -52,7 +52,7 @@ namespace mamba
++res;
}
std::this_thread::sleep_for(std::chrono::milliseconds(300));
} }.extract());
}}.extract());
}
if (interrupt)
{

View File

@ -22,7 +22,7 @@ namespace mamba
mamba::ChannelContext channel_context;
const mamba::Channel& c = channel_context.make_channel("conda-forge");
mamba::MultiDownloadTarget multi_dl;
mamba::MultiPackageCache pkg_cache({ "/tmp/" });
mamba::MultiPackageCache pkg_cache({"/tmp/"});
mamba::MSubdirData cf = mamba::MSubdirData::create(
c,
"linux-64",
@ -44,7 +44,7 @@ namespace mamba
mamba::ChannelContext channel_context;
const mamba::Channel& c = channel_context.make_channel("conda-forge");
mamba::MultiDownloadTarget multi_dl;
mamba::MultiPackageCache pkg_cache({ "/tmp/" });
mamba::MultiPackageCache pkg_cache({"/tmp/"});
mamba::MSubdirData cf = mamba::MSubdirData::create(
c,
"noarch",

View File

@ -16,10 +16,19 @@
namespace mamba
{
const std::vector<std::string> KNOWN_PLATFORMS = {
"noarch", "linux-32", "linux-64", "linux-aarch64", "linux-armv6l",
"linux-armv7l", "linux-ppc64le", "linux-ppc64", "osx-64", "osx-arm64",
"win-32", "win-64", "zos-z"
};
"noarch",
"linux-32",
"linux-64",
"linux-aarch64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-ppc64",
"osx-64",
"osx-arm64",
"win-32",
"win-64",
"zos-z"};
TEST_SUITE("url")
{
@ -59,7 +68,7 @@ namespace mamba
std::string platform_found, cleaned_url;
split_platform(
{ "noarch", "linux-64" },
{"noarch", "linux-64"},
"https://mamba.com/linux-64/package.tar.bz2",
ctx.platform,
cleaned_url,
@ -70,7 +79,7 @@ namespace mamba
CHECK_EQ(cleaned_url, "https://mamba.com/package.tar.bz2");
split_platform(
{ "noarch", "linux-64" },
{"noarch", "linux-64"},
"https://mamba.com/linux-64/noarch-package.tar.bz2",
ctx.platform,
cleaned_url,
@ -80,7 +89,7 @@ namespace mamba
CHECK_EQ(cleaned_url, "https://mamba.com/noarch-package.tar.bz2");
split_platform(
{ "linux-64", "osx-arm64", "noarch" },
{"linux-64", "osx-arm64", "noarch"},
"https://mamba.com/noarch/kernel_linux-64-package.tar.bz2",
ctx.platform,
cleaned_url,
@ -90,7 +99,7 @@ namespace mamba
CHECK_EQ(cleaned_url, "https://mamba.com/kernel_linux-64-package.tar.bz2");
split_platform(
{ "noarch", "linux-64" },
{"noarch", "linux-64"},
"https://mamba.com/linux-64",
ctx.platform,
cleaned_url,
@ -101,7 +110,7 @@ namespace mamba
CHECK_EQ(cleaned_url, "https://mamba.com");
split_platform(
{ "noarch", "linux-64" },
{"noarch", "linux-64"},
"https://mamba.com/noarch",
ctx.platform,
cleaned_url,

View File

@ -38,8 +38,7 @@ namespace mamba
void* pointer_to_this_thread_rng = same_thread_checks();
void* pointer_to_another_thread_rng = nullptr;
std::thread another_thread{ [&]
{ pointer_to_another_thread_rng = same_thread_checks(); } };
std::thread another_thread{[&] { pointer_to_another_thread_rng = same_thread_checks(); }};
another_thread.join();
CHECK_NE(pointer_to_this_thread_rng, pointer_to_another_thread_rng);
@ -68,7 +67,7 @@ namespace mamba
{
bool executed = false;
{
on_scope_exit _{ [&] { executed = true; } };
on_scope_exit _{[&] { executed = true; }};
CHECK_FALSE(executed);
}
CHECK(executed);
@ -88,24 +87,24 @@ namespace mamba
CHECK(is_yaml_file_name("../../some/dir/something.yml"));
CHECK(is_yaml_file_name("../../some/dir/something.yml"));
CHECK(is_yaml_file_name(fs::u8path{ "something.yaml" }.string()));
CHECK(is_yaml_file_name(fs::u8path{ "something.yml" }.string()));
CHECK(is_yaml_file_name(fs::u8path{ "something-lock.yaml" }.string()));
CHECK(is_yaml_file_name(fs::u8path{ "something-lock.yml" }.string()));
CHECK(is_yaml_file_name(fs::u8path{ "/some/dir/something.yaml" }.string()));
CHECK(is_yaml_file_name(fs::u8path{ "/some/dir/something.yml" }.string()));
CHECK(is_yaml_file_name(fs::u8path{ "../../some/dir/something.yaml" }.string()));
CHECK(is_yaml_file_name(fs::u8path{ "../../some/dir/something.yml" }.string()));
CHECK(is_yaml_file_name(fs::u8path{"something.yaml"}.string()));
CHECK(is_yaml_file_name(fs::u8path{"something.yml"}.string()));
CHECK(is_yaml_file_name(fs::u8path{"something-lock.yaml"}.string()));
CHECK(is_yaml_file_name(fs::u8path{"something-lock.yml"}.string()));
CHECK(is_yaml_file_name(fs::u8path{"/some/dir/something.yaml"}.string()));
CHECK(is_yaml_file_name(fs::u8path{"/some/dir/something.yml"}.string()));
CHECK(is_yaml_file_name(fs::u8path{"../../some/dir/something.yaml"}.string()));
CHECK(is_yaml_file_name(fs::u8path{"../../some/dir/something.yml"}.string()));
CHECK_FALSE(is_yaml_file_name("something"));
CHECK_FALSE(is_yaml_file_name("something-lock"));
CHECK_FALSE(is_yaml_file_name("/some/dir/something"));
CHECK_FALSE(is_yaml_file_name("../../some/dir/something"));
CHECK_FALSE(is_yaml_file_name(fs::u8path{ "something" }.string()));
CHECK_FALSE(is_yaml_file_name(fs::u8path{ "something-lock" }.string()));
CHECK_FALSE(is_yaml_file_name(fs::u8path{ "/some/dir/something" }.string()));
CHECK_FALSE(is_yaml_file_name(fs::u8path{ "../../some/dir/something" }.string()));
CHECK_FALSE(is_yaml_file_name(fs::u8path{"something"}.string()));
CHECK_FALSE(is_yaml_file_name(fs::u8path{"something-lock"}.string()));
CHECK_FALSE(is_yaml_file_name(fs::u8path{"/some/dir/something"}.string()));
CHECK_FALSE(is_yaml_file_name(fs::u8path{"../../some/dir/something"}.string()));
}
}
@ -134,11 +133,11 @@ namespace mamba
{
const auto test_dir_path = fs::temp_directory_path() / "libmamba" / "writable_tests";
fs::create_directories(test_dir_path);
on_scope_exit _{ [&]
{
fs::permissions(test_dir_path, fs::perms::all);
fs::remove_all(test_dir_path);
} };
on_scope_exit _{[&]
{
fs::permissions(test_dir_path, fs::perms::all);
fs::remove_all(test_dir_path);
}};
CHECK(path::is_writable(test_dir_path));
fs::permissions(test_dir_path, fs::perms::none);
@ -158,7 +157,7 @@ namespace mamba
const auto existing_file_path = test_dir_path
/ "existing-writable-test-delete-me.txt";
{
std::ofstream temp_file{ existing_file_path.std_path() };
std::ofstream temp_file{existing_file_path.std_path()};
REQUIRE(temp_file.is_open());
temp_file << "delete me" << std::endl;
}
@ -175,11 +174,12 @@ namespace mamba
{
TEST_CASE("proxy_match")
{
Context::instance().proxy_servers = { { "http", "foo" },
{ "https", "bar" },
{ "https://example.net", "foobar" },
{ "all://example.net", "baz" },
{ "all", "other" } };
Context::instance().proxy_servers = {
{"http", "foo"},
{"https", "bar"},
{"https://example.net", "foobar"},
{"all://example.net", "baz"},
{"all", "other"}};
CHECK_EQ(*proxy_match("http://example.com/channel"), "foo");
CHECK_EQ(*proxy_match("http://example.net/channel"), "foo");
@ -189,10 +189,11 @@ namespace mamba
CHECK_EQ(*proxy_match("ftp://example.net/channel"), "baz");
CHECK_EQ(*proxy_match("ftp://example.org"), "other");
Context::instance().proxy_servers = { { "http", "foo" },
{ "https", "bar" },
{ "https://example.net", "foobar" },
{ "all://example.net", "baz" } };
Context::instance().proxy_servers = {
{"http", "foo"},
{"https", "bar"},
{"https://example.net", "foobar"},
{"all://example.net", "baz"}};
CHECK_FALSE(proxy_match("ftp://example.org").has_value());

View File

@ -67,24 +67,24 @@ namespace mamba
TEST_CASE("any_starts_with")
{
using StrVec = std::vector<std::string_view>;
CHECK_FALSE(any_starts_with(StrVec{}, { "not" }));
CHECK_FALSE(any_starts_with(StrVec{}, {"not"}));
CHECK_FALSE(any_starts_with(StrVec{}, ""));
CHECK(any_starts_with(StrVec{ ":hello", "world" }, ""));
CHECK(any_starts_with(StrVec{ ":hello", "world" }, ":"));
CHECK(any_starts_with(StrVec{ ":hello", "world" }, ":h"));
CHECK(any_starts_with(StrVec{ ":hello", "world" }, ":hello"));
CHECK_FALSE(any_starts_with(StrVec{ ":hello", "world" }, "orld"));
CHECK(any_starts_with(StrVec{ "áäᜩgþhëb", "®hüghœ©®xb" }, "áäá"));
CHECK(any_starts_with(StrVec{":hello", "world"}, ""));
CHECK(any_starts_with(StrVec{":hello", "world"}, ":"));
CHECK(any_starts_with(StrVec{":hello", "world"}, ":h"));
CHECK(any_starts_with(StrVec{":hello", "world"}, ":hello"));
CHECK_FALSE(any_starts_with(StrVec{":hello", "world"}, "orld"));
CHECK(any_starts_with(StrVec{"áäᜩgþhëb", "®hüghœ©®xb"}, "áäá"));
}
TEST_CASE("starts_with_any")
{
using StrVec = std::vector<std::string_view>;
CHECK(starts_with_any(":hello", StrVec{ "", "not" }));
CHECK(starts_with_any(":hello", StrVec{ ":hello", "not" }));
CHECK(starts_with_any(":hello", StrVec{"", "not"}));
CHECK(starts_with_any(":hello", StrVec{":hello", "not"}));
CHECK_FALSE(starts_with_any(":hello", StrVec{}));
CHECK_FALSE(starts_with_any(":hello", StrVec{ "not", "any" }));
CHECK(starts_with_any("áäᜩgþhëb®hüghœ©®xb", StrVec{ "áäᜩgþhëb", "®hüghœ©®xb" }));
CHECK_FALSE(starts_with_any(":hello", StrVec{"not", "any"}));
CHECK(starts_with_any("áäᜩgþhëb®hüghœ©®xb", StrVec{"áäᜩgþhëb", "®hüghœ©®xb"}));
}
TEST_CASE("lstrip")
@ -101,12 +101,12 @@ namespace mamba
TEST_CASE("lstrip_parts")
{
using StrPair = std::array<std::string_view, 2>;
CHECK_EQ(lstrip_parts(":::hello%:%", ":%"), StrPair({ ":::", "hello%:%" }));
CHECK_EQ(lstrip_parts(":::hello%:%", ':'), StrPair({ ":::", "hello%:%" }));
CHECK_EQ(lstrip_parts(":::hello%:%", '%'), StrPair({ "", ":::hello%:%" }));
CHECK_EQ(lstrip_parts("", '%'), StrPair({ "", "" }));
CHECK_EQ(lstrip_parts("aaa", 'a'), StrPair({ "aaa", "" }));
CHECK_EQ(lstrip_parts("aaa", 'b'), StrPair({ "", "aaa" }));
CHECK_EQ(lstrip_parts(":::hello%:%", ":%"), StrPair({":::", "hello%:%"}));
CHECK_EQ(lstrip_parts(":::hello%:%", ':'), StrPair({":::", "hello%:%"}));
CHECK_EQ(lstrip_parts(":::hello%:%", '%'), StrPair({"", ":::hello%:%"}));
CHECK_EQ(lstrip_parts("", '%'), StrPair({"", ""}));
CHECK_EQ(lstrip_parts("aaa", 'a'), StrPair({"aaa", ""}));
CHECK_EQ(lstrip_parts("aaa", 'b'), StrPair({"", "aaa"}));
}
TEST_CASE("lstrip_if")
@ -121,16 +121,16 @@ namespace mamba
TEST_CASE("lstrip_if_parts")
{
using StrPair = std::array<std::string_view, 2>;
CHECK_EQ(lstrip_if_parts("", [](auto) { return true; }), StrPair({ "", "" }));
CHECK_EQ(lstrip_if_parts("hello", [](auto) { return true; }), StrPair({ "hello", "" }));
CHECK_EQ(lstrip_if_parts("hello", [](auto) { return false; }), StrPair({ "", "hello" }));
CHECK_EQ(lstrip_if_parts("", [](auto) { return true; }), StrPair({"", ""}));
CHECK_EQ(lstrip_if_parts("hello", [](auto) { return true; }), StrPair({"hello", ""}));
CHECK_EQ(lstrip_if_parts("hello", [](auto) { return false; }), StrPair({"", "hello"}));
CHECK_EQ(
lstrip_if_parts("\n \thello \t\n", [](auto c) { return !is_alphanum(c); }),
StrPair({ "\n \t", "hello \t\n" })
StrPair({"\n \t", "hello \t\n"})
);
CHECK_EQ(
lstrip_if_parts("123hello456", [](auto c) { return is_digit(c); }),
StrPair({ "123", "hello456" })
StrPair({"123", "hello456"})
);
}
@ -148,12 +148,12 @@ namespace mamba
TEST_CASE("rstrip_parts")
{
using StrPair = std::array<std::string_view, 2>;
CHECK_EQ(rstrip_parts(":::hello%:%", '%'), StrPair({ ":::hello%:", "%" }));
CHECK_EQ(rstrip_parts(":::hello%:%", ":%"), StrPair({ ":::hello", "%:%" }));
CHECK_EQ(rstrip_parts(":::hello%:%", ':'), StrPair({ ":::hello%:%", "" }));
CHECK_EQ(rstrip_parts("", '%'), StrPair({ "", "" }));
CHECK_EQ(rstrip_parts("aaa", 'a'), StrPair({ "", "aaa" }));
CHECK_EQ(rstrip_parts("aaa", 'b'), StrPair({ "aaa", "" }));
CHECK_EQ(rstrip_parts(":::hello%:%", '%'), StrPair({":::hello%:", "%"}));
CHECK_EQ(rstrip_parts(":::hello%:%", ":%"), StrPair({":::hello", "%:%"}));
CHECK_EQ(rstrip_parts(":::hello%:%", ':'), StrPair({":::hello%:%", ""}));
CHECK_EQ(rstrip_parts("", '%'), StrPair({"", ""}));
CHECK_EQ(rstrip_parts("aaa", 'a'), StrPair({"", "aaa"}));
CHECK_EQ(rstrip_parts("aaa", 'b'), StrPair({"aaa", ""}));
}
TEST_CASE("rstrip_if")
@ -168,16 +168,16 @@ namespace mamba
TEST_CASE("rstrip_if_parts")
{
using StrPair = std::array<std::string_view, 2>;
CHECK_EQ(rstrip_if_parts("", [](auto) { return true; }), StrPair({ "", "" }));
CHECK_EQ(rstrip_if_parts("hello", [](auto) { return true; }), StrPair({ "", "hello" }));
CHECK_EQ(rstrip_if_parts("hello", [](auto) { return false; }), StrPair({ "hello", "" }));
CHECK_EQ(rstrip_if_parts("", [](auto) { return true; }), StrPair({"", ""}));
CHECK_EQ(rstrip_if_parts("hello", [](auto) { return true; }), StrPair({"", "hello"}));
CHECK_EQ(rstrip_if_parts("hello", [](auto) { return false; }), StrPair({"hello", ""}));
CHECK_EQ(
rstrip_if_parts("\n \thello \t\n", [](auto c) { return !is_alphanum(c); }),
StrPair({ "\n \thello", " \t\n" })
StrPair({"\n \thello", " \t\n"})
);
CHECK_EQ(
rstrip_if_parts("123hello456", [](auto c) { return is_digit(c); }),
StrPair({ "123hello", "456" })
StrPair({"123hello", "456"})
);
}
@ -194,11 +194,11 @@ namespace mamba
TEST_CASE("strip_parts")
{
using StrTrio = std::array<std::string_view, 3>;
CHECK_EQ(strip_parts(":::hello%:%", ":%"), StrTrio({ ":::", "hello", "%:%" }));
CHECK_EQ(strip_parts(":::hello%:%", ':'), StrTrio({ ":::", "hello%:%", "" }));
CHECK_EQ(strip_parts("", '%'), StrTrio({ "", "", "" }));
CHECK_EQ(strip_parts("aaa", 'a'), StrTrio({ "aaa", "", "" }));
CHECK_EQ(strip_parts("aaa", 'b'), StrTrio({ "", "aaa", "" }));
CHECK_EQ(strip_parts(":::hello%:%", ":%"), StrTrio({":::", "hello", "%:%"}));
CHECK_EQ(strip_parts(":::hello%:%", ':'), StrTrio({":::", "hello%:%", ""}));
CHECK_EQ(strip_parts("", '%'), StrTrio({"", "", ""}));
CHECK_EQ(strip_parts("aaa", 'a'), StrTrio({"aaa", "", ""}));
CHECK_EQ(strip_parts("aaa", 'b'), StrTrio({"", "aaa", ""}));
}
TEST_CASE("strip_if")
@ -213,16 +213,16 @@ namespace mamba
TEST_CASE("strip_if_parts")
{
using StrTrio = std::array<std::string_view, 3>;
CHECK_EQ(strip_if_parts("", [](auto) { return true; }), StrTrio({ "", "", "" }));
CHECK_EQ(strip_if_parts("hello", [](auto) { return true; }), StrTrio({ "hello", "", "" }));
CHECK_EQ(strip_if_parts("hello", [](auto) { return false; }), StrTrio({ "", "hello", "" }));
CHECK_EQ(strip_if_parts("", [](auto) { return true; }), StrTrio({"", "", ""}));
CHECK_EQ(strip_if_parts("hello", [](auto) { return true; }), StrTrio({"hello", "", ""}));
CHECK_EQ(strip_if_parts("hello", [](auto) { return false; }), StrTrio({"", "hello", ""}));
CHECK_EQ(
strip_if_parts("\n \thello \t\n", [](auto c) { return !is_alphanum(c); }),
StrTrio({ "\n \t", "hello", " \t\n" })
StrTrio({"\n \t", "hello", " \t\n"})
);
CHECK_EQ(
strip_if_parts("123hello456", [](auto c) { return is_digit(c); }),
StrTrio({ "123", "hello", "456" })
StrTrio({"123", "hello", "456"})
);
}
@ -289,32 +289,32 @@ namespace mamba
TEST_CASE("split")
{
std::string a = "hello.again.it's.me.mario";
std::vector<std::string> e1 = { "hello", "again", "it's", "me", "mario" };
std::vector<std::string> e1 = {"hello", "again", "it's", "me", "mario"};
CHECK_EQ(split(a, "."), e1);
std::vector<std::string> s2 = { "hello", "again", "it's.me.mario" };
std::vector<std::string> s2 = {"hello", "again", "it's.me.mario"};
CHECK_EQ(split(a, ".", 2), s2);
CHECK_EQ(rsplit(a, "."), e1);
std::vector<std::string> r2 = { "hello.again.it's", "me", "mario" };
std::vector<std::string> r2 = {"hello.again.it's", "me", "mario"};
CHECK_EQ(rsplit(a, ".", 2), r2);
std::string b = "...";
auto es1 = std::vector<std::string>{ "", "", "", "" };
auto es2 = std::vector<std::string>{ "", ".." };
auto es1 = std::vector<std::string>{"", "", "", ""};
auto es2 = std::vector<std::string>{"", ".."};
CHECK_EQ(split(b, "."), es1);
CHECK_EQ(split(b, ".", 1), es2);
std::vector<std::string> v = { "xtensor==0.12.3" };
std::vector<std::string> v = {"xtensor==0.12.3"};
CHECK_EQ(split(v[0], ":"), v);
CHECK_EQ(rsplit(v[0], ":"), v);
CHECK_EQ(split(v[0], ":", 2), v);
CHECK_EQ(rsplit(v[0], ":", 2), v);
std::vector<std::string> v2 = { "conda-forge/linux64", "", "xtensor==0.12.3" };
std::vector<std::string> v2 = {"conda-forge/linux64", "", "xtensor==0.12.3"};
CHECK_EQ(split("conda-forge/linux64::xtensor==0.12.3", ":", 2), v2);
CHECK_EQ(rsplit("conda-forge/linux64::xtensor==0.12.3", ":", 2), v2);
std::vector<std::string> v21 = { "conda-forge/linux64:", "xtensor==0.12.3" };
std::vector<std::string> v21 = {"conda-forge/linux64:", "xtensor==0.12.3"};
CHECK_EQ(rsplit("conda-forge/linux64::xtensor==0.12.3", ":", 1), v21);
}
@ -322,13 +322,13 @@ namespace mamba
TEST_CASE("join")
{
{
std::vector<std::string> to_join = { "a", "bc", "d" };
std::vector<std::string> to_join = {"a", "bc", "d"};
auto joined = join("-", to_join);
static_assert(std::is_same<decltype(joined), decltype(to_join)::value_type>::value);
CHECK_EQ(joined, "a-bc-d");
}
{
std::vector<fs::u8path> to_join = { "/a", "bc", "d" };
std::vector<fs::u8path> to_join = {"/a", "bc", "d"};
auto joined = join("/", to_join);
static_assert(std::is_same<decltype(joined), decltype(to_join)::value_type>::value);
CHECK_EQ(joined, "/a/bc/d");
@ -340,16 +340,16 @@ namespace mamba
TEST_CASE("join_trunc")
{
std::vector<std::string> to_join = { "a", "bc", "d", "e", "f" };
std::vector<std::string> to_join = {"a", "bc", "d", "e", "f"};
{
auto joined = join_trunc(to_join);
static_assert(std::is_same<decltype(joined), decltype(to_join)::value_type>::value);
}
CHECK_EQ(join_trunc(to_join, "-", "..", 5, { 2, 1 }), "a-bc-d-e-f");
CHECK_EQ(join_trunc(to_join, ",", "..", 4, { 2, 1 }), "a,bc,..,f");
CHECK_EQ(join_trunc(to_join, ",", "..", 4, { 0, 1 }), "..,f");
CHECK_EQ(join_trunc(to_join, ",", "..", 4, { 2, 0 }), "a,bc,..");
CHECK_EQ(join_trunc(to_join, ",", "..", 4, { 0, 0 }), "..");
CHECK_EQ(join_trunc(to_join, "-", "..", 5, {2, 1}), "a-bc-d-e-f");
CHECK_EQ(join_trunc(to_join, ",", "..", 4, {2, 1}), "a,bc,..,f");
CHECK_EQ(join_trunc(to_join, ",", "..", 4, {0, 1}), "..,f");
CHECK_EQ(join_trunc(to_join, ",", "..", 4, {2, 0}), "a,bc,..");
CHECK_EQ(join_trunc(to_join, ",", "..", 4, {0, 0}), "..");
CHECK_EQ(join_trunc(std::vector<std::string>()), "");
}

View File

@ -274,14 +274,14 @@ namespace mamba::validation
void generate_secrets(int root = 1, int key_mgr = 1, int pkg_mgr = 1)
{
secrets.insert({ "root", generate_role_secrets(root) });
secrets.insert({ "key_mgr", generate_role_secrets(key_mgr) });
secrets.insert({ "pkg_mgr", generate_role_secrets(pkg_mgr) });
secrets.insert({"root", generate_role_secrets(root)});
secrets.insert({"key_mgr", generate_role_secrets(key_mgr)});
secrets.insert({"pkg_mgr", generate_role_secrets(pkg_mgr)});
}
void sign_root()
{
std::vector<std::string> mandatory_roles({ "root", "key_mgr" });
std::vector<std::string> mandatory_roles({"root", "key_mgr"});
for (auto& r : mandatory_roles)
{
std::vector<std::string> role_public_keys;
@ -289,7 +289,7 @@ namespace mamba::validation
{
role_public_keys.push_back(secret.first);
}
root1_json["signed"]["delegations"][r] = RolePubKeys({ role_public_keys, 1 });
root1_json["signed"]["delegations"][r] = RolePubKeys({role_public_keys, 1});
}
root1_json["signed"]["version"] = 1;
@ -314,7 +314,7 @@ namespace mamba::validation
sign(root_meta.dump(2), secret.second.data(), sig_bin);
auto sig_hex = ::mamba::hex_string(sig_bin, MAMBA_ED25519_SIGSIZE_BYTES);
signatures[secret.first].insert({ "signature", sig_hex });
signatures[secret.first].insert({"signature", sig_hex});
}
return signatures;
@ -365,7 +365,7 @@ namespace mamba::validation
generate_ed25519_keypair(pk, sk.data());
auto pk_hex = ::mamba::hex_string(pk, MAMBA_ED25519_KEYSIZE_BYTES);
role_secrets.insert({ pk_hex, sk });
role_secrets.insert({pk_hex, sk});
}
return role_secrets;
}
@ -953,7 +953,7 @@ namespace mamba::validation
{
pkg_mgr_pks.push_back(secret.first);
}
key_mgr_json["signed"]["delegations"]["pkg_mgr"] = RolePubKeys({ pkg_mgr_pks, 1 });
key_mgr_json["signed"]["delegations"]["pkg_mgr"] = RolePubKeys({pkg_mgr_pks, 1});
key_mgr_json["signed"]["version"] = 1;
key_mgr_json["signed"]["metadata_spec_version"] = "0.6.0";
@ -1009,7 +1009,7 @@ namespace mamba::validation
sign(meta.dump(2), secret.second.data(), sig_bin);
auto sig_hex = ::mamba::hex_string(sig_bin, MAMBA_ED25519_SIGSIZE_BYTES);
signatures[secret.first].insert({ "signature", sig_hex });
signatures[secret.first].insert({"signature", sig_hex});
}
return signatures;
@ -1299,7 +1299,7 @@ namespace mamba::validation
sign(meta.dump(2), secret.second.data(), sig_bin);
auto sig_hex = ::mamba::hex_string(sig_bin, MAMBA_ED25519_SIGSIZE_BYTES);
signatures[secret.first].insert({ "signature", sig_hex });
signatures[secret.first].insert({"signature", sig_hex});
}
return signatures;
@ -1347,7 +1347,7 @@ namespace mamba::validation
sign(meta.dump(2), secret.second.data(), sig_bin);
auto sig_hex = ::mamba::hex_string(sig_bin, MAMBA_ED25519_SIGSIZE_BYTES);
signatures[secret.first].insert({ "signature", sig_hex });
signatures[secret.first].insert({"signature", sig_hex});
}
return signatures;
@ -1581,10 +1581,10 @@ namespace mamba::validation
void
generate_secrets(int root = 1, int targets = 1, int snapshot = 1, int timestamp = 1)
{
secrets.insert({ "root", generate_role_secrets(root) });
secrets.insert({ "targets", generate_role_secrets(targets) });
secrets.insert({ "snapshot", generate_role_secrets(snapshot) });
secrets.insert({ "timestamp", generate_role_secrets(timestamp) });
secrets.insert({"root", generate_role_secrets(root)});
secrets.insert({"targets", generate_role_secrets(targets)});
secrets.insert({"snapshot", generate_role_secrets(snapshot)});
secrets.insert({"timestamp", generate_role_secrets(timestamp)});
}
void sign_root()
@ -1602,9 +1602,9 @@ namespace mamba::validation
for (auto& s : it.second)
{
r_keys.push_back(s.first);
all_keys.insert({ s.first, Key::from_ed25519(s.first) });
all_keys.insert({s.first, Key::from_ed25519(s.first)});
}
all_roles[r] = { r_keys, 1 };
all_roles[r] = {r_keys, 1};
}
root1_json.at("signed").at("roles") = all_roles;
root1_json.at("signed").at("keys") = all_keys;
@ -1623,7 +1623,7 @@ namespace mamba::validation
sign(root_meta.dump(), secret.second.data(), sig_bin);
auto sig_hex = ::mamba::hex_string(sig_bin, MAMBA_ED25519_SIGSIZE_BYTES);
signatures.push_back({ secret.first, sig_hex });
signatures.push_back({secret.first, sig_hex});
}
return signatures;
@ -1651,7 +1651,7 @@ namespace mamba::validation
generate_ed25519_keypair(pk, sk.data());
auto pk_hex = ::mamba::hex_string(pk, MAMBA_ED25519_KEYSIZE_BYTES);
role_secrets.insert({ pk_hex, sk });
role_secrets.insert({pk_hex, sk});
}
return role_secrets;
}
@ -2156,11 +2156,11 @@ namespace mamba::validation
// Test serialization/deserialization
TEST_CASE("to_json")
{
RoleSignature s{ "some_key_id", "some_signature", "" };
RoleSignature s{"some_key_id", "some_signature", ""};
json j = R"({"keyid": "some_key_id", "sig": "some_signature"})"_json;
CHECK_EQ(j, json(s));
s = { "some_key_id", "some_signature", "some_pgp_trailer" };
s = {"some_key_id", "some_signature", "some_pgp_trailer"};
j = R"({"keyid": "some_key_id", "other_headers": "some_pgp_trailer", "sig": "some_signature"})"_json;
CHECK_EQ(j, json(s));
}

View File

@ -76,7 +76,7 @@ namespace mamba
// This is bad design, tests should not interfer
// Will get rid of that when implementing context as not a singleton
auto restore_ctx = [&ctx, old_plat = ctx.platform]() { ctx.platform = old_plat; };
auto finally = Finally<decltype(restore_ctx)>{ restore_ctx };
auto finally = Finally<decltype(restore_ctx)>{restore_ctx};
ctx.platform = "osx-arm";
env::set("CONDA_OVERRIDE_OSX", "12.1");

View File

@ -16,7 +16,7 @@ namespace doctest
{
static auto convert(const std::pair<T, U>& value) -> String
{
return { fmt::format("std::pair{{{}, {}}}", value.first, value.second).c_str() };
return {fmt::format("std::pair{{{}, {}}}", value.first, value.second).c_str()};
}
};
}

View File

@ -16,7 +16,7 @@ namespace doctest
{
static auto convert(const std::vector<T>& value) -> String
{
return { fmt::format("std::vector{{{}}}", fmt::join(value, ", ")).c_str() };
return {fmt::format("std::vector{{{}}}", fmt::join(value, ", ")).c_str()};
}
};
}

View File

@ -34,22 +34,22 @@ namespace mamba::test
inline auto make_packages()
{
return std::array<SimplePkg, 16>{
SimplePkg{ "menu", "1.5.0", { "dropdown=2.*" } },
SimplePkg{ "menu", "1.4.0", { "dropdown=2.*" } },
SimplePkg{ "menu", "1.3.0", { "dropdown=2.*" } },
SimplePkg{ "menu", "1.2.0", { "dropdown=2.*" } },
SimplePkg{ "menu", "1.1.0", { "dropdown=2.*" } },
SimplePkg{ "menu", "1.0.0", { "dropdown=1.*" } },
SimplePkg{ "dropdown", "2.3.0", { "icons=2.*" } },
SimplePkg{ "dropdown", "2.2.0", { "icons=2.*" } },
SimplePkg{ "dropdown", "2.1.0", { "icons=2.*" } },
SimplePkg{ "dropdown", "2.0.0", { "icons=2.*" } },
SimplePkg{ "dropdown", "1.8.0", { "icons=1.*", "intl=3.*" } },
SimplePkg{ "icons", "2.0.0" },
SimplePkg{ "icons", "1.0.0" },
SimplePkg{ "intl", "5.0.0" },
SimplePkg{ "intl", "4.0.0" },
SimplePkg{ "intl", "3.0.0" },
SimplePkg{"menu", "1.5.0", {"dropdown=2.*"}},
SimplePkg{"menu", "1.4.0", {"dropdown=2.*"}},
SimplePkg{"menu", "1.3.0", {"dropdown=2.*"}},
SimplePkg{"menu", "1.2.0", {"dropdown=2.*"}},
SimplePkg{"menu", "1.1.0", {"dropdown=2.*"}},
SimplePkg{"menu", "1.0.0", {"dropdown=1.*"}},
SimplePkg{"dropdown", "2.3.0", {"icons=2.*"}},
SimplePkg{"dropdown", "2.2.0", {"icons=2.*"}},
SimplePkg{"dropdown", "2.1.0", {"icons=2.*"}},
SimplePkg{"dropdown", "2.0.0", {"icons=2.*"}},
SimplePkg{"dropdown", "1.8.0", {"icons=1.*", "intl=3.*"}},
SimplePkg{"icons", "2.0.0"},
SimplePkg{"icons", "1.0.0"},
SimplePkg{"intl", "5.0.0"},
SimplePkg{"intl", "4.0.0"},
SimplePkg{"intl", "3.0.0"},
};
}

View File

@ -113,7 +113,7 @@ TEST_SUITE("ObjPool")
SUBCASE("Iterate over repos")
{
const auto repo_ids = std::array{ repo1_id, repo2_id, repo3_id };
const auto repo_ids = std::array{repo1_id, repo2_id, repo3_id};
SUBCASE("Over all repos")
{
@ -187,7 +187,7 @@ TEST_SUITE("ObjPool")
std::vector<SolvableId> ids = {};
pool.for_each_solvable_id([&](SolvableId id) { ids.push_back(id); });
std::sort(ids.begin(), ids.end()); // Ease comparison
CHECK_EQ(ids, decltype(ids){ id1, id2 });
CHECK_EQ(ids, decltype(ids){id1, id2});
pool.for_each_solvable(
[&](ObjSolvableViewConst s)
{ CHECK_NE(std::find(ids.cbegin(), ids.cend(), s.id()), ids.cend()); }
@ -221,7 +221,7 @@ TEST_SUITE("ObjPool")
std::vector<SolvableId> ids = {};
pool.for_each_installed_solvable_id([&](auto id) { ids.push_back(id); });
std::sort(ids.begin(), ids.end()); // Ease comparsion
CHECK_EQ(ids, decltype(ids){ id1 });
CHECK_EQ(ids, decltype(ids){id1});
}
}
@ -246,7 +246,7 @@ TEST_SUITE("ObjPool")
[&](auto id) { whatprovides_ids.push_back(id); }
);
// Only one solvable matches
CHECK_EQ(whatprovides_ids, std::vector{ id1 });
CHECK_EQ(whatprovides_ids, std::vector{id1});
}
}
}

View File

@ -23,7 +23,7 @@ TEST_SUITE("ObjQueue")
CHECK_EQ(q1.size(), 0);
CHECK(q1.empty());
auto q2 = ObjQueue{ 1, 2, 3 };
auto q2 = ObjQueue{1, 2, 3};
CHECK_EQ(q2.size(), 3);
CHECK_FALSE(q2.empty());
@ -50,7 +50,7 @@ TEST_SUITE("ObjQueue")
const auto q1_data = q1.data();
const auto q1_size = q1.size();
auto q2 = ObjQueue{ 1, 2, 3 };
auto q2 = ObjQueue{1, 2, 3};
const auto q2_size = q2.size();
const auto q2_data = q2.data();
@ -74,7 +74,7 @@ TEST_SUITE("ObjQueue")
TEST_CASE("element")
{
auto q = ObjQueue{ 3, 2, 1 };
auto q = ObjQueue{3, 2, 1};
CHECK_EQ(q[0], 3);
CHECK_EQ(q[1], 2);
CHECK_EQ(q[2], 1);
@ -82,7 +82,7 @@ TEST_SUITE("ObjQueue")
TEST_CASE("at")
{
auto q = ObjQueue{ 3, 2, 1 };
auto q = ObjQueue{3, 2, 1};
CHECK_EQ(q.at(0), q[0]);
CHECK_EQ(q.at(1), q[1]);
CHECK_EQ(q.at(2), q[2]);
@ -91,14 +91,14 @@ TEST_SUITE("ObjQueue")
TEST_CASE("clear")
{
auto q = ObjQueue{ 3, 2, 1 };
auto q = ObjQueue{3, 2, 1};
q.clear();
CHECK(q.empty());
}
TEST_CASE("iterator")
{
const auto q = ObjQueue{ 3, 2, 1 };
const auto q = ObjQueue{3, 2, 1};
std::size_t n = 0;
for ([[maybe_unused]] auto _ : q)
{
@ -107,13 +107,13 @@ TEST_SUITE("ObjQueue")
CHECK_EQ(n, q.size());
const auto l = std::list<::Id>(q.begin(), q.end());
const auto l_expected = std::list{ 3, 2, 1 };
const auto l_expected = std::list{3, 2, 1};
CHECK_EQ(l, l_expected);
}
TEST_CASE("reverse_iterator")
{
const auto q = ObjQueue{ 3, 2, 1 };
const auto q = ObjQueue{3, 2, 1};
const auto v = std::vector(q.crbegin(), q.crend());
CHECK_EQ(v.front(), q.back());
@ -132,7 +132,7 @@ TEST_SUITE("ObjQueue")
{
auto q = ObjQueue();
const auto r1 = std::vector{ 1, 2, 3 };
const auto r1 = std::vector{1, 2, 3};
// std::vector::iterator is not always a pointer
auto iter = q.insert(q.cend(), r1.data(), r1.data() + r1.size());
CHECK_EQ(*iter, q[0]);
@ -140,7 +140,7 @@ TEST_SUITE("ObjQueue")
CHECK_EQ(q[1], 2);
CHECK_EQ(q[2], 3);
const auto r2 = std::vector{ 4, 4 };
const auto r2 = std::vector{4, 4};
iter = q.insert(q.cbegin(), r2.data(), r2.data() + r2.size());
CHECK_EQ(*iter, q[0]);
CHECK_EQ(q[0], 4);
@ -156,14 +156,14 @@ TEST_SUITE("ObjQueue")
{
auto q = ObjQueue();
const auto r1 = std::list{ 1, 2, 3 };
const auto r1 = std::list{1, 2, 3};
auto iter = q.insert(q.cend(), r1.begin(), r1.end());
CHECK_EQ(*iter, q[0]);
CHECK_EQ(q[0], 1);
CHECK_EQ(q[1], 2);
CHECK_EQ(q[2], 3);
const auto r2 = std::list{ 4, 4 };
const auto r2 = std::list{4, 4};
iter = q.insert(q.cbegin(), r2.begin(), r2.end());
CHECK_EQ(*iter, q[0]);
CHECK_EQ(q[0], 4);
@ -177,7 +177,7 @@ TEST_SUITE("ObjQueue")
TEST_CASE("erase")
{
auto q = ObjQueue{ 3, 2, 1 };
auto q = ObjQueue{3, 2, 1};
const auto iter = q.erase(q.cbegin() + 1);
CHECK_EQ(*iter, 1);
CHECK_EQ(q.size(), 2);
@ -195,7 +195,7 @@ TEST_SUITE("ObjQueue")
{
CHECK_EQ(ObjQueue{}, ObjQueue{});
auto q1 = ObjQueue{ 1, 2, 3 };
auto q1 = ObjQueue{1, 2, 3};
CHECK_EQ(q1, q1);
CHECK_NE(q1, ObjQueue{});
@ -208,7 +208,7 @@ TEST_SUITE("ObjQueue")
TEST_CASE("contains")
{
const auto q = ObjQueue{ 1, 9, 3 };
const auto q = ObjQueue{1, 9, 3};
CHECK(q.contains(3));
CHECK_FALSE(q.contains(0));
}

View File

@ -96,7 +96,7 @@ TEST_SUITE("ObjRepo")
{
SUBCASE("Over all solvables")
{
const auto ids = std::array{ id1, id2 };
const auto ids = std::array{id1, id2};
std::size_t n_solvables = 0;
repo.for_each_solvable_id(
[&](SolvableId id)

View File

@ -120,12 +120,12 @@ TEST_SUITE("ObjSolvable")
SUBCASE("Add dependency")
{
solv.add_dependency(33);
CHECK_EQ(solv.dependencies(), ObjQueue{ 33 });
CHECK_EQ(solv.dependencies(), ObjQueue{33});
SUBCASE("Add more dependencies")
{
solv.add_dependencies(ObjQueue{ 44, 22 });
CHECK_EQ(solv.dependencies(), ObjQueue{ 33, 44, 22 });
solv.add_dependencies(ObjQueue{44, 22});
CHECK_EQ(solv.dependencies(), ObjQueue{33, 44, 22});
}
SUBCASE("Reset dependencies")
@ -140,17 +140,17 @@ TEST_SUITE("ObjSolvable")
solv.add_dependency(11, SOLVABLE_PREREQMARKER);
solv.add_dependency(35);
CHECK_EQ(solv.dependencies(-1), ObjQueue{ 33, 34 });
CHECK_EQ(solv.dependencies(0), ObjQueue{ 33, 34, SOLVABLE_PREREQMARKER, 11, 35 });
CHECK_EQ(solv.dependencies(1), ObjQueue{ 11, 35 });
CHECK_EQ(solv.dependencies(SOLVABLE_PREREQMARKER), ObjQueue{ 11, 35 });
CHECK_EQ(solv.dependencies(-1), ObjQueue{33, 34});
CHECK_EQ(solv.dependencies(0), ObjQueue{33, 34, SOLVABLE_PREREQMARKER, 11, 35});
CHECK_EQ(solv.dependencies(1), ObjQueue{11, 35});
CHECK_EQ(solv.dependencies(SOLVABLE_PREREQMARKER), ObjQueue{11, 35});
}
}
SUBCASE("Add provide")
{
solv.add_provide(33);
CHECK_EQ(solv.provides(), ObjQueue{ 33 });
CHECK_EQ(solv.provides(), ObjQueue{33});
SUBCASE("Add self provide")
{
@ -160,8 +160,8 @@ TEST_SUITE("ObjSolvable")
SUBCASE("Add more provides")
{
solv.add_provides(ObjQueue{ 44, 22 });
CHECK_EQ(solv.provides(), ObjQueue{ 33, 44, 22 });
solv.add_provides(ObjQueue{44, 22});
CHECK_EQ(solv.provides(), ObjQueue{33, 44, 22});
}
SUBCASE("Reset provides")
@ -178,38 +178,38 @@ TEST_SUITE("ObjSolvable")
SUBCASE("Internalize and get constraint")
{
repo.internalize();
CHECK_EQ(solv.constraints(), ObjQueue{ 33 });
CHECK_EQ(solv.constraints(), ObjQueue{33});
SUBCASE("Fail to add more constraint")
{
solv.add_constraint(44);
CHECK_EQ(solv.constraints(), ObjQueue{ 33 });
CHECK_EQ(solv.constraints(), ObjQueue{33});
SUBCASE("Override when internalizing again")
{
repo.internalize();
CHECK_EQ(solv.constraints(), ObjQueue{ 44 });
CHECK_EQ(solv.constraints(), ObjQueue{44});
}
}
SUBCASE("Fail to set constraints")
{
solv.set_constraints({ 22 });
CHECK_EQ(solv.constraints(), ObjQueue{ 33 });
solv.set_constraints({22});
CHECK_EQ(solv.constraints(), ObjQueue{33});
SUBCASE("Override when internalizing again")
{
repo.internalize();
CHECK_EQ(solv.constraints(), ObjQueue{ 22 });
CHECK_EQ(solv.constraints(), ObjQueue{22});
}
}
}
SUBCASE("Add more constraints")
{
solv.add_constraints(ObjQueue{ 44, 22 });
solv.add_constraints(ObjQueue{44, 22});
repo.internalize();
CHECK_EQ(solv.constraints(), ObjQueue{ 33, 44, 22 });
CHECK_EQ(solv.constraints(), ObjQueue{33, 44, 22});
}
SUBCASE("Reset constraints")
@ -227,38 +227,38 @@ TEST_SUITE("ObjSolvable")
SUBCASE("Internalize and get tracked features")
{
repo.internalize();
CHECK_EQ(solv.track_features(), ObjQueue{ feat1_id });
CHECK_EQ(solv.track_features(), ObjQueue{feat1_id});
SUBCASE("Fail to track more features")
{
const StringId feat2_id = solv.add_track_feature("feature2");
CHECK_EQ(solv.track_features(), ObjQueue{ feat1_id });
CHECK_EQ(solv.track_features(), ObjQueue{feat1_id});
SUBCASE("Override when internalizing again")
{
repo.internalize();
CHECK_EQ(solv.track_features(), ObjQueue{ feat2_id });
CHECK_EQ(solv.track_features(), ObjQueue{feat2_id});
}
}
SUBCASE("Fail to set tracked features")
{
solv.set_track_features({ 22 });
CHECK_EQ(solv.track_features(), ObjQueue{ feat1_id });
solv.set_track_features({22});
CHECK_EQ(solv.track_features(), ObjQueue{feat1_id});
SUBCASE("Override when internalizing again")
{
repo.internalize();
CHECK_EQ(solv.track_features(), ObjQueue{ 22 });
CHECK_EQ(solv.track_features(), ObjQueue{22});
}
}
}
SUBCASE("Track more features")
{
solv.add_track_features(ObjQueue{ 44, 11 });
solv.add_track_features(ObjQueue{44, 11});
repo.internalize();
CHECK_EQ(solv.track_features(), ObjQueue{ feat1_id, 44, 11 });
CHECK_EQ(solv.track_features(), ObjQueue{feat1_id, 44, 11});
}
SUBCASE("Reset tracked features")

Some files were not shown because too many files have changed in this diff Show More