DEV: Make load order consistent for `rake plugin:spec` (#16076)

`Dir.glob` doesn't guarantee any particular order for results. However, it does appear to be consistent on a given machine. This means that specs can consistently pass on one machine while consistently failing on another. This can lead to some very confusing situations!

This commit sorts the spec files alphabetically so that load order is consistent across environments.

Note that the order in which tests are **run** is not affected by this change. Run order is still randomized by RSpec
This commit is contained in:
David Taylor 2022-03-01 17:46:47 +00:00 committed by GitHub
parent fd8388776e
commit 9415ec91a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -182,7 +182,7 @@ task 'plugin:spec', :plugin do |t, args|
args.with_defaults(plugin: "*")
params = ENV['RSPEC_FAILFAST'] ? '--profile --fail-fast' : '--profile'
ruby = `which ruby`.strip
files = Dir.glob("./plugins/#{args[:plugin]}/spec/**/*_spec.rb")
files = Dir.glob("./plugins/#{args[:plugin]}/spec/**/*_spec.rb").sort
if files.length > 0
sh "LOAD_PLUGINS=1 #{ruby} -S rspec #{files.join(' ')} #{params}"
else