use std::ffi::OsString;
use derive_more::AsRef;
use gungraun_macros::IntoInner;
use gungraun_runner::api::ValgrindTool;
use crate::__internal;
#[derive(Debug, Default, IntoInner, AsRef, Clone)]
pub struct LibraryBenchmarkConfig(__internal::InternalLibraryBenchmarkConfig);
impl LibraryBenchmarkConfig {
pub fn default_tool(&mut self, tool: ValgrindTool) -> &mut Self {
self.0.default_tool = Some(tool);
self
}
pub fn valgrind_args<I, T>(&mut self, args: T) -> &mut Self
where
I: AsRef<str>,
T: IntoIterator<Item = I>,
{
self.0.valgrind_args.extend_ignore_flag(args);
self
}
pub fn env_clear(&mut self, value: bool) -> &mut Self {
self.0.env_clear = Some(value);
self
}
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Self
where
K: Into<OsString>,
V: Into<OsString>,
{
self.0.envs.push((key.into(), Some(value.into())));
self
}
pub fn envs<K, V, T>(&mut self, envs: T) -> &mut Self
where
K: Into<OsString>,
V: Into<OsString>,
T: IntoIterator<Item = (K, V)>,
{
self.0
.envs
.extend(envs.into_iter().map(|(k, v)| (k.into(), Some(v.into()))));
self
}
pub fn pass_through_env<K>(&mut self, key: K) -> &mut Self
where
K: Into<OsString>,
{
self.0.envs.push((key.into(), None));
self
}
pub fn pass_through_envs<K, T>(&mut self, envs: T) -> &mut Self
where
K: Into<OsString>,
T: IntoIterator<Item = K>,
{
self.0
.envs
.extend(envs.into_iter().map(|k| (k.into(), None)));
self
}
pub fn tool<T>(&mut self, tool: T) -> &mut Self
where
T: Into<__internal::InternalTool>,
{
self.0.tools.update(tool.into());
self
}
pub fn tool_override<T>(&mut self, tool: T) -> &mut Self
where
T: Into<__internal::InternalTool>,
{
self.0
.tools_override
.get_or_insert_with(__internal::InternalTools::default)
.update(tool.into());
self
}
pub fn output_format<T>(&mut self, output_format: T) -> &mut Self
where
T: Into<__internal::InternalOutputFormat>,
{
self.0.output_format = Some(output_format.into());
self
}
}