diff --git a/Changelog.md b/Changelog.md index 31c31c047..74cb5af85 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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) diff --git a/lib/mutant/integration/rspec.rb b/lib/mutant/integration/rspec.rb index a0ebac61d..662bf2b3b 100644 --- a/lib/mutant/integration/rspec.rb +++ b/lib/mutant/integration/rspec.rb @@ -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) diff --git a/scripts/devloop.sh b/scripts/devloop.sh index 48c839274..5176252b5 100755 --- a/scripts/devloop.sh +++ b/scripts/devloop.sh @@ -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 diff --git a/spec/integration/mutant/rspec_spec.rb b/spec/integration/mutant/rspec_spec.rb index 7567debc5..7544bffb5 100644 --- a/spec/integration/mutant/rspec_spec.rb +++ b/spec/integration/mutant/rspec_spec.rb @@ -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 diff --git a/spec/unit/mutant/integration/rspec_spec.rb b/spec/unit/mutant/integration/rspec_spec.rb index 71adf77e3..77d1d58e4 100644 --- a/spec/unit/mutant/integration/rspec_spec.rb +++ b/spec/unit/mutant/integration/rspec_spec.rb @@ -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( @@ -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 diff --git a/test_app/Gemfile.rspec3.10 b/test_app/Gemfile.rspec3.10 new file mode 100644 index 000000000..dc6203184 --- /dev/null +++ b/test_app/Gemfile.rspec3.10 @@ -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__) diff --git a/test_app/Gemfile.rspec3.10.lock b/test_app/Gemfile.rspec3.10.lock new file mode 100644 index 000000000..382ef128e --- /dev/null +++ b/test_app/Gemfile.rspec3.10.lock @@ -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:Px2ENN7S91OmWaD5G7MIQJi1dmtmYrEh@gem.mutant.dev/ + 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 diff --git a/test_app/Gemfile.rspec3.11 b/test_app/Gemfile.rspec3.11 new file mode 100644 index 000000000..db6b5a6ad --- /dev/null +++ b/test_app/Gemfile.rspec3.11 @@ -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__) diff --git a/test_app/Gemfile.rspec3.11.lock b/test_app/Gemfile.rspec3.11.lock new file mode 100644 index 000000000..59c5dfe66 --- /dev/null +++ b/test_app/Gemfile.rspec3.11.lock @@ -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:Px2ENN7S91OmWaD5G7MIQJi1dmtmYrEh@gem.mutant.dev/ + 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 diff --git a/test_app/Gemfile.rspec3.12 b/test_app/Gemfile.rspec3.12 new file mode 100644 index 000000000..1b036a979 --- /dev/null +++ b/test_app/Gemfile.rspec3.12 @@ -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__) diff --git a/test_app/Gemfile.rspec3.12.lock b/test_app/Gemfile.rspec3.12.lock new file mode 100644 index 000000000..d3983207b --- /dev/null +++ b/test_app/Gemfile.rspec3.12.lock @@ -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:Px2ENN7S91OmWaD5G7MIQJi1dmtmYrEh@gem.mutant.dev/ + 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 diff --git a/test_app/Gemfile.rspec3.13 b/test_app/Gemfile.rspec3.13 new file mode 100644 index 000000000..b7f29f010 --- /dev/null +++ b/test_app/Gemfile.rspec3.13 @@ -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__) diff --git a/test_app/Gemfile.rspec3.13.lock b/test_app/Gemfile.rspec3.13.lock new file mode 100644 index 000000000..a97d1a5b8 --- /dev/null +++ b/test_app/Gemfile.rspec3.13.lock @@ -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:Px2ENN7S91OmWaD5G7MIQJi1dmtmYrEh@gem.mutant.dev/ + 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 diff --git a/test_app/Gemfile.rspec3.8 b/test_app/Gemfile.rspec3.8 index 85bee6240..71b933c34 100644 --- a/test_app/Gemfile.rspec3.8 +++ b/test_app/Gemfile.rspec3.8 @@ -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' diff --git a/test_app/Gemfile.rspec3.8.lock b/test_app/Gemfile.rspec3.8.lock index e6ae970bd..395897bcc 100644 --- a/test_app/Gemfile.rspec3.8.lock +++ b/test_app/Gemfile.rspec3.8.lock @@ -59,8 +59,8 @@ DEPENDENCIES mutant! mutant-license! mutant-rspec! - rspec (~> 3.8.0) - rspec-core (~> 3.8.0) + rspec (~> 3.8) + rspec-core (~> 3.8) BUNDLED WITH 2.4.2 diff --git a/test_app/Gemfile.rspec3.9 b/test_app/Gemfile.rspec3.9 new file mode 100644 index 000000000..1b036a979 --- /dev/null +++ b/test_app/Gemfile.rspec3.9 @@ -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__) diff --git a/test_app/Gemfile.rspec3.9.lock b/test_app/Gemfile.rspec3.9.lock new file mode 100644 index 000000000..d3983207b --- /dev/null +++ b/test_app/Gemfile.rspec3.9.lock @@ -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:Px2ENN7S91OmWaD5G7MIQJi1dmtmYrEh@gem.mutant.dev/ + 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 diff --git a/test_app/spec/unit/test_app/invalid.rb b/test_app/spec/unit/test_app/invalid.rb new file mode 100644 index 000000000..9dae856c3 --- /dev/null +++ b/test_app/spec/unit/test_app/invalid.rb @@ -0,0 +1 @@ +fail