1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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 🎉
This commit is contained in:
Kir Shatrov 2016-11-15 14:27:16 -05:00
parent 3a558aa2bc
commit 3261470452

View file

@ -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