diff --git a/Changelog.md b/Changelog.md index 2627e1d28..461ca98bc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,10 @@ +# v0.11.14 2022-09-05 + +* []() + + Fix to provide a well formed `Mutant::Config::DEFAULT` constant at all times. + Primarily useful for custom 3rd party integrations that use mutants API directly. + # v0.11.14 2022-07-31 * [#1348](https://github.com/mbj/mutant/pull/1348) diff --git a/Gemfile.lock b/Gemfile.lock index 706e6dc8a..fd60beb68 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - mutant (0.11.14) + mutant (0.11.15) diff-lcs (~> 1.3) parser (~> 3.1.0) regexp_parser (~> 2.3, >= 2.3.1) @@ -52,7 +52,7 @@ GEM rubocop-ast (1.16.0) parser (>= 3.1.1.0) ruby-progressbar (1.11.0) - sorbet-runtime (0.5.10206) + sorbet-runtime (0.5.10400) unicode-display_width (2.1.0) unparser (0.6.5) diff-lcs (~> 1.3) diff --git a/lib/mutant.rb b/lib/mutant.rb index 4ecc7a56c..7cd054c34 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -273,7 +273,7 @@ module Mutant # Reopen class to initialize constant to avoid dep circle class Config DEFAULT = new( - coverage_criteria: Config::CoverageCriteria::EMPTY, + coverage_criteria: Config::CoverageCriteria::DEFAULT, expression_parser: Expression::Parser.new([ Expression::Descendants, Expression::Method, diff --git a/lib/mutant/cli/command/environment.rb b/lib/mutant/cli/command/environment.rb index cafc0a9ff..190117359 100644 --- a/lib/mutant/cli/command/environment.rb +++ b/lib/mutant/cli/command/environment.rb @@ -19,7 +19,9 @@ class Environment < self def initialize(attributes) super(attributes) - @config = Config::DEFAULT + @config = Config::DEFAULT.with( + coverage_criteria: Config::CoverageCriteria::EMPTY + ) end def bootstrap @@ -37,7 +39,7 @@ def expand(file_config) ) end - @config = Config.env.merge(file_config).merge(@config).expand_defaults + @config = Config.env.merge(file_config).merge(@config) end def parse_remaining_arguments(arguments) diff --git a/lib/mutant/config.rb b/lib/mutant/config.rb index 41d50d17c..8673935d2 100644 --- a/lib/mutant/config.rb +++ b/lib/mutant/config.rb @@ -98,16 +98,6 @@ def self.load_config_file(env) end end - # Expand config with defaults - # - # @return [Config] - def expand_defaults - with( - coverage_criteria: CoverageCriteria::DEFAULT.merge(coverage_criteria), - jobs: jobs || 1 - ) - end - def self.load_contents(env, path) Transform::Named .new( diff --git a/lib/mutant/version.rb b/lib/mutant/version.rb index ad6d122dd..ab9cb4c4e 100644 --- a/lib/mutant/version.rb +++ b/lib/mutant/version.rb @@ -2,5 +2,5 @@ module Mutant # Current mutant version - VERSION = '0.11.14' + VERSION = '0.11.15' end # Mutant diff --git a/spec/support/shared_context.rb b/spec/support/shared_context.rb index c97b4c75d..42e4dcefe 100644 --- a/spec/support/shared_context.rb +++ b/spec/support/shared_context.rb @@ -104,9 +104,7 @@ def setup_shared_context end let(:config) do - Mutant::Config::DEFAULT.with( - reporter: Mutant::Reporter::Null.new - ).expand_defaults + Mutant::Config::DEFAULT.with(reporter: Mutant::Reporter::Null.new) end let(:subject_a_context) do diff --git a/spec/unit/mutant/cli_spec.rb b/spec/unit/mutant/cli_spec.rb index 2ceadba0f..7bd2fa028 100644 --- a/spec/unit/mutant/cli_spec.rb +++ b/spec/unit/mutant/cli_spec.rb @@ -6,7 +6,6 @@ let(:events) { [] } let(:expected_zombie) { false } let(:kernel) { class_double(Kernel) } - let(:load_config_file_config) { Mutant::Config::DEFAULT } let(:stderr) { instance_double(IO, :stderr, tty?: false) } let(:stdout) { instance_double(IO, :stdout, tty?: false) } let(:timer) { instance_double(Mutant::Timer) } @@ -21,6 +20,12 @@ ) end + let(:load_config_file_config) do + Mutant::Config::DEFAULT.with( + coverage_criteria: Mutant::Config::CoverageCriteria::EMPTY + ) + end + def apply described_class.parse( arguments: Marshal.load(Marshal.dump(arguments)), @@ -548,7 +553,7 @@ def self.main_body shared_context 'environment' do let(:arguments) { %w[run] } - let(:bootstrap_config) { env_config.merge(file_config).expand_defaults } + let(:bootstrap_config) { env_config.merge(file_config) } let(:bootstrap_result) { right(env) } let(:env_result) { instance_double(Mutant::Result::Env, success?: true) } let(:expected_exit) { true } @@ -1154,7 +1159,7 @@ def self.main_body let(:file_config) { Mutant::Config::DEFAULT } context 'without coverage criteria in env or file' do - let(:bootstrap_config) { Mutant::Config::DEFAULT.expand_defaults } + let(:bootstrap_config) { Mutant::Config::DEFAULT } include_examples 'CLI run' end @@ -1168,7 +1173,7 @@ def self.main_body ) end - let(:bootstrap_config) { file_config.expand_defaults } + let(:bootstrap_config) { file_config } include_examples 'CLI run' end diff --git a/spec/unit/mutant/config_spec.rb b/spec/unit/mutant/config_spec.rb index 7affff2f5..9f759fc52 100644 --- a/spec/unit/mutant/config_spec.rb +++ b/spec/unit/mutant/config_spec.rb @@ -1,40 +1,6 @@ # frozen_string_literal: true RSpec.describe Mutant::Config do - describe '#expand_defaults' do - let(:config) do - described_class::DEFAULT.with( - coverage_criteria: described_class::CoverageCriteria::EMPTY.with( - test_result: false - ) - ) - end - - def apply - config.expand_defaults - end - - context 'on empty jobs' do - it 'expands empty jobs' do - expect(apply.jobs).to eql(1) - end - end - - context 'on present jobs' do - let(:config) { super().with(jobs: 2) } - - it 'doesn not expand jobs' do - expect(apply.jobs).to eql(2) - end - end - - it 'expands merges coverage criteria with defaults' do - expect(apply.coverage_criteria).to eql( - described_class::CoverageCriteria::DEFAULT.with(test_result: false) - ) - end - end - describe '#merge' do def apply original.merge(other) diff --git a/spec/unit/mutant/reporter/cli/printer/config_spec.rb b/spec/unit/mutant/reporter/cli/printer/config_spec.rb index 5a9183423..18cfbc429 100644 --- a/spec/unit/mutant/reporter/cli/printer/config_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/config_spec.rb @@ -24,7 +24,7 @@ it_reports(<<~'REPORT') Matcher: # Integration: null - Jobs: 1 + Jobs: auto Includes: [] Requires: [] REPORT @@ -38,7 +38,7 @@ it_reports(<<~'REPORT') Matcher: # Integration: foo - Jobs: 1 + Jobs: auto Includes: [] Requires: [] REPORT @@ -52,7 +52,7 @@ it_reports(<<~'REPORT') Matcher: # Integration: null - Jobs: 1 + Jobs: auto Includes: [] Requires: [] MutationTimeout: 2.1 diff --git a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb index 56b40c7ac..b05a70b65 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb @@ -13,7 +13,7 @@ Mutant environment: Matcher: # Integration: null - Jobs: 1 + Jobs: auto Includes: [] Requires: [] Subjects: 1 @@ -38,7 +38,7 @@ Mutant environment: Matcher: # Integration: null - Jobs: 1 + Jobs: auto Includes: [] Requires: [] Subjects: 1 @@ -65,7 +65,7 @@ Mutant environment: Matcher: # Integration: null - Jobs: 1 + Jobs: auto Includes: [] Requires: [] Subjects: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb index 0143a20a7..8d6ac282a 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb @@ -20,7 +20,7 @@ Mutant environment: Matcher: # Integration: null - Jobs: 1 + Jobs: auto Includes: [] Requires: [] Subjects: 1 diff --git a/spec/unit/mutant/reporter/cli_spec.rb b/spec/unit/mutant/reporter/cli_spec.rb index dc226b1f9..94e76db22 100644 --- a/spec/unit/mutant/reporter/cli_spec.rb +++ b/spec/unit/mutant/reporter/cli_spec.rb @@ -66,7 +66,7 @@ def self.it_reports(expected_content) Mutant environment: Matcher: # Integration: null - Jobs: 1 + Jobs: auto Includes: [] Requires: [] Subjects: 1 @@ -84,7 +84,7 @@ def self.it_reports(expected_content) Mutant environment: Matcher: # Integration: null - Jobs: 1 + Jobs: auto Includes: [] Requires: [] Subjects: 1