mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-14 16:35:01 +01:00
Migrate core logic to tree sitter
This commit is contained in:
parent
cb0bad3c9e
commit
c5621b3794
9 changed files with 174 additions and 152 deletions
|
|
@ -101,7 +101,7 @@ pub fn full_tests() -> Result<()> {
|
|||
let path = child.path();
|
||||
|
||||
build(&cargo, &path, ®ression_checker_path)
|
||||
.with_context(|| format!("building {:?}", path.file_name().unwrap()))
|
||||
.with_context(|| format!("test {:?}", path.file_name().unwrap()))
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
} else {
|
||||
|
|
@ -109,7 +109,7 @@ pub fn full_tests() -> Result<()> {
|
|||
let path = child.path();
|
||||
|
||||
build(&cargo, &path, ®ression_checker_path)
|
||||
.with_context(|| format!("building {:?}", path.file_name().unwrap()))?;
|
||||
.with_context(|| format!("test {:?}", path.file_name().unwrap()))?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -159,6 +159,10 @@ fn build(cargo: &Path, path: &Path, regression_checker_path: &Path) -> Result<()
|
|||
.canonicalize()
|
||||
.context("canonicalizing target/debug/cargo-minimize")?;
|
||||
|
||||
if is_ignored(&proj_dir).context("checking whether the test is ignored")? {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let start_roots = get_roots(&proj_dir).context("getting initial MINIMIZE-ROOTs")?;
|
||||
|
||||
let mut cmd = Command::new(cargo_minimize);
|
||||
|
|
@ -209,6 +213,12 @@ fn get_required_deleted(path: &Path) -> Result<Vec<String>> {
|
|||
grep(path, ®EX)
|
||||
}
|
||||
|
||||
fn is_ignored(path: &Path) -> Result<bool> {
|
||||
static REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"~IGNORE").unwrap());
|
||||
|
||||
grep(path, ®EX).map(|v| !v.is_empty())
|
||||
}
|
||||
|
||||
fn grep(path: &Path, regex: &Regex) -> Result<Vec<String>> {
|
||||
let path = path.join("src");
|
||||
let mut results = Vec::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue