Sha256: 7053a9cf86c7719e3c5354327aec7c21664bdf0d3608a0f005f01c8ab19b259e

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require 'parallel'
require 'parallel_tests/version'
require 'parallel_tests/grouper'

module ParallelTests
  def self.determine_number_of_processes(count)
    [
      count,
      ENV['PARALLEL_TEST_PROCESSORS'],
      Parallel.processor_count
    ].detect{|c| not c.to_s.strip.empty? }.to_i
  end

  # parallel:spec[:count, :pattern, :options]
  def self.parse_rake_args(args)
    # order as given by user
    args = [args[:count], args[:pattern], args[:options]]

    # count given or empty ?
    # parallel:spec[2,models,options]
    # parallel:spec[,models,options]
    count = args.shift if args.first.to_s =~ /^\d*$/
    num_processes = count.to_i unless count.to_s.empty?
    pattern = args.shift
    options = args.shift

    [num_processes, pattern.to_s, options.to_s]
  end

  # copied from http://github.com/carlhuda/bundler Bundler::SharedHelpers#find_gemfile
  def self.bundler_enabled?
    return true if Object.const_defined?(:Bundler)

    previous = nil
    current = File.expand_path(Dir.pwd)

    until !File.directory?(current) || current == previous
      filename = File.join(current, "Gemfile")
      return true if File.exists?(filename)
      current, previous = File.expand_path("..", current), current
    end

    false
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parallel_tests-0.7.0.alpha2 lib/parallel_tests.rb
parallel_tests-0.7.0.alpha lib/parallel_tests.rb