Skip to content

Commit

Permalink
Some changes around Rbx and JRuby
Browse files Browse the repository at this point in the history
Rbx passes all specs, and looks like feature issues are
due to different presentation style of backtrace

JRuby has one failing spec, but gets totally destroyed
in the cukes b/c it's interface to Open3.capture3 is
apparently different (looks like it ultimately delegates
to IO.popen, but haven't tracked that code down yet

This is part of #31
  • Loading branch information
JoshCheek committed Jun 29, 2014
1 parent 04f477f commit b8d39b4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
6 changes: 5 additions & 1 deletion lib/seeing_is_believing/wrap_expressions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ def find_wrappings(ast=root)
range = ast.location.expression

# first two children: target, message, so we want the last child only if it is an argument
target, message, *, last_arg = ast.children
children = ast.children
target = children[0]
message = children[1]
last_arg = children.size > 2 ? children[-1] : nil


# last arg is a heredoc, use the closing paren, or the end of the first line of the heredoc
if heredoc? last_arg
Expand Down
9 changes: 8 additions & 1 deletion spec/evaluate_by_moving_files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ def invoke(program, options={})
end

it 'will set the encoding' do
invoke('print "ç"', encoding: 'u').stdout.should == "ç"
test = -> { invoke('print "ç"', encoding: 'u').stdout.should == "ç" }
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
pending "Rubinius doesn't seem to use -Kx, but rather -U" do
test.call
end
else
test.call
end
end

it 'if it fails, it prints some debugging information and raises an error' do
Expand Down
37 changes: 23 additions & 14 deletions spec/hard_core_ensure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,25 @@ def call(options)
end

it 'invokes the code even if an interrupt is sent and there is a default handler' do
channel = IChannel.new Marshal
pid = fork do
old_handler = trap('INT') { channel.put "old handler invoked" }
call code: -> { sleep 0.1 }, ensure: -> { channel.put "ensure invoked" }
trap 'INT', old_handler
test = lambda do
channel = IChannel.new Marshal
pid = fork do
old_handler = trap('INT') { channel.put "old handler invoked" }
call code: -> { sleep 0.1 }, ensure: -> { channel.put "ensure invoked" }
trap 'INT', old_handler
end
sleep 0.05
Process.kill 'INT', pid
Process.wait pid
channel.get.should == "ensure invoked"
channel.get.should == "old handler invoked"
channel.should_not be_readable
end
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
pending "Skipping this test on jruby b/c the JVM doesn't have a fork"
else
test.call
end
sleep 0.05
Process.kill 'INT', pid
Process.wait pid
channel.get.should == "ensure invoked"
channel.get.should == "old handler invoked"
channel.should_not be_readable
end

it 'invokes the code even if an interrupt is sent and interrupts are set to ignore' do
Expand All @@ -72,10 +79,12 @@ def call(options)
channel.should_not be_readable
end

if RUBY_VERSION == '2.1.1' || RUBY_VERSION == '2.1.2'
pending 'This test can\'t run on 2.1.1 or 2.1.2'
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
pending "Skipping this test on jruby b/c the JVM doesn't have a fork"
elsif (!defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby') && (RUBY_VERSION == '2.1.1' || RUBY_VERSION == '2.1.2')
pending 'This test can\'t run on MRI (2.1.1 or 2.1.2) b/c of bug, see https://github.com/JoshCheek/seeing_is_believing/issues/26'
else
test.call
test.call # e.g. works on Rubinius
end
end
end

0 comments on commit b8d39b4

Please sign in to comment.