test_sort: created a new big file for sort

Before, the sort could work faster and we could be late with
the signal.
Now we create a new big file, `sort` can't process it in a minute,
so we can safely wait for the temporary directory to be created
and send a signal afterwards
This commit is contained in:
Niyaz Nigmatullin 2022-09-12 18:32:57 +03:00
parent 95e7b53402
commit ec8e610e48

View file

@ -1117,8 +1117,23 @@ fn test_tmp_files_deleted_on_sigint() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("tmp_dir");
let file_name = "big_file_to_sort.txt";
{
use rand::Rng;
use std::io::Write;
let mut file = at.make_file(file_name);
// approximately 20 MB
for _ in 0..40 {
let lines = rand::thread_rng()
.sample_iter(rand::distributions::uniform::Uniform::new(0, 10007))
.take(100000)
.map(|x| x.to_string() + "\n")
.collect::<String>();
file.write_all(lines.as_bytes()).unwrap();
}
}
ucmd.args(&[
"ext_sort.txt",
file_name,
"--buffer-size=1", // with a small buffer size `sort` will be forced to create a temporary directory very soon.
"--temporary-directory=tmp_dir",
]);