Sha256: 445ae2b099339ef08913de2c5ebe51a294a75f6316f7400ca3e9fa36879e14b4

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module Mutant

  # Abstract base class mutant test framework integrations
  class Integration
    include AbstractType, Adamantium::Flat, Concord.new(:config)

    # Setup integration
    #
    # Integrations are supposed to define a constant under
    # Mutant::Integration named after the capitalized +name+
    # parameter.
    #
    # This avoids having to maintain a mutable registry.
    #
    # @param kernel [Kernel]
    # @param name [String]
    #
    # @return [Class<Integration>]
    def self.setup(kernel, name)
      kernel.require("mutant/integration/#{name}")
      const_get(name.capitalize)
    end

    # Perform integration setup
    #
    # @return [self]
    def setup
      self
    end

    # Run a collection of tests
    #
    # @param [Enumerable<Test>] tests
    #
    # @return [Result::Test]
    abstract_method :call

    # Available tests for integration
    #
    # @return [Enumerable<Test>]
    abstract_method :all_tests

  private

    # Expression parser
    #
    # @return [Expression::Parser]
    def expression_parser
      config.expression_parser
    end

    # Null integration that never kills a mutation
    class Null < self

      # Available tests for integration
      #
      # @return [Enumerable<Test>]
      def all_tests
        EMPTY_ARRAY
      end

      # Run a collection of tests
      #
      # @param [Enumerable<Mutant::Test>] tests
      #
      # @return [Result::Test]
      def call(tests)
        Result::Test.new(
          output:  '',
          passed:  true,
          runtime: 0.0,
          tests:   tests
        )
      end

    end # Null
  end # Integration
end # Mutant

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutant-0.8.24 lib/mutant/integration.rb
mutant-0.8.23 lib/mutant/integration.rb
mutant-0.8.22 lib/mutant/integration.rb
mutant-0.8.21 lib/mutant/integration.rb
mutant-0.8.20 lib/mutant/integration.rb
mutant-0.8.19 lib/mutant/integration.rb
mutant-0.8.18 lib/mutant/integration.rb
mutant-0.8.17 lib/mutant/integration.rb