From b8d39b4ca15c63f74440c7a6e47c2e5b31729465 Mon Sep 17 00:00:00 2001 From: Josh Cheek Date: Sat, 28 Jun 2014 23:21:20 -0600 Subject: [PATCH] Some changes around Rbx and JRuby 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 --- lib/seeing_is_believing/wrap_expressions.rb | 6 +++- spec/evaluate_by_moving_files_spec.rb | 9 ++++- spec/hard_core_ensure_spec.rb | 37 +++++++++++++-------- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/lib/seeing_is_believing/wrap_expressions.rb b/lib/seeing_is_believing/wrap_expressions.rb index 271883a..b22b578 100644 --- a/lib/seeing_is_believing/wrap_expressions.rb +++ b/lib/seeing_is_believing/wrap_expressions.rb @@ -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 diff --git a/spec/evaluate_by_moving_files_spec.rb b/spec/evaluate_by_moving_files_spec.rb index 7edcc04..e054fe5 100644 --- a/spec/evaluate_by_moving_files_spec.rb +++ b/spec/evaluate_by_moving_files_spec.rb @@ -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 diff --git a/spec/hard_core_ensure_spec.rb b/spec/hard_core_ensure_spec.rb index be677aa..75367c6 100644 --- a/spec/hard_core_ensure_spec.rb +++ b/spec/hard_core_ensure_spec.rb @@ -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 @@ -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