mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-16 09:08:37 +01:00
149 lines
2.5 KiB
Rust
149 lines
2.5 KiB
Rust
use watchexec_supervisor::command::{Command, Program, Shell};
|
|
|
|
#[tokio::test]
|
|
#[cfg(unix)]
|
|
async fn unix_shell_none() -> Result<(), std::io::Error> {
|
|
assert!(Box::into_pin(
|
|
Command {
|
|
program: Program::Exec {
|
|
prog: "echo".into(),
|
|
args: vec!["hi".into()],
|
|
},
|
|
options: Default::default()
|
|
}
|
|
.to_spawnable()
|
|
.spawn()?
|
|
.wait()
|
|
)
|
|
.await?
|
|
.success());
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
#[cfg(unix)]
|
|
async fn unix_shell_sh() -> Result<(), std::io::Error> {
|
|
assert!(Box::into_pin(
|
|
Command {
|
|
program: Program::Shell {
|
|
shell: Shell::new("sh"),
|
|
command: "echo hi".into(),
|
|
args: Vec::new(),
|
|
},
|
|
options: Default::default()
|
|
}
|
|
.to_spawnable()
|
|
.spawn()?
|
|
.wait()
|
|
)
|
|
.await?
|
|
.success());
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
#[cfg(unix)]
|
|
async fn unix_shell_alternate() -> Result<(), std::io::Error> {
|
|
assert!(Box::into_pin(
|
|
Command {
|
|
program: Program::Shell {
|
|
shell: Shell::new("bash"),
|
|
command: "echo".into(),
|
|
args: vec!["--".into(), "hi".into()],
|
|
},
|
|
options: Default::default()
|
|
}
|
|
.to_spawnable()
|
|
.spawn()?
|
|
.wait()
|
|
)
|
|
.await?
|
|
.success());
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
#[cfg(unix)]
|
|
async fn unix_shell_alternate_shopts() -> Result<(), std::io::Error> {
|
|
assert!(Box::into_pin(
|
|
Command {
|
|
program: Program::Shell {
|
|
shell: Shell {
|
|
options: vec!["-o".into(), "errexit".into()],
|
|
..Shell::new("bash")
|
|
},
|
|
command: "echo hi".into(),
|
|
args: Vec::new(),
|
|
},
|
|
options: Default::default()
|
|
}
|
|
.to_spawnable()
|
|
.spawn()?
|
|
.wait()
|
|
)
|
|
.await?
|
|
.success());
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
#[cfg(windows)]
|
|
async fn windows_shell_none() -> Result<(), std::io::Error> {
|
|
assert!(Box::into_pin(
|
|
Command {
|
|
program: Program::Exec {
|
|
prog: "echo".into(),
|
|
args: vec!["hi".into()],
|
|
},
|
|
options: Default::default()
|
|
}
|
|
.to_spawnable()
|
|
.spawn()?
|
|
.wait()
|
|
)
|
|
.await?
|
|
.success());
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
#[cfg(windows)]
|
|
async fn windows_shell_cmd() -> Result<(), std::io::Error> {
|
|
assert!(Box::into_pin(
|
|
Command {
|
|
program: Program::Shell {
|
|
shell: Shell::cmd(),
|
|
args: Vec::new(),
|
|
command: r#""echo" hi"#.into()
|
|
},
|
|
options: Default::default()
|
|
}
|
|
.to_spawnable()
|
|
.spawn()?
|
|
.wait()
|
|
)
|
|
.await?
|
|
.success());
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
#[cfg(windows)]
|
|
async fn windows_shell_powershell() -> Result<(), std::io::Error> {
|
|
assert!(Box::into_pin(
|
|
Command {
|
|
program: Program::Shell {
|
|
shell: Shell::new("pwsh.exe"),
|
|
args: Vec::new(),
|
|
command: "echo hi".into()
|
|
},
|
|
options: Default::default()
|
|
}
|
|
.to_spawnable()
|
|
.spawn()?
|
|
.wait()
|
|
)
|
|
.await?
|
|
.success());
|
|
Ok(())
|
|
}
|