Sha256: 635c2b43e98c3c846e87333fda8f2b75f8bc71f0b0078798adad17b7ecaa2020

Contents?: true

Size: 1.94 KB

Versions: 15

Compression:

Stored size: 1.94 KB

Contents

# frozen_string_literal: true

module Mutant
  module CLI
    class Command
      class Environment
        class Run < self
          NAME              = 'run'
          SHORT_DESCRIPTION = 'Run code analysis'
          SUBCOMMANDS       = EMPTY_ARRAY

          UNLICENSED = <<~MESSAGE.lines.freeze
            You are using mutant unlicensed.

            See https://github.com/mbj/mutant#licensing to aquire a license.
            Note: Its free for opensource use, which is recommended for trials.
          MESSAGE

          NO_TESTS_MESSAGE = <<~'MESSAGE'
            ===============
            Mutant found no tests available for mutation testing.
            Mutation testing cannot be started.

            This can have various reasons:

            * You did not setup an integration, see:
              https://github.com/mbj/mutant/blob/main/docs/configuration.md#integration
            * You set environment variables like RSPEC_OPTS that filter out all tests.
            * You set configuration optiosn like `config.filter_run :focus` which do
              make rspec to not report any test.
            ===============
          MESSAGE

        private

          def action
            License.call(world)
              .bind { bootstrap }
              .bind(&method(:validate_tests))
              .bind(&Mutation::Runner.public_method(:call))
              .bind(&method(:from_result))
          end

          def validate_tests(environment)
            if environment.integration.available_tests.empty?
              Either::Left.new(NO_TESTS_MESSAGE)
            else
              Either::Right.new(environment)
            end
          end

          def from_result(result)
            if result.success?
              Either::Right.new(nil)
            else
              Either::Left.new('Uncovered mutations detected, exiting nonzero!')
            end
          end
        end # Run
      end # Environment
    end # Command
  end # CLI
end # Mutant

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mutant-0.11.34 lib/mutant/cli/command/environment/run.rb
mutant-0.11.33 lib/mutant/cli/command/environment/run.rb
mutant-0.11.32 lib/mutant/cli/command/environment/run.rb
mutant-0.11.31 lib/mutant/cli/command/environment/run.rb
mutant-0.11.30 lib/mutant/cli/command/environment/run.rb
mutant-0.11.29 lib/mutant/cli/command/environment/run.rb
mutant-0.11.28 lib/mutant/cli/command/environment/run.rb
mutant-0.11.27 lib/mutant/cli/command/environment/run.rb
mutant-0.11.26 lib/mutant/cli/command/environment/run.rb
mutant-0.11.25 lib/mutant/cli/command/environment/run.rb
mutant-0.11.24 lib/mutant/cli/command/environment/run.rb
mutant-0.11.23 lib/mutant/cli/command/environment/run.rb
mutant-0.11.22 lib/mutant/cli/command/environment/run.rb
mutant-0.11.21 lib/mutant/cli/command/environment/run.rb
mutant-0.11.20 lib/mutant/cli/command/environment/run.rb