Skip to content

Commit

Permalink
Fix environment subcommand taking options that where ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj committed Feb 1, 2024
1 parent bb6e362 commit ae53a1a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/mutant/cli/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,17 @@ def parser
add_global_options(parser)
add_subcommands(parser)

self.class::OPTIONS.each do |method_name|
effective_options.each do |method_name|
2.times { parser.separator(nil) }
__send__(method_name, parser)
end
end
end

def effective_options
self.class::OPTIONS
end

def capture_main(&block)
@main = block
end
Expand Down
4 changes: 4 additions & 0 deletions lib/mutant/cli/command/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def add_matcher(attribute, value)
set(matcher: @config.matcher.add(attribute, value))
end

def effective_options
instance_of?(Environment) ? EMPTY_ARRAY : super()
end

# rubocop:disable Metrics/MethodLength
def add_environment_options(parser)
parser.separator('Environment:')
Expand Down
32 changes: 32 additions & 0 deletions spec/unit/mutant/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,38 @@ def self.main_body
}
end

make do
message = <<~MESSAGE
usage: mutant environment <subject|show|irb|test> [options]
Summary: Environment subcommands
mutant version: #{Mutant::VERSION}
Global Options:
--help Print help
--version Print mutants version
--profile Profile mutant execution
--zombie Run mutant zombified
Available subcommands:
subject - Subject subcommands
show - Display environment without coverage analysis
irb - Run irb with mutant environment loaded
test - test subcommands
MESSAGE

{
arguments: %w[environment --help],
expected_events: [[:stdout, :puts, message]],
expected_exit: true,
expected_print_profile: false,
expected_zombie: false
}
end

context 'pathname with null bytes' do
let(:arguments) { %w[util mutation] + ["\0"] }

Expand Down

0 comments on commit ae53a1a

Please sign in to comment.