aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorKir Shatrov <shatrov@me.com>2016-11-15 14:27:16 -0500
committerKir Shatrov <shatrov@me.com>2016-11-15 15:56:32 -0500
commit326147045262c49d0389c5a275570cb913a1a03b (patch)
tree107afc590b2a6422fc9971c00c9b179a3d23bb3c /activesupport
parent3a558aa2bc8ce3834ee79ff3346bcf5d7debbbd0 (diff)
downloadrails-326147045262c49d0389c5a275570cb913a1a03b.tar.gz
rails-326147045262c49d0389c5a275570cb913a1a03b.tar.bz2
rails-326147045262c49d0389c5a275570cb913a1a03b.zip
Fix testing isolation
AS::Testing::Isolation has two ways to isolate the process: forking and subprocessing. The second way is used on JRuby and other platforms that don't support forking. The way how subprocessing works is that we prepare a command to run a new process: ``` /opt/rubies/2.3.0/bin/ruby -I{skipped_load_path} test/initializable_test.rb '' -nInitializableTests::Basic#test_Initializer_provides_context's_class_name ``` As you see, there's unescaped quote at the end of the line. It leads to: ``` sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file ``` This fixes tests on MRI + NO_FORK variable and on JRuby :tada:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/testing/isolation.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb
index d30b34ecd6..404efe50bf 100644
--- a/activesupport/lib/active_support/testing/isolation.rb
+++ b/activesupport/lib/active_support/testing/isolation.rb
@@ -2,6 +2,7 @@ module ActiveSupport
module Testing
module Isolation
require "thread"
+ require "shellwords"
def self.included(klass) #:nodoc:
klass.class_eval do
@@ -80,7 +81,7 @@ module ActiveSupport
load_paths = $-I.map { |p| "-I\"#{File.expand_path(p)}\"" }.join(" ")
orig_args = ORIG_ARGV.join(" ")
- test_opts = "-n#{self.class.name}##{self.name}"
+ test_opts = "-n#{self.class.name}##{Shellwords.escape(self.name)}"
command = "#{Gem.ruby} #{load_paths} #{$0} '#{orig_args}' #{test_opts}"
# IO.popen lets us pass env in a cross-platform way