mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-28 22:21:33 +02:00
Remove kill/wait tests as process handling is async now
This commit is contained in:
parent
dddc1e8886
commit
6b7351d45b
@ -281,53 +281,16 @@ fn get_longest_common_path(paths: &[PathBuf]) -> Option<String> {
|
||||
#[cfg(test)]
|
||||
#[cfg(target_family = "unix")]
|
||||
mod tests {
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use mktemp::Temp;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::spawn;
|
||||
use super::get_longest_common_path;
|
||||
|
||||
fn file_contents(path: &Path) -> String {
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
let mut f = File::open(path).unwrap();
|
||||
let mut s = String::new();
|
||||
f.read_to_string(&mut s).unwrap();
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_start() {
|
||||
let _ = spawn("echo hi", vec![]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_wait() {
|
||||
let file = Temp::new_file().unwrap();
|
||||
let path = file.to_path_buf();
|
||||
let process = spawn(&format!("echo hi > {}", path.to_str().unwrap()), vec![]);
|
||||
process.wait();
|
||||
|
||||
assert!(file_contents(&path).starts_with("hi"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_kill() {
|
||||
let file = Temp::new_file().unwrap();
|
||||
let path = file.to_path_buf();
|
||||
|
||||
let process = spawn(&format!("sleep 20; echo hi > {}", path.to_str().unwrap()),
|
||||
vec![]);
|
||||
process.kill();
|
||||
process.wait();
|
||||
|
||||
assert!(file_contents(&path) == "");
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn longest_common_path_should_return_correct_value() {
|
||||
let single_path = vec![PathBuf::from("/tmp/random/")];
|
||||
|
Loading…
Reference in New Issue
Block a user