Skip to content

Add rubocop_spec_helper to be used by RuboCop specs

Peter Leitzen requested to merge pl-rubocop-spec-helper into master

What does this MR do and why?

Only load RuboCop and its support code if needed. This reduces the load time for fast specs (from ~1.2s down to 0.8s) and normal (which use spec_helper) specs (from 6.8s. down to 6.6s).

All RuboCop related specs now need to require 'rubocop_spec_helper' instead of require 'fast_spec_helper'.

This MR also contains fixes for fast specs where need to require some features (tsort, tmpdir, tempfile etc.) explicitly because it was required by rubocop before.

Contributes to #350700.

How to set up and validate locally

Fast specs

# On this branch, list of files to use fast spec helper.
# Note that all rubocop latest spec are missing. We are testing them separately below.
files=$(rg "^require .fast_spec_helper"  -l | rg -v 'rubocop_spec_helper' | sort)

for i in $files; do; bin/rspec --order defined --format progress $i >> log-branch.txt; done


# On this branch, list of files to use fast spec helper
files=$(rg "^require .fast_spec_helper"  -l | rg -v 'rubocop_spec_helper' | sort)

# Now, switch back to master.
git checkout master

for i in $files; do; bin/rspec --order defined --format progress $i >> log-master.txt; done

# Now diff, ignoring common timing changes from the RSpec summary line.

diff -IFinished -u log-master.txt log-branch.txt
# No changes so no functional changes (less or more failures/errors)

So changes into terms of functionality. Some fast specs are failing but they were failing before. This will be fixed in a follow-up.

RuboCop specs

# On this branch
files=$(rg "^require .rubocop_spec_helper"  -l | sort)

for i in $files; do bin/rspec --order defined --format progress $i || break; done
...

# All specs pass.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports

Loading