Skip to content

Commit

Permalink
Merge pull request mbj#1428 from mbj/improve/rspec-integration
Browse files Browse the repository at this point in the history
Improve rspec integration
  • Loading branch information
mbj authored Mar 14, 2024
2 parents 7d74a37 + 3a26fff commit 381663a
Show file tree
Hide file tree
Showing 19 changed files with 395 additions and 11 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.11.31 2024-03-14

* [#1428](https://github.com/mbj/mutant/pull/1428)

Improve rspec integration. Mutant now properly exits early if rspec cannot load examples.

# v0.11.30 2024-03-11

* [#1427](https://github.com/mbj/mutant/pull/1427)
Expand Down
2 changes: 1 addition & 1 deletion lib/mutant/integration/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def initialize(*)
def setup
@setup_elapsed = timer.elapsed do
@runner.setup(world.stderr, world.stdout)
fail 'Rspec setup failure' if RSpec.world.respond_to?(:rspec_is_quitting) && RSpec.world.rspec_is_quitting
fail 'Rspec setup failure' if @rspec_world.wants_to_quit
example_group_map
end
@runner.configuration.force(color_mode: :on)
Expand Down
4 changes: 2 additions & 2 deletions lib/mutant/parallel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.async(config:, world:)
)
end

# rubocop:disable Metric/MethodLength
# rubocop:disable Metrics/MethodLength
def self.workers(world, config, shared)
Array.new(config.jobs) do |index|
Worker.start(
Expand All @@ -38,7 +38,7 @@ def self.workers(world, config, shared)
end
end
private_class_method :workers
# rubocop:enable Metric/MethodLength
# rubocop:enable Metrics/MethodLength

def self.shared_state(world, config)
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/devloop.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
while inotifywait lib/**/*.rb meta/**/*.rb spec/**/*.rb Gemfile Gemfile.shared mutant.gemspec; do
bundle exec mutant environment test run --fail-fast spec/unit \
bundle exec mutant environment test run --fail-fast spec/unit spec/integration/mutant/rspec_spec.rb \
&& bundle exec mutant run --fail-fast --since main --zombie -- 'Mutant*' \
&& bundle exec rubocop
done
14 changes: 13 additions & 1 deletion spec/integration/mutant/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@
%w[bundle exec mutant run -I lib --require test_app --integration rspec]
end

%w[3.8].each do |version|
%w[3.8 3.9 3.10 3.11 3.12 3.13].each do |version|
context "RSpec #{version}" do
let(:gemfile) { "Gemfile.rspec#{version}" }

it_behaves_like 'framework integration'

it 'handles invalid rspec' do
Dir.chdir('test_app') do
result = Kernel.system(
{ 'BUNDLE_GEMFILE' => gemfile },
*%w[bundle exec mutant environment test run --integration rspec -- --backtrace
spec/unit/test_app/invalid.rb]
)

expect(result).to be(false)
end
end
end
end
end
4 changes: 2 additions & 2 deletions spec/unit/mutant/integration/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
let(:rspec_options) { instance_double(RSpec::Core::ConfigurationOptions) }
let(:rspec_runner) { instance_double(RSpec::Core::Runner) }
let(:world) { fake_world }
let(:rspec_is_quitting) { false }
let(:wants_to_quit) { false }

let(:example_a) do
double(
Expand Down Expand Up @@ -115,7 +115,7 @@
example_groups: example_groups,
filtered_examples: filtered_examples,
ordered_example_groups: ordered_example_groups,
rspec_is_quitting: rspec_is_quitting
wants_to_quit: wants_to_quit
)
end

Expand Down
7 changes: 7 additions & 0 deletions test_app/Gemfile.rspec3.10
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'
gem 'rspec', '~> 3.10'
gem 'rspec-core', '~> 3.10'
gem 'mutant', path: '../'
gem 'mutant-rspec', path: '../'
gem 'adamantium'
eval_gemfile File.expand_path('../../Gemfile.shared', __FILE__)
66 changes: 66 additions & 0 deletions test_app/Gemfile.rspec3.10.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
PATH
remote: ..
specs:
mutant (0.11.30)
diff-lcs (~> 1.3)
parser (~> 3.3.0)
regexp_parser (~> 2.9.0)
sorbet-runtime (~> 0.5.0)
unparser (~> 0.6.9)
mutant-rspec (0.11.30)
mutant (= 0.11.30)
rspec-core (>= 3.8.0, < 4.0.0)

GEM
remote: https://oss:[email protected]/
specs:
mutant-license (0.1.1.2.2355046999240944981729280251890364410689.5)

GEM
remote: https://rubygems.org/
specs:
adamantium (0.2.0)
ice_nine (~> 0.11.0)
memoizable (~> 0.4.0)
ast (2.4.2)
diff-lcs (1.5.1)
ice_nine (0.11.2)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
racc (1.7.3)
regexp_parser (2.9.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
sorbet-runtime (0.5.11292)
thread_safe (0.3.6)
unparser (0.6.13)
diff-lcs (~> 1.3)
parser (>= 3.3.0)

PLATFORMS
x86_64-linux

DEPENDENCIES
adamantium
mutant!
mutant-license!
mutant-rspec!
rspec (~> 3.10)
rspec-core (~> 3.10)

BUNDLED WITH
2.5.6
7 changes: 7 additions & 0 deletions test_app/Gemfile.rspec3.11
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'
gem 'rspec', '~> 3.12'
gem 'rspec-core', '~> 3.12'
gem 'mutant', path: '../'
gem 'mutant-rspec', path: '../'
gem 'adamantium'
eval_gemfile File.expand_path('../../Gemfile.shared', __FILE__)
66 changes: 66 additions & 0 deletions test_app/Gemfile.rspec3.11.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
PATH
remote: ..
specs:
mutant (0.11.30)
diff-lcs (~> 1.3)
parser (~> 3.3.0)
regexp_parser (~> 2.9.0)
sorbet-runtime (~> 0.5.0)
unparser (~> 0.6.9)
mutant-rspec (0.11.30)
mutant (= 0.11.30)
rspec-core (>= 3.8.0, < 4.0.0)

GEM
remote: https://oss:[email protected]/
specs:
mutant-license (0.1.1.2.2355046999240944981729280251890364410689.5)

GEM
remote: https://rubygems.org/
specs:
adamantium (0.2.0)
ice_nine (~> 0.11.0)
memoizable (~> 0.4.0)
ast (2.4.2)
diff-lcs (1.5.1)
ice_nine (0.11.2)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
racc (1.7.3)
regexp_parser (2.9.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
sorbet-runtime (0.5.11292)
thread_safe (0.3.6)
unparser (0.6.13)
diff-lcs (~> 1.3)
parser (>= 3.3.0)

PLATFORMS
x86_64-linux

DEPENDENCIES
adamantium
mutant!
mutant-license!
mutant-rspec!
rspec (~> 3.12)
rspec-core (~> 3.12)

BUNDLED WITH
2.5.6
7 changes: 7 additions & 0 deletions test_app/Gemfile.rspec3.12
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'
gem 'rspec', '~> 3.9'
gem 'rspec-core', '~> 3.9'
gem 'mutant', path: '../'
gem 'mutant-rspec', path: '../'
gem 'adamantium'
eval_gemfile File.expand_path('../../Gemfile.shared', __FILE__)
66 changes: 66 additions & 0 deletions test_app/Gemfile.rspec3.12.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
PATH
remote: ..
specs:
mutant (0.11.30)
diff-lcs (~> 1.3)
parser (~> 3.3.0)
regexp_parser (~> 2.9.0)
sorbet-runtime (~> 0.5.0)
unparser (~> 0.6.9)
mutant-rspec (0.11.30)
mutant (= 0.11.30)
rspec-core (>= 3.8.0, < 4.0.0)

GEM
remote: https://oss:[email protected]/
specs:
mutant-license (0.1.1.2.2355046999240944981729280251890364410689.5)

GEM
remote: https://rubygems.org/
specs:
adamantium (0.2.0)
ice_nine (~> 0.11.0)
memoizable (~> 0.4.0)
ast (2.4.2)
diff-lcs (1.5.1)
ice_nine (0.11.2)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
racc (1.7.3)
regexp_parser (2.9.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
sorbet-runtime (0.5.11292)
thread_safe (0.3.6)
unparser (0.6.13)
diff-lcs (~> 1.3)
parser (>= 3.3.0)

PLATFORMS
x86_64-linux

DEPENDENCIES
adamantium
mutant!
mutant-license!
mutant-rspec!
rspec (~> 3.9)
rspec-core (~> 3.9)

BUNDLED WITH
2.5.6
7 changes: 7 additions & 0 deletions test_app/Gemfile.rspec3.13
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'
gem 'rspec', '~> 3.13'
gem 'rspec-core', '~> 3.13'
gem 'mutant', path: '../'
gem 'mutant-rspec', path: '../'
gem 'adamantium'
eval_gemfile File.expand_path('../../Gemfile.shared', __FILE__)
66 changes: 66 additions & 0 deletions test_app/Gemfile.rspec3.13.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
PATH
remote: ..
specs:
mutant (0.11.30)
diff-lcs (~> 1.3)
parser (~> 3.3.0)
regexp_parser (~> 2.9.0)
sorbet-runtime (~> 0.5.0)
unparser (~> 0.6.9)
mutant-rspec (0.11.30)
mutant (= 0.11.30)
rspec-core (>= 3.8.0, < 4.0.0)

GEM
remote: https://oss:[email protected]/
specs:
mutant-license (0.1.1.2.2355046999240944981729280251890364410689.5)

GEM
remote: https://rubygems.org/
specs:
adamantium (0.2.0)
ice_nine (~> 0.11.0)
memoizable (~> 0.4.0)
ast (2.4.2)
diff-lcs (1.5.1)
ice_nine (0.11.2)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
racc (1.7.3)
regexp_parser (2.9.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
sorbet-runtime (0.5.11292)
thread_safe (0.3.6)
unparser (0.6.13)
diff-lcs (~> 1.3)
parser (>= 3.3.0)

PLATFORMS
x86_64-linux

DEPENDENCIES
adamantium
mutant!
mutant-license!
mutant-rspec!
rspec (~> 3.13)
rspec-core (~> 3.13)

BUNDLED WITH
2.5.6
4 changes: 2 additions & 2 deletions test_app/Gemfile.rspec3.8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
gem 'rspec', '~> 3.8.0'
gem 'rspec-core', '~> 3.8.0'
gem 'rspec', '~> 3.8'
gem 'rspec-core', '~> 3.8'
gem 'mutant', path: '../'
gem 'mutant-rspec', path: '../'
gem 'adamantium'
Expand Down
Loading

0 comments on commit 381663a

Please sign in to comment.