mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51: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(test)]
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use mktemp::Temp;
|
|
||||||
|
|
||||||
use super::spawn;
|
use super::spawn;
|
||||||
use super::get_longest_common_path;
|
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]
|
#[test]
|
||||||
fn test_start() {
|
fn test_start() {
|
||||||
let _ = spawn("echo hi", vec![]);
|
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]
|
#[test]
|
||||||
fn longest_common_path_should_return_correct_value() {
|
fn longest_common_path_should_return_correct_value() {
|
||||||
let single_path = vec![PathBuf::from("/tmp/random/")];
|
let single_path = vec![PathBuf::from("/tmp/random/")];
|
||||||
|
Loading…
Reference in New Issue
Block a user