diff --git a/lib/mutant/cli/command.rb b/lib/mutant/cli/command.rb index 1b4647082..6ae277158 100644 --- a/lib/mutant/cli/command.rb +++ b/lib/mutant/cli/command.rb @@ -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 diff --git a/lib/mutant/cli/command/environment.rb b/lib/mutant/cli/command/environment.rb index 2d08458cc..2da5bb25e 100644 --- a/lib/mutant/cli/command/environment.rb +++ b/lib/mutant/cli/command/environment.rb @@ -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:') diff --git a/spec/unit/mutant/cli_spec.rb b/spec/unit/mutant/cli_spec.rb index 88b11c673..90ce4cf31 100644 --- a/spec/unit/mutant/cli_spec.rb +++ b/spec/unit/mutant/cli_spec.rb @@ -555,6 +555,38 @@ def self.main_body } end + make do + message = <<~MESSAGE + usage: mutant environment [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"] }