Skip to content

Commit 6d6abba

Browse files
committed
No need for this helper without in-process spawn
1 parent f16bb3c commit 6d6abba

4 files changed

Lines changed: 26 additions & 53 deletions

File tree

test/jruby/test_command_line_switches.rb

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,16 @@ def test_dash_0_splits_records
1616
end if IS_JAR_EXECUTION
1717

1818
def test_dash_little_c_checks_syntax
19-
with_jruby_shell_spawning do
20-
with_temp_script("bad : code") do |s|
21-
assert_match(/SyntaxError/, jruby("-c #{s.path} 2>&1"))
22-
assert_not_equal 0, $?.exitstatus
23-
end
19+
with_temp_script("bad : code") do |s|
20+
assert_match(/SyntaxError/, jruby("-c #{s.path} 2>&1"))
21+
assert_not_equal 0, $?.exitstatus
2422
end
2523
end
2624

2725
def test_dash_little_c_checks_syntax_only
28-
with_jruby_shell_spawning do
29-
with_temp_script(%q{ puts "a" }) do |s|
30-
assert_match(/Syntax OK/, jruby(" -c #{s.path} 2>&1").chomp)
31-
assert_equal 0, $?.exitstatus
32-
end
26+
with_temp_script(%q{ puts "a" }) do |s|
27+
assert_match(/Syntax OK/, jruby(" -c #{s.path} 2>&1").chomp)
28+
assert_equal 0, $?.exitstatus
3329
end
3430
end
3531

@@ -158,20 +154,16 @@ def test_dash_big_C_error
158154
end
159155

160156
def test_dash_little_w_turns_warnings_on
161-
with_jruby_shell_spawning do
162-
assert_match(/warning/, `#{RUBY} -v -e "defined? true" 2>&1`)
163-
assert_equal 0, $?.exitstatus
164-
end
157+
assert_match(/warning/, `#{RUBY} -v -e "defined? true" 2>&1`)
158+
assert_equal 0, $?.exitstatus
165159
end
166160

167161
def test_dash_big_w_sets_warning_level
168-
with_jruby_shell_spawning do
169-
with_temp_script("defined? true") do |s|
170-
assert_equal "", jruby("-W1 #{s.path} 2>&1")
171-
assert_equal 0, $?.exitstatus
172-
assert_match(/warning/, jruby("-W2 #{s.path} 2>&1"))
173-
assert_equal 0, $?.exitstatus
174-
end
162+
with_temp_script("defined? true") do |s|
163+
assert_equal "", jruby("-W1 #{s.path} 2>&1")
164+
assert_equal 0, $?.exitstatus
165+
assert_match(/warning/, jruby("-W2 #{s.path} 2>&1"))
166+
assert_equal 0, $?.exitstatus
175167
end
176168
end
177169

@@ -259,11 +251,9 @@ def test_with_interesting_file_names
259251
/test__/, /test_U_D/, /_P_U_S_D/]
260252

261253
names.each_with_index do |name, idx|
262-
with_jruby_shell_spawning do
263-
with_temp_script('print __FILE__', name) do |s|
264-
assert_match rgxes[idx], jruby("#{s.path}")
265-
assert_equal 0, $?.exitstatus
266-
end
254+
with_temp_script('print __FILE__', name) do |s|
255+
assert_match rgxes[idx], jruby("#{s.path}")
256+
assert_equal 0, $?.exitstatus
267257
end
268258
end
269259
end
@@ -281,21 +271,17 @@ def test_blank_arg_ends_arg_processing
281271
# JRUBY-4288
282272
def test_case_insensitive_jruby
283273
weird_jruby = '"' + File.join([RbConfig::CONFIG['bindir'], 'jRuBy']) << RbConfig::CONFIG['EXEEXT'] + '"'
284-
with_jruby_shell_spawning do
285-
res = `cmd.exe /c #{weird_jruby} -e "puts 1"`.rstrip
286-
assert_equal '1', res
287-
assert_equal 0, $?.exitstatus
288-
end
274+
res = `cmd.exe /c #{weird_jruby} -e "puts 1"`.rstrip
275+
assert_equal '1', res
276+
assert_equal 0, $?.exitstatus
289277
end if WINDOWS
290278

291279
# JRUBY-4289
292280
def test_uppercase_exe
293281
weird_jruby = '"' + File.join([RbConfig::CONFIG['bindir'], 'jRuBy']) << '.ExE' + '"'
294-
with_jruby_shell_spawning do
295-
res = `#{weird_jruby} -e "puts 1"`.rstrip
296-
assert_equal '1', res
297-
assert_equal 0, $?.exitstatus
298-
end
282+
res = `#{weird_jruby} -e "puts 1"`.rstrip
283+
assert_equal '1', res
284+
assert_equal 0, $?.exitstatus
299285
end if WINDOWS
300286

301287
# JRUBY-4290

test/jruby/test_helper.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def jruby(*args)
7979
args = args[0..-2]
8080
end
8181
options.each { |k,v| args.unshift "-J-D#{k}=\"#{v}\"" } unless RUBY =~ /-cp /
82-
with_jruby_shell_spawning { sh "#{interpreter(options)} #{args.join(' ')}" }
82+
sh "#{interpreter(options)} #{args.join(' ')}"
8383
end
8484

8585
def jruby(*args)
@@ -98,7 +98,7 @@ def jruby_with_pipe(pipe, *args)
9898
args = args[0..-2]
9999
end
100100
options.each { |k,v| args.unshift "-J-D#{k}=\"#{v}\"" } unless RUBY =~ /-cp /
101-
with_jruby_shell_spawning { sh "#{pipe} | #{interpreter(options)} #{args.join(' ')}" }
101+
sh "#{pipe} | #{interpreter(options)} #{args.join(' ')}"
102102
end
103103

104104
def sh(cmd)
@@ -108,14 +108,6 @@ def sh(cmd)
108108

109109
private
110110

111-
def with_jruby_shell_spawning
112-
prev_in_process = JRuby.runtime.instance_config.run_ruby_in_process
113-
JRuby.runtime.instance_config.run_ruby_in_process = false
114-
yield
115-
ensure
116-
JRuby.runtime.instance_config.run_ruby_in_process = prev_in_process
117-
end
118-
119111
def quiet(&block)
120112
io = [STDOUT.dup, STDERR.dup]
121113
STDOUT.reopen DEVNULL

test/jruby/test_load.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,8 @@ def test_load_from_jar_with_symlink_in_path
264264
begin
265265
Dir.mkdir 'not_A' unless File.exist? 'not_A'
266266
File.symlink("not_A", "A") unless File.symlink?('A')
267-
with_jruby_shell_spawning do
268-
`bin/jruby -e "load File.join('file:', File.join(File.expand_path(File.dirname(File.dirname('#{__FILE__}'))), 'jruby/requireTest-1.0.jar!'), 'A', 'B.rb') ; B"`
269-
assert_equal 0, $?
270-
end
267+
`bin/jruby -e "load File.join('file:', File.join(File.expand_path(File.dirname(File.dirname('#{__FILE__}'))), 'jruby/requireTest-1.0.jar!'), 'A', 'B.rb') ; B"`
268+
assert_equal 0, $?
271269
ensure
272270
File.delete("A") if File.symlink?('A')
273271
Dir.rmdir 'not_A' if File.exist? 'not_A'

test/jruby/test_load_compiled_ruby_class_from_classpath.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ def setup
2929

3030
# This line means we assume the test is running from the jruby root directory
3131
@jruby_home = Dir.pwd
32-
@in_process = JRuby.runtime.instance_config.run_ruby_in_process
33-
JRuby.runtime.instance_config.run_ruby_in_process = false
3432
end
3533

3634
def teardown
3735
remove_test_artifacts
3836
ENV["CLASSPATH"] = @@ENV_CLASSPATH
39-
JRuby.runtime.instance_config.run_ruby_in_process = @in_process
4037
end
4138

4239
def test_loading_compiled_ruby_class_from_classpath

0 commit comments

Comments
 (0)