aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2018-11-19 09:35:55 -0800
committerGitHub <noreply@github.com>2018-11-19 09:35:55 -0800
commit9893998f4a8d3edd64ab0c8efbfb3c385e33befa (patch)
treee5f5f2bb9a112c16c503ca2dce5458f28eb8d8f0
parent317bf45c24e6d78ec5349eadd2683aca7e7fe7e8 (diff)
parent0712dfd6ae1423269af1512c3403ee1145f27de1 (diff)
downloadrails-9893998f4a8d3edd64ab0c8efbfb3c385e33befa.tar.gz
rails-9893998f4a8d3edd64ab0c8efbfb3c385e33befa.tar.bz2
rails-9893998f4a8d3edd64ab0c8efbfb3c385e33befa.zip
Merge pull request #34410 from gmcgibbon/test_support_windows
Windows support for parallelization and instrumenter
-rw-r--r--activesupport/lib/active_support/notifications/instrumenter.rb7
-rw-r--r--activesupport/lib/active_support/testing/parallelization.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt2
3 files changed, 8 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb
index f8344912bb..9184f8f54b 100644
--- a/activesupport/lib/active_support/notifications/instrumenter.rb
+++ b/activesupport/lib/active_support/notifications/instrumenter.rb
@@ -55,6 +55,11 @@ module ActiveSupport
attr_reader :name, :time, :transaction_id, :payload, :children
attr_accessor :end
+ def self.clock_gettime_supported? # :nodoc:
+ defined?(Process::CLOCK_PROCESS_CPUTIME_ID) &&
+ !Gem.win_platform?
+ end
+
def initialize(name, start, ending, transaction_id, payload)
@name = name
@payload = payload.dup
@@ -130,7 +135,7 @@ module ActiveSupport
Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
- if defined?(Process::CLOCK_PROCESS_CPUTIME_ID)
+ if clock_gettime_supported?
def now_cpu
Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID)
end
diff --git a/activesupport/lib/active_support/testing/parallelization.rb b/activesupport/lib/active_support/testing/parallelization.rb
index 24c4f18931..8de01eb19b 100644
--- a/activesupport/lib/active_support/testing/parallelization.rb
+++ b/activesupport/lib/active_support/testing/parallelization.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require "drb"
-require "drb/unix"
+require "drb/unix" unless Gem.win_platform?
require "active_support/core_ext/module/attribute_accessors"
module ActiveSupport
diff --git a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt
index c918b57eca..c06cd525d7 100644
--- a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt
@@ -4,7 +4,7 @@ require 'rails/test_help'
class ActiveSupport::TestCase
# Run tests in parallel with specified workers
-<% if defined?(JRUBY_VERSION) -%>
+<% if defined?(JRUBY_VERSION) || Gem.win_platform? -%>
parallelize(workers: 2, with: :threads)
<%- else -%>
parallelize(workers: 2)