Summary
Deduplicate file paths returned by parse_files so overlapping globs/directories do not execute the same example file multiple times.
Motivation
parse_files currently flattens matched paths without uniqueness filtering. Passing overlapping patterns (for example app plus app/**/*.rb) yields duplicate entries, which causes duplicate YARD parsing and duplicate generated tests.
Concrete example
parse_files(['app', 'app/**/*.rb'])
# => ["app/a.rb", "app/a.rb"]
This can inflate run counts and make failures appear multiple times even though source files are unique.
Current behaviour
files = globs.map do |glob|
glob = "#{glob}/**/*.rb" if File.directory?(glob)
Dir[glob]
end
files.flatten
Proposed solution
Return a de-duplicated list while preserving stable order (first appearance wins), e.g.:
Optionally normalize with File.expand_path before dedupe if mixed relative/absolute globs are expected.
Scope
In scope
- Deduplicate output from
parse_files
- Keep current glob expansion semantics and defaults (
app, lib)
- Add tests for overlapping input patterns
Out of scope
- Changing how defaults are selected
- Recursive file type expansion beyond
*.rb
Implementation notes
- Keep output deterministic for CI and snapshot-friendly tests.
- Preserve behavior for non-overlapping glob input.
- Ensure no regression in feature scenarios that pass explicit file globs.
Acceptance criteria
Related
lib/yard/cli/test_examples.rb — parse_files
lib/yard/cli/test_examples.rb — run
Summary
Deduplicate file paths returned by
parse_filesso overlapping globs/directories do not execute the same example file multiple times.Motivation
parse_filescurrently flattens matched paths without uniqueness filtering. Passing overlapping patterns (for exampleappplusapp/**/*.rb) yields duplicate entries, which causes duplicate YARD parsing and duplicate generated tests.Concrete example
This can inflate run counts and make failures appear multiple times even though source files are unique.
Current behaviour
Proposed solution
Return a de-duplicated list while preserving stable order (first appearance wins), e.g.:
Optionally normalize with
File.expand_pathbefore dedupe if mixed relative/absolute globs are expected.Scope
In scope
parse_filesapp,lib)Out of scope
*.rbImplementation notes
Acceptance criteria
parse_files(['app', 'app/**/*.rb'])returns each matched file onceRelated
lib/yard/cli/test_examples.rb—parse_fileslib/yard/cli/test_examples.rb—run