Skip to content

Commit

Permalink
splice: suffle file vec before
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Dec 27, 2023
1 parent f0d18d6 commit b87323b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/fuzz_tree_splicer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub(crate) fn splice_file_from_set(

// such files will most likely just causes known crashes or hang the splicing
pub(crate) fn ignore_file_for_splicing(file: &PathBuf) -> bool {
const LINE_LIMIT: usize = 300; // was 1000
const LINE_LIMIT: usize = 400; // was 1000

let content = std::fs::read_to_string(file).unwrap_or_default();
let lines_count = content.lines().count();
Expand Down
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ use clap::Parser;
use colored::Colorize;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use rand::seq::SliceRandom;
use rand::thread_rng;
use rayon::prelude::*;
use regex::Regex;
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -132,7 +134,7 @@ fn check_dir(
Err(e) => {
// this can happen if we for example change the representation of Ice so that that the previous file is no longer compatible with the new format
eprintln!("Failed to parse errors.json, is it a json file?");
eprintln!("origina error: '{e:?}'");
eprintln!("original error: '{e:?}'");
Vec::new()
}
}
Expand Down Expand Up @@ -2500,14 +2502,17 @@ fn codegen_tree_splicer() {

let root_path = std::env::current_dir().expect("no cwd!");

let files = WalkDir::new(root_path)
let mut files = WalkDir::new(root_path)
.into_iter()
.filter_map(|e| e.ok())
.filter(|f| f.path().extension() == Some(OsStr::new("rs")))
.map(|f| f.path().to_owned())
.filter(|pb| !ignore_file_for_splicing(pb))
.collect::<Vec<PathBuf>>();

// shuffle the vec
files.shuffle(&mut thread_rng());

// dir to put the files in
std::fs::create_dir("icemaker").expect("could not create icemaker dir");

Expand Down

0 comments on commit b87323b

Please sign in to comment.