Sha256: 20673bab048541e1f594a5430e3a87700ce6084fea22ee8026d7a3e92dc4a943

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

module Mutant
  module CLI
    class Command
      class Environment
        class Test < self
          NAME              = 'test'
          SHORT_DESCRIPTION = 'test subcommands'

        private

          def parse_remaining_arguments(arguments)
            arguments.each(&method(:add_integration_argument))
            Either::Right.new(self)
          end

          def bootstrap
            env = Env.empty(world, @config)

            env
              .record(:config) { Config.load(cli_config: @config, world:) }
              .bind { |config| Bootstrap.call_test(env.with(config:)) }
          end

          class List < self
            NAME              = 'list'
            SHORT_DESCRIPTION = 'List tests detected in the environment'
            SUBCOMMANDS       = EMPTY_ARRAY

          private

            def action
              bootstrap.fmap(&method(:list_tests))
            end

            def list_tests(env)
              tests = env.integration.all_tests
              print('All tests in environment: %d' % tests.length)
              tests.each do |test|
                print(test.identification)
              end
            end
          end

          class Run < self
            NAME              = 'run'
            SHORT_DESCRIPTION = 'Run tests'
            SUBCOMMANDS       = EMPTY_ARRAY

          private

            def action
              bootstrap
                .bind(&Mutant::Test::Runner.public_method(:call))
                .bind(&method(:from_result))
            end

            def from_result(result)
              if result.success?
                Either::Right.new(nil)
              else
                Either::Left.new('Test failures, exiting nonzero!')
              end
            end
          end

          SUBCOMMANDS = [List, Run].freeze
        end # Test
      end # Environment
    end # Command
  end # CLI
end # Mutant

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.12.4 lib/mutant/cli/command/environment/test.rb
mutant-0.12.3 lib/mutant/cli/command/environment/test.rb