Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make CI faster by decreasing size of tests #514

Merged
merged 2 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ fn create_random_files(dir: impl Into<PathBuf>, 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<FileExtension>) {
let dir = tempdir().unwrap();
let dir = dir.path();
Expand All @@ -99,7 +99,7 @@ fn single_empty_file(ext: Extension, #[any(size_range(0..8).lift())] exts: Vec<F
}

// compress and decompress a single file
#[proptest(cases = 512)]
#[proptest(cases = 250)]
fn single_file(
ext: Extension,
#[any(size_range(0..8).lift())] exts: Vec<FileExtension>,
Expand All @@ -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<FileExtension>,
#[any(size_range(0..5).lift())] exts: Vec<FileExtension>,
#[strategy(0u8..4)] depth: u8,
) {
let dir = tempdir().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down