toptal / crystalball

Regression Test Selection library for your RSpec test suite
https://toptal.github.io/crystalball/
MIT License
322 stars 41 forks source link

Create flexible map generation filtering logic #118

Open pirj opened 5 years ago

pirj commented 5 years ago

Currently we have filtering logic literally hardcoded here: lib/crystalball/map_generator/helpers/path_filter.rb.

We need it to be a bit more flexible so we can specify a list of directories\files to filter out of profiling data.

Common use case: bundle install --standalone installs everything to vendor => falls into the data.

Expected configuration:

Crystalball::MapGenerator.start!(exclude_sources: [/\.gems/, /vendor/], exclude_specs: [/features/]) do
  # ...
end

it should exclude all sources containing .gems or vendor in paths and it should exclude the data for all spec files including features in paths

rodrigovilina commented 3 years ago

Is no one working on this? Perhaps I can give it a try! Is the proposed example the way I should approach it :ok_hand: ?

edit: Looking at the code I think it would be cleaner to implement this at the strategy level, so only PathFilter and the strategies are modified. If I attempt to do it from the generator itself, I have to pass the arguments thru the MapGenerator::Configuration and then write the attribute into the strategies inside the MapGenerator::Configuration#register method.

edit: I'll put up a PR implementing just how the example looks with comments on how I think it could be simpler if it is done right at the strategies level. Also this provides further granularity.