From 9a974bb5da13c280fe548cfe792a8dab6adecd48 Mon Sep 17 00:00:00 2001 From: Freddie Ridell Date: Thu, 5 Mar 2026 21:16:05 +0000 Subject: [PATCH] rename FilesIter to TwigsIter --- TODO.md | 41 ------------------------------ TODO.spec-issues.md | 27 ++++++++++++++++++++ crates/bough-core/SPEC.md | 12 ++++----- crates/bough-core/src/base.rs | 16 ++++++------ crates/bough-core/src/file.rs | 10 ++++---- crates/bough-core/src/mutant.rs | 14 +++++----- crates/bough-core/src/mutation.rs | 4 +-- crates/bough-core/src/workspace.rs | 6 ++--- 8 files changed, 58 insertions(+), 72 deletions(-) delete mode 100644 TODO.md create mode 100644 TODO.spec-issues.md diff --git a/TODO.md b/TODO.md deleted file mode 100644 index aaeb304c..00000000 --- a/TODO.md +++ /dev/null @@ -1,41 +0,0 @@ -## Multi lang config - -should be like - -```toml -[language.js] #must be tree-sitter id -files.include = [ "**/*.js", "**/*.jsx", ] -files.exclude = [ "**/*__mocks__*" ] -mutants.skip = [ - "((fn 'describe') @ignore)", - { "BinaryOp" = "Add" } -] - -[language.rust] #must be tree-sitter id -files.include = [ "**/*.rs", ] -mutants.skip = [ - "((#[cfg(test)]) @ignore)", - { "BinaryOp" = "Div" } -] -``` - -## Break appart commands - -```toml -[vitest.test] -pwd = "./examples/vitest" -timeout.absolute = 30 -timeout.relative = 3 -commands = [ - "npx run build", - "npx run test" -] - -[cargo.test] -pwd = "./examples/cargo" -timeout.absolute = 30 -timeout.relative = 3 -commands = [ - "cargo test", -] -``` diff --git a/TODO.spec-issues.md b/TODO.spec-issues.md new file mode 100644 index 00000000..2c7d3bb9 --- /dev/null +++ b/TODO.spec-issues.md @@ -0,0 +1,27 @@ +# Spec Issues to Resolve + +## Return types + +### `base.mutants` / `base.mutations` +Spec says `Base::mutants(language_id: &LanguageId) -> MutantsIter` but `MutantsIter` is per-file (holds single `&Twig`). `Base::mutants` needs to iterate across all files for a language. + +Options: +- a) Return `impl Iterator>` — simple, but doesn't match spec signature +- b) Rework `MutantsIter` to support multiple twigs — changes existing type +- c) Create a new `BaseMutantsIter` wrapper — matches spirit but not letter of spec + +Same issue applies to `Base::mutations` / `MutationIter`. + +## Skip config + +### `mutant.iter.skip.kind` / `mutant.iter.skip.kind.multiple` +Where does the skip config live? Options: +- a) Additional params to `MutantsIter::new()` +- b) Builder pattern on `MutantsIter` +- c) Config struct passed in + +### `mutant.iter.skip.query` / `mutant.iter.skip.query.multiple` +"ts lisp-style query" — assumed to be tree-sitter S-expression queries. Clarify: +- Does the query match against the mutant's own node? +- Or against the mutant's parent/ancestor context? +- How does it interact with the tree — do we need to retain the parsed tree in `MutantsIter` (currently discarded after `walk_tree`)? diff --git a/crates/bough-core/SPEC.md b/crates/bough-core/SPEC.md index 84fb6b68..042131e6 100644 --- a/crates/bough-core/SPEC.md +++ b/crates/bough-core/SPEC.md @@ -18,13 +18,13 @@ core[file.transplant] `File::transplant(&self, root: &Root) -> Self` replace root core[file.files.config] -FilesIter holds a ref to FileSourceConfig +TwigsIter holds a ref to FileSourceConfig core[file.files.root] -FilesIter holds a ref to a Root +TwigsIter holds a ref to a Root core[file.files.iter] -FilesIter iterates Twigs +TwigsIter iterates Twigs core[file.files.iter.include] A file should be included if it matches any of the include globs @@ -41,10 +41,10 @@ core[base.root] Base impls Root core[base.files] -Base::files -> FilesIter +Base::files -> TwigsIter core[base.mutant_files] -Base::mutant_files(language_id: &LanguageId) -> FilesIter +Base::mutant_files(language_id: &LanguageId) -> TwigsIter core[base.mutants] Base::mutants(language_id: &LanguageId) -> MutantsIter @@ -61,7 +61,7 @@ core[workspace.base] Workspace holds &Base core[workspace.files] -Workspace::files -> FilesIter +Workspace::files -> TwigsIter core[workspace.is-handle] Workspace struct exists as a handle for a directory diff --git a/crates/bough-core/src/base.rs b/crates/bough-core/src/base.rs index 8a2c1a11..91c4d77a 100644 --- a/crates/bough-core/src/base.rs +++ b/crates/bough-core/src/base.rs @@ -1,5 +1,5 @@ use crate::LanguageId; -use crate::file::{Error, FilesIter, Root, Twig}; +use crate::file::{Error, TwigsIter, Root, Twig}; use std::collections::HashMap; use std::path::{Path, PathBuf}; @@ -7,14 +7,14 @@ use std::path::{Path, PathBuf}; #[derive(Debug, Clone, PartialEq)] pub struct Base { root: PathBuf, - files: FilesIter, - mutant_files: HashMap, + files: TwigsIter, + mutant_files: HashMap, } impl Base { pub fn new( root: PathBuf, - files: FilesIter, + files: TwigsIter, ) -> Result { crate::file::validate_root(&root)?; Ok(Self { @@ -24,7 +24,7 @@ impl Base { }) } - pub fn add_mutator(&mut self, language_id: LanguageId, files: FilesIter) { + pub fn add_mutator(&mut self, language_id: LanguageId, files: TwigsIter) { self.mutant_files.insert(language_id, files); } @@ -52,10 +52,10 @@ impl Root for Base { mod tests { use super::*; - use crate::file::FilesIter; + use crate::file::TwigsIter; - fn files_for(root: &Path, include: &[String]) -> FilesIter { - FilesIter::new(root, include, &[], &[]) + fn files_for(root: &Path, include: &[String]) -> TwigsIter { + TwigsIter::new(root, include, &[], &[]) } // core[verify base.root] diff --git a/crates/bough-core/src/file.rs b/crates/bough-core/src/file.rs index 8b0b0dce..7e3cfcb6 100644 --- a/crates/bough-core/src/file.rs +++ b/crates/bough-core/src/file.rs @@ -98,11 +98,11 @@ pub(crate) fn validate_root(path: &PathBuf) -> Result<(), Error> { // core[impl file.files.root] // core[impl file.files.iter] #[derive(Debug, Clone, PartialEq)] -pub struct FilesIter { +pub struct TwigsIter { twigs: Vec, } -impl FilesIter { +impl TwigsIter { pub fn new( root: &Path, include: &[String], @@ -179,7 +179,7 @@ impl FilesIter { } } -impl IntoIterator for FilesIter { +impl IntoIterator for TwigsIter { type Item = Twig; type IntoIter = std::vec::IntoIter; @@ -216,7 +216,7 @@ mod tests { let dir = tempfile::tempdir().unwrap(); std::fs::write(dir.path().join("a.txt"), "content").unwrap(); let root = TestRoot::new(dir.path()); - let twigs: Vec<_> = FilesIter::new(root.path(), &["*.txt".into()], &[], &[]).into_iter().collect(); + let twigs: Vec<_> = TwigsIter::new(root.path(), &["*.txt".into()], &[], &[]).into_iter().collect(); assert_eq!(twigs.len(), 1); assert_eq!(twigs[0].path(), Path::new("a.txt")); } @@ -313,7 +313,7 @@ mod tests { } fn sorted_twigs(root: &TestRoot, include: &[String], exclude: &[String], ignore_files: &[PathBuf]) -> Vec { - let mut twigs: Vec = FilesIter::new(root.path(), include, exclude, ignore_files) + let mut twigs: Vec = TwigsIter::new(root.path(), include, exclude, ignore_files) .into_iter() .map(|t| t.path().to_path_buf()) .collect(); diff --git a/crates/bough-core/src/mutant.rs b/crates/bough-core/src/mutant.rs index 0b43f2ce..87399145 100644 --- a/crates/bough-core/src/mutant.rs +++ b/crates/bough-core/src/mutant.rs @@ -256,7 +256,7 @@ pub(crate) fn span_from_node(node: &tree_sitter::Node<'_>) -> Span { mod tests { use super::*; use crate::base::Base; - use crate::file::{FilesIter, Root}; + use crate::file::{TwigsIter, Root}; use std::path::PathBuf; fn make_base() -> (tempfile::TempDir, Base) { @@ -269,7 +269,7 @@ mod tests { std::fs::write(dir.path().join("src/a.js"), content).unwrap(); let base = Base::new( dir.path().to_path_buf(), - FilesIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), + TwigsIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), ) .unwrap(); (dir, base) @@ -561,7 +561,7 @@ mod tests { std::fs::write(dir1.path().join("src/a.js"), "const a = 1;").unwrap(); let base1 = Base::new( dir1.path().to_path_buf(), - FilesIter::new(dir1.path(), &["src/**/*.js".into()], &[], &[]), + TwigsIter::new(dir1.path(), &["src/**/*.js".into()], &[], &[]), ) .unwrap(); @@ -570,7 +570,7 @@ mod tests { std::fs::write(dir2.path().join("src/a.js"), "const a = 1;").unwrap(); let base2 = Base::new( dir2.path().to_path_buf(), - FilesIter::new(dir2.path(), &["src/**/*.js".into()], &[], &[]), + TwigsIter::new(dir2.path(), &["src/**/*.js".into()], &[], &[]), ) .unwrap(); @@ -623,7 +623,7 @@ mod tests { std::fs::write(dir.path().join("src/b.js"), "const a = 1;").unwrap(); let base = Base::new( dir.path().to_path_buf(), - FilesIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), + TwigsIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), ) .unwrap(); let twig_a = Twig::new(PathBuf::from("src/a.js")).unwrap(); @@ -653,7 +653,7 @@ mod tests { std::fs::write(dir1.path().join("src/a.js"), "const a = 1;").unwrap(); let base1 = Base::new( dir1.path().to_path_buf(), - FilesIter::new(dir1.path(), &["src/**/*.js".into()], &[], &[]), + TwigsIter::new(dir1.path(), &["src/**/*.js".into()], &[], &[]), ) .unwrap(); @@ -662,7 +662,7 @@ mod tests { std::fs::write(dir2.path().join("src/a.js"), "const b = 2;").unwrap(); let base2 = Base::new( dir2.path().to_path_buf(), - FilesIter::new(dir2.path(), &["src/**/*.js".into()], &[], &[]), + TwigsIter::new(dir2.path(), &["src/**/*.js".into()], &[], &[]), ) .unwrap(); diff --git a/crates/bough-core/src/mutation.rs b/crates/bough-core/src/mutation.rs index 1a93633a..c8bcb913 100644 --- a/crates/bough-core/src/mutation.rs +++ b/crates/bough-core/src/mutation.rs @@ -76,7 +76,7 @@ impl HashInto for Mutation<'_> { mod tests { use super::*; use crate::base::Base; - use crate::file::{FilesIter, Twig}; + use crate::file::{TwigsIter, Twig}; use crate::mutant::{BinaryOpMutationKind, MutantKind, Point, Span}; use bough_typed_hash::HashStore; use std::path::PathBuf; @@ -91,7 +91,7 @@ mod tests { std::fs::write(dir.path().join("src/a.js"), content).unwrap(); let base = Base::new( dir.path().to_path_buf(), - FilesIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), + TwigsIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), ) .unwrap(); (dir, base) diff --git a/crates/bough-core/src/workspace.rs b/crates/bough-core/src/workspace.rs index 47725311..ceeee21e 100644 --- a/crates/bough-core/src/workspace.rs +++ b/crates/bough-core/src/workspace.rs @@ -241,7 +241,7 @@ impl Root for Workspace<'_> { #[cfg(test)] mod tests { use super::*; - use crate::file::FilesIter; + use crate::file::TwigsIter; fn make_base() -> (tempfile::TempDir, Base) { let dir = tempfile::tempdir().unwrap(); @@ -250,7 +250,7 @@ mod tests { std::fs::write(dir.path().join("src/b.js"), "const b = 2;").unwrap(); let base = Base::new( dir.path().to_path_buf(), - FilesIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), + TwigsIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), ) .unwrap(); (dir, base) @@ -418,7 +418,7 @@ mod tests { std::fs::write(dir.path().join("src/a.js"), content).unwrap(); let base = Base::new( dir.path().to_path_buf(), - FilesIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), + TwigsIter::new(dir.path(), &["src/**/*.js".into()], &[], &[]), ) .unwrap(); (dir, base) -- knotmirror 0.0.1