pub struct MockPredicateEnv {
pub platform: Platform,
pub env: BTreeMap<String, String>,
pub commands: BTreeSet<String>,
pub files: BTreeSet<PathBuf>,
pub resolver: Resolver,
}Expand description
Test double for PredicateEnv.
Build an instance, populate the public fields, and pass a reference to
eval. All lookups are pure in-memory — the host filesystem, PATH, and
environment are never consulted.
Fields§
§platform: PlatformPlatform reported to platform: predicates.
env: BTreeMap<String, String>Env vars available to env: predicates.
commands: BTreeSet<String>Commands that are considered to exist for command_exists: predicates.
files: BTreeSet<PathBuf>Paths that are considered to exist for file_exists: predicates.
resolver: ResolverResolver used to expand ${VAR} tokens in file_exists: paths.
Implementations§
Trait Implementations§
Source§impl PredicateEnv for MockPredicateEnv
impl PredicateEnv for MockPredicateEnv
Source§fn platform(&self) -> Platform
fn platform(&self) -> Platform
The platform to match
platform:linux / platform:macos /
platform:windows against.Source§fn env(&self, var: &str) -> Option<String>
fn env(&self, var: &str) -> Option<String>
Look up an environment variable. Returns
None when the variable is
not set (as opposed to set-but-empty, which returns Some("")).Source§fn command_exists(&self, name: &str) -> bool
fn command_exists(&self, name: &str) -> bool
Returns
true when name is found on PATH.Source§fn file_exists(&self, path: &Path) -> bool
fn file_exists(&self, path: &Path) -> bool
Returns
true when path exists on the filesystem.Auto Trait Implementations§
impl Freeze for MockPredicateEnv
impl RefUnwindSafe for MockPredicateEnv
impl Send for MockPredicateEnv
impl Sync for MockPredicateEnv
impl Unpin for MockPredicateEnv
impl UnsafeUnpin for MockPredicateEnv
impl UnwindSafe for MockPredicateEnv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more