Skip to content

Fix filter manager location filtering

gitlab-qa-bot requested to merge fix-filter-manager-location-filtering into master

Created by: myronmarston

This is a follow up to #1839. I realized that with the changes there, if you ran rspec 1_spec.rb:14 2_spec.rb exclusion filters would not be applied to specs in 2_spec.rb because the presence of a location filter disabled all exclusion filters. However, since location filters are contextual to a file and we now allow additional files to be loaded and run, I think we should continue to apply exclusion filters to other files. This fixes that.

The last commit is an optional perf optimization. I noticed that we were doing File.expand_path(metadata[:file_path]) in many locations and thought it would be faster to calculate the absolute file path only once and store it in the metadata hash. My benchmark confirms this is much faster (by an order-of-magnitude) but I do have one concern: doing this requires us to treat :absolute_file_path as a reserved metadata key, which could be a breaking change if there are any users who are using that as a custom metadata key. That seems pretty unlikely though.

What do others think?

/cc @rspec/rspec

Merge request reports