Skip to content

Commit

Permalink
Merge pull request #1427 from mbj/add/test-setup-hooks
Browse files Browse the repository at this point in the history
Add hooks setup_integration_{pre,post}
  • Loading branch information
mbj authored Mar 11, 2024
2 parents fa6d66a + b06847f commit 7d74a37
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 7 additions & 1 deletion lib/mutant/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,25 @@ 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,
mutations: mutations,
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
Expand Down
2 changes: 2 additions & 0 deletions lib/mutant/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/mutant/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module Mutant
# Current mutant version
VERSION = '0.11.29'
VERSION = '0.11.30'
end # Mutant
20 changes: 20 additions & 0 deletions spec/unit/mutant/bootstrap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test_app/Gemfile.minitest.lock
Original file line number Diff line number Diff line change
@@ -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:[email protected]/
Expand Down
6 changes: 3 additions & 3 deletions test_app/Gemfile.rspec3.8.lock
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 7d74a37

Please sign in to comment.