mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
test_sort: make timeout smarter, wait if failed to create dir
Before the change it slept for 0.1 seconds and right after that asserted if `sort` has created the directory. Sometimes `sort` didn't manage to create the directory in 0.1 seconds. So the change is it tries to wait for `timeout` starting with 0.1 seconds, and if directory was not found, it tries 4 more times, each time increasing timeout twice. Once the directory is found it breaks.
This commit is contained in:
parent
513b764434
commit
95e7b53402
1 changed files with 8 additions and 1 deletions
|
@ -1124,7 +1124,14 @@ fn test_tmp_files_deleted_on_sigint() {
|
|||
]);
|
||||
let mut child = ucmd.run_no_wait();
|
||||
// wait a short amount of time so that `sort` can create a temporary directory.
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
let mut timeout = Duration::from_millis(100);
|
||||
for _ in 0..5 {
|
||||
std::thread::sleep(timeout);
|
||||
if read_dir(at.plus("tmp_dir")).unwrap().next().is_some() {
|
||||
break;
|
||||
}
|
||||
timeout *= 2;
|
||||
}
|
||||
// `sort` should have created a temporary directory.
|
||||
assert!(read_dir(at.plus("tmp_dir")).unwrap().next().is_some());
|
||||
// kill sort with SIGINT
|
||||
|
|
Loading…
Reference in a new issue