Skip to content

test_file_finder: Use named captures and file patterns

Peter Leitzen requested to merge pl-tff-named-captures into master

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

  1. Run scripts/verify-tff-mapping
  2. 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
  1. Run bundle && ruby foo.rb > after to collect mappings for all checked files for the new version
  2. Run gem uninstall test_file_finder -v 0.3.0 to revert bundle install
  3. Run git checkout master -- tests.yml to revert tests.yml changes (named captures are now gone)
  4. Run ruby foo.rb > before to collect mappings for all checked files for the old version
  5. Run diff -u before after to see no changes 🤞
  6. Run git reset --hard && bundle to install latest version again
Edited by Peter Leitzen

Merge request reports