1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tests: Set timeout for tests which would fail with the default timeout in test_factor, test_sort

This commit is contained in:
Joining7943 2022-12-16 01:18:27 +01:00
parent 1d7447d42e
commit 09c04d9f3f
3 changed files with 9 additions and 4 deletions

View file

@ -10,7 +10,7 @@
use crate::common::util::*; use crate::common::util::*;
use std::time::SystemTime; use std::time::{Duration, SystemTime};
#[path = "../../src/uu/factor/sieve.rs"] #[path = "../../src/uu/factor/sieve.rs"]
mod sieve; mod sieve;
@ -35,7 +35,7 @@ fn test_invalid_arg() {
fn test_parallel() { fn test_parallel() {
use hex_literal::hex; use hex_literal::hex;
use sha1::{Digest, Sha1}; use sha1::{Digest, Sha1};
use std::fs::OpenOptions; use std::{fs::OpenOptions, time::Duration};
use tempfile::TempDir; use tempfile::TempDir;
// factor should only flush the buffer at line breaks // factor should only flush the buffer at line breaks
let n_integers = 100_000; let n_integers = 100_000;
@ -55,6 +55,7 @@ fn test_parallel() {
for child in (0..10) for child in (0..10)
.map(|_| { .map(|_| {
new_ucmd!() new_ucmd!()
.timeout(Duration::from_secs(240))
.set_stdout(output.try_clone().unwrap()) .set_stdout(output.try_clone().unwrap())
.pipe_in(input_string.clone()) .pipe_in(input_string.clone())
.run_no_wait() .run_no_wait()
@ -275,6 +276,7 @@ fn run(input_string: &[u8], output_string: &[u8]) {
); );
// now run factor // now run factor
new_ucmd!() new_ucmd!()
.timeout(Duration::from_secs(240))
.pipe_in(input_string) .pipe_in(input_string)
.run() .run()
.stdout_is(String::from_utf8(output_string.to_owned()).unwrap()); .stdout_is(String::from_utf8(output_string.to_owned()).unwrap());

View file

@ -5,6 +5,8 @@
// spell-checker:ignore (words) ints // spell-checker:ignore (words) ints
use std::time::Duration;
use crate::common::util::*; use crate::common::util::*;
fn test_helper(file_name: &str, possible_args: &[&str]) { fn test_helper(file_name: &str, possible_args: &[&str]) {
@ -948,6 +950,7 @@ fn test_compress_fail() {
fn test_merge_batches() { fn test_merge_batches() {
TestScenario::new(util_name!()) TestScenario::new(util_name!())
.ucmd_keepenv() .ucmd_keepenv()
.timeout(Duration::from_secs(120))
.args(&["ext_sort.txt", "-n", "-S", "150b"]) .args(&["ext_sort.txt", "-n", "-S", "150b"])
.succeeds() .succeeds()
.stdout_only_fixture("ext_sort.expected"); .stdout_only_fixture("ext_sort.expected");

View file

@ -1641,8 +1641,8 @@ impl UChild {
format!("wait: Timeout of '{}s' reached", timeout.as_secs_f64()), format!("wait: Timeout of '{}s' reached", timeout.as_secs_f64()),
)), )),
Err(RecvTimeoutError::Disconnected) => { Err(RecvTimeoutError::Disconnected) => {
handle.join().unwrap().unwrap(); handle.join().expect("Panic caused disconnect").unwrap();
panic!("Error receiving from waiting thread because of unexpected disconnect") panic!("Error receiving from waiting thread because of unexpected disconnect");
} }
} }
} else { } else {