From 9415ec91a1a972b08b3b3bf698d2b652f076057f Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 1 Mar 2022 17:46:47 +0000 Subject: [PATCH] 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 --- lib/tasks/plugin.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/plugin.rake b/lib/tasks/plugin.rake index 9e575e99f7b..25c881de160 100644 --- a/lib/tasks/plugin.rake +++ b/lib/tasks/plugin.rake @@ -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