DEV: Add --exclude-pattern to bin/turbo_rspec (#32390)

This commit adds a new `--exclude-pattern` CLI option which supports
excluding files using unix style pattern matching.

This is to simplify a couple of situations:

1. Running `bin/turbo_rspec plugin/spec` but we want to exclude all
   tests in the `plugin/spec/system` folder.

   Example: `bin/turbo_rspec --exclude-pattern="*spec/system*"
plugin/spec`

2. Running `bin/turbo_rspec plugin/*/spec/system` but we want to exclude
   tests for a particular plugin.

   Example: `bin/turbo_rspec --exclude-pattern="plugins/chat/*"
plugin/*/spec/system`
This commit is contained in:
Alan Guo Xiang Tan
2025-04-22 11:34:48 +08:00
committed by GitHub
parent 1d7b08f2e1
commit 0252712008
3 changed files with 20 additions and 17 deletions

View File

@ -42,14 +42,6 @@ module TurboTests
).run
end
def self.default_spec_folders
# We do not want to include system specs by default, they are quite slow.
Dir
.entries("#{Rails.root}/spec")
.reject { |entry| !File.directory?("spec/#{entry}") || %w[.. . system].include?(entry) }
.map { |entry| "spec/#{entry}" }
end
def initialize(opts)
@reporter = opts[:reporter]
@files = opts[:files]