From ec8e610e48e156a9d42de97629c8dffc375223c0 Mon Sep 17 00:00:00 2001 From: Niyaz Nigmatullin Date: Mon, 12 Sep 2022 18:32:57 +0300 Subject: [PATCH] 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 --- tests/by-util/test_sort.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index e0bfb6025..cb0aa2683 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -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::(); + 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", ]);