Sha256: 2ec5d2b826611cef74e7faf87d79435d7abb931b7237adfa4d781593ffc01434
Contents?: true
Size: 1.94 KB
Versions: 3
Compression:
Stored size: 1.94 KB
Contents
require "rubygems" require "parallel" require "parallel_tests/railtie" if defined? Rails::Railtie require "rbconfig" module ParallelTests WINDOWS = (RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) GREP_PROCESSES_COMMAND = \ if WINDOWS "wmic process get commandline | findstr TEST_ENV_NUMBER 2>&1" else "ps -ef | grep [T]EST_ENV_NUMBER= 2>&1" end autoload :CLI, "parallel_tests/cli" autoload :VERSION, "parallel_tests/version" autoload :Grouper, "parallel_tests/grouper" class << self def determine_number_of_processes(count) [ count, ENV["PARALLEL_TEST_PROCESSORS"], Parallel.processor_count ].detect{|c| not c.to_s.strip.empty? }.to_i end # copied from http://github.com/carlhuda/bundler Bundler::SharedHelpers#find_gemfile def 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 def first_process? !ENV["TEST_ENV_NUMBER"] || ENV["TEST_ENV_NUMBER"].to_i == 0 end def wait_for_other_processes_to_finish return unless ENV["TEST_ENV_NUMBER"] sleep 1 until number_of_running_processes <= 1 end # Fun fact: this includes the current process if it's run via parallel_tests def number_of_running_processes result = `#{GREP_PROCESSES_COMMAND}` raise "Could not grep for processes -> #{result}" if result.strip != "" && !$?.success? result.split("\n").size end # real time even if someone messed with timecop in tests def now if Time.respond_to?(:now_without_mock_time) # Timecop Time.now_without_mock_time else Time.now end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
parallel_tests-0.16.15 | lib/parallel_tests.rb |
parallel_tests-0.16.14 | lib/parallel_tests.rb |
parallel_tests-0.16.13 | lib/parallel_tests.rb |