Skip to content

Commit 0ab6f12

Browse files
committed
wip: test
1 parent e1b1363 commit 0ab6f12

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use super::prelude::*;
2+
3+
#[derive(Clone, Debug, Default)]
4+
pub struct FlagSpy {
5+
pub flags: Arc<AtomicU32>,
6+
}
7+
8+
impl StdCommandWrapper for FlagSpy {
9+
fn pre_spawn(&mut self, command: &mut Command, core: &StdCommandWrap) -> Result<()> {
10+
#[cfg(feature = "creation-flags")]
11+
if let Some(CreationFlags(user_flags)) = core.get_wrap::<CreationFlags>() {
12+
self.flags.set(*user_flags);
13+
}
14+
15+
Ok(())
16+
}
17+
}
18+
19+
#[test]
20+
fn empty_flags_input() -> Result<()> {
21+
let spy = FlagSpy::default();
22+
let _ = StdCommandWrap::with_new("powershell.exe", |command| {
23+
command.arg("/C").arg("echo hello").stdout(Stdio::piped());
24+
})
25+
.wrap(CreationFlags(CREATE_NO_WINDOW))
26+
.wrap(spy.clone())
27+
.spawn()?;
28+
29+
assert_eq!(spy.flags.get(), CREATE_NO_WINDOW);
30+
31+
Ok(())
32+
}

0 commit comments

Comments
 (0)