test_file_finder: Use named captures and file patterns
What does this MR do and why?
Using named captures makes mappings more readable. Using file patterns makes source definitions more concise.
See also !147027 (comment 1813282875).
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to verify locally
- Run
scripts/verify-tff-mapping
✅ - Save this script as
foo.rb
(🤷 ):
# frozen_string_literal: true
require "test_file_finder"
mapping_file = 'tests.yml'
strategy = TestFileFinder::MappingStrategies::PatternMatching.load(mapping_file)
def test_file(file, strategy)
tff = TestFileFinder::FileFinder.new(paths: [file])
tff.use strategy
tff.test_files
end
`git ls-files -z`.split("\0").sort.each do |file|
mappings = test_file(file, strategy)
p file => mappings
end
- Run
bundle && ruby foo.rb > after
to collect mappings for all checked files for the new version - Run
gem uninstall test_file_finder -v 0.3.0
to revertbundle install
- Run
git checkout master -- tests.yml
to reverttests.yml
changes (named captures are now gone) - Run
ruby foo.rb > before
to collect mappings for all checked files for the old version - Run
diff -u before after
to see no changes🤞 - Run
git reset --hard && bundle
to install latest version again
Edited by Peter Leitzen