diff --git a/Changelog.md b/Changelog.md index 18cb792c3..31c31c047 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,11 @@ +# v0.11.30 2024-03-11 + +* [#1427](https://github.com/mbj/mutant/pull/1427) + + Add integration setup hooks. + * `setup_integration_pre` - called before the test integration setup. + * `setup_integration_post` - called after the test integration setup. + # v0.11.29 2024-03-09 * [#1426](https://github.com/mbj/mutant/pull/1426) diff --git a/Gemfile.lock b/Gemfile.lock index 9f0e23abc..86bfca687 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - mutant (0.11.29) + mutant (0.11.30) diff-lcs (~> 1.3) parser (~> 3.3.0) regexp_parser (~> 2.9.0) diff --git a/lib/mutant/bootstrap.rb b/lib/mutant/bootstrap.rb index 54e2a8a70..1167f7d36 100644 --- a/lib/mutant/bootstrap.rb +++ b/lib/mutant/bootstrap.rb @@ -71,8 +71,12 @@ def self.call_test(env) end end + # rubocop:disable Metrics/MethodLength + # rubocop:disable Style/MultilineBlockChain def self.setup_integration(env:, mutations:, selected_subjects:) env.record(__method__) do + hooks = env.hooks + hooks.run(:setup_integration_pre) Integration.setup(env).fmap do |integration| env.with( integration: integration, @@ -80,10 +84,12 @@ def self.setup_integration(env:, mutations:, selected_subjects:) selector: Selector::Expression.new(integration: integration), subjects: selected_subjects ) - end + end.tap { hooks.run(:setup_integration_post) } end end private_class_method :setup_integration + # rubocop:enable Metrics/MethodLength + # rubocop:enable Style/MultilineBlockChain def self.load_hooks(env) env.record(__method__) do diff --git a/lib/mutant/hooks.rb b/lib/mutant/hooks.rb index 136a9db6f..5d2823d4d 100644 --- a/lib/mutant/hooks.rb +++ b/lib/mutant/hooks.rb @@ -10,6 +10,8 @@ class Hooks mutation_insert_post mutation_insert_pre mutation_worker_process_start + setup_integration_post + setup_integration_pre test_worker_process_start ].product([EMPTY_ARRAY]).to_h.transform_values(&:freeze).freeze diff --git a/lib/mutant/version.rb b/lib/mutant/version.rb index 11371a55d..c0223d25e 100644 --- a/lib/mutant/version.rb +++ b/lib/mutant/version.rb @@ -2,5 +2,5 @@ module Mutant # Current mutant version - VERSION = '0.11.29' + VERSION = '0.11.30' end # Mutant diff --git a/spec/unit/mutant/bootstrap_spec.rb b/spec/unit/mutant/bootstrap_spec.rb index 14d202457..9de9fca47 100644 --- a/spec/unit/mutant/bootstrap_spec.rb +++ b/spec/unit/mutant/bootstrap_spec.rb @@ -187,11 +187,21 @@ def require(_); end arguments: [:setup_integration], reaction: { yields: [] } }, + { + receiver: hooks, + selector: :run, + arguments: [:setup_integration_pre] + }, { receiver: Mutant::Integration, selector: :setup, arguments: [env_with_scopes], reaction: { return: integration_result } + }, + { + receiver: hooks, + selector: :run, + arguments: [:setup_integration_post] } ] end @@ -391,11 +401,21 @@ def apply arguments: [:setup_integration], reaction: { yields: [] } }, + { + receiver: hooks, + selector: :run, + arguments: [:setup_integration_pre] + }, { receiver: Mutant::Integration, selector: :setup, arguments: [env_initial], reaction: { return: integration_result } + }, + { + receiver: hooks, + selector: :run, + arguments: [:setup_integration_post] } ] end diff --git a/test_app/Gemfile.minitest.lock b/test_app/Gemfile.minitest.lock index 5004d54ab..8920b04fa 100644 --- a/test_app/Gemfile.minitest.lock +++ b/test_app/Gemfile.minitest.lock @@ -1,15 +1,15 @@ PATH remote: .. specs: - mutant (0.11.29) + 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-minitest (0.11.29) + mutant-minitest (0.11.30) minitest (~> 5.11) - mutant (= 0.11.29) + mutant (= 0.11.30) GEM remote: https://oss:Px2ENN7S91OmWaD5G7MIQJi1dmtmYrEh@gem.mutant.dev/ diff --git a/test_app/Gemfile.rspec3.8.lock b/test_app/Gemfile.rspec3.8.lock index 8cbc8bd74..e6ae970bd 100644 --- a/test_app/Gemfile.rspec3.8.lock +++ b/test_app/Gemfile.rspec3.8.lock @@ -1,14 +1,14 @@ PATH remote: .. specs: - mutant (0.11.29) + 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.29) - mutant (= 0.11.29) + mutant-rspec (0.11.30) + mutant (= 0.11.30) rspec-core (>= 3.8.0, < 4.0.0) GEM