Sha256: 348e5ca741d50a82c2bb31ac8950925b495e862d641be095973bcee987615e7f

Contents?: true

Size: 1.92 KB

Versions: 50

Compression:

Stored size: 1.92 KB

Contents

#
# Helper that tries to find out what test suite is running (for SimpleCov.command_name)
#
module SimpleCov
  module CommandGuesser
    class << self
      # Storage for the original command line call that invoked the test suite.
      # This has got to be stored as early as possible because i.e. rake and test/unit 2
      # have a habit of tampering with ARGV, which makes i.e. the automatic distinction
      # between rails unit/functional/integration tests impossible without this cached
      # item.
      attr_accessor :original_run_command

      def guess
        from_env || from_command_line_options || from_defined_constants
      end

    private

      def from_env
        # If being run from inside parallel_tests set the command name according to the process number
        return unless ENV["PARALLEL_TEST_GROUPS"] && ENV["TEST_ENV_NUMBER"]
        number = ENV["TEST_ENV_NUMBER"]
        number = "1" if number.empty?
        "(#{number}/#{ENV['PARALLEL_TEST_GROUPS']})"
      end

      def from_command_line_options
        case original_run_command
        when /test\/functional\//, /test\/\{.*functional.*\}\//
          "Functional Tests"
        when /test\/integration\//
          "Integration Tests"
        when /test\//
          "Unit Tests"
        when /spec/
          "RSpec"
        when /cucumber/, /features/
          "Cucumber Features"
        end
      end

      def from_defined_constants
        # If the command regexps fail, let's try checking defined constants.
        if defined?(RSpec)
          "RSpec"
        elsif defined?(Test::Unit)
          "Unit Tests"
        elsif defined?(MiniTest)
          "MiniTest"
        else
          # TODO: Provide link to docs/wiki article
          warn "SimpleCov failed to recognize the test framework and/or suite used. Please specify manually using SimpleCov.command_name 'Unit Tests'."
          "Unknown Test Framework"
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 14 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/simplecov-0.13.0/lib/simplecov/command_guesser.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/simplecov-0.13.0/lib/simplecov/command_guesser.rb
tdiary-5.0.9 vendor/bundle/gems/simplecov-0.14.1/lib/simplecov/command_guesser.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/command_guesser.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/command_guesser.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/command_guesser.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/command_guesser.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/simplecov-0.13.0/lib/simplecov/command_guesser.rb
simplecov-0.15.1 lib/simplecov/command_guesser.rb
simplecov-0.15.0 lib/simplecov/command_guesser.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/lib/simplecov/command_guesser.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/lib/simplecov/command_guesser.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/lib/simplecov/command_guesser.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/lib/simplecov/command_guesser.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simplecov-0.14.1/lib/simplecov/command_guesser.rb
simplecov-patched-0.14.3 lib/simplecov/command_guesser.rb
simplecov-patched-0.14.2 lib/simplecov/command_guesser.rb
simplecov-0.14.1 lib/simplecov/command_guesser.rb
simplecov-0.14.0 lib/simplecov/command_guesser.rb
simplecov-0.13.0 lib/simplecov/command_guesser.rb