From 0151238c87d5a5ceba1a164cd0a138a39944ca2c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Fri, 15 Sep 2023 15:50:31 -0300 Subject: [PATCH] make CI faster by decreasing size of tests make fuzzing tests create less files, with half the size and run less test cases should speed up by a magnitude of ~5.0x --- tests/integration.rs | 19 +++++++++++-------- tests/utils.rs | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 47d5703..4b29a19 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -65,22 +65,22 @@ fn create_random_files(dir: impl Into, depth: u8, rng: &mut SmallRng) { let dir = &dir.into(); - // create 0 to 7 random files - for _ in 0..rng.gen_range(0..8u32) { + // create 0 to 4 random files + for _ in 0..rng.gen_range(0..=4u32) { write_random_content( &mut tempfile::Builder::new().tempfile_in(dir).unwrap().keep().unwrap().0, rng, ); } - // create more random files in 0 to 3 new directories - for _ in 0..rng.gen_range(0..4u32) { + // create more random files in 0 to 2 new directories + for _ in 0..rng.gen_range(0..=2u32) { create_random_files(&tempfile::tempdir_in(dir).unwrap().into_path(), depth - 1, rng); } } // compress and decompress a single empty file -#[proptest(cases = 512)] +#[proptest(cases = 200)] fn single_empty_file(ext: Extension, #[any(size_range(0..8).lift())] exts: Vec) { let dir = tempdir().unwrap(); let dir = dir.path(); @@ -99,7 +99,7 @@ fn single_empty_file(ext: Extension, #[any(size_range(0..8).lift())] exts: Vec, @@ -123,10 +123,13 @@ fn single_file( } // compress and decompress a directory with random content generated with create_random_files -#[proptest(cases = 512)] +// +// this one runs only 50 times because there are only `.zip` and `.tar` to be tested, and +// single-file formats testing is done in the other test +#[proptest(cases = 50)] fn multiple_files( ext: DirectoryExtension, - #[any(size_range(0..8).lift())] exts: Vec, + #[any(size_range(0..7).lift())] exts: Vec, #[strategy(0u8..4)] depth: u8, ) { let dir = tempdir().unwrap(); diff --git a/tests/utils.rs b/tests/utils.rs index d1af39a..0e67da9 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -30,7 +30,7 @@ pub fn cargo_bin() -> Command { // write random content to a file pub fn write_random_content(file: &mut impl Write, rng: &mut impl RngCore) { let mut data = Vec::new(); - data.resize(rng.gen_range(0..8192), 0); + data.resize(rng.gen_range(0..4096), 0); rng.fill_bytes(&mut data); file.write_all(&data).unwrap(); } -- 2.11.4.GIT