From 879f701c35699d194890c288a036b0037f6b3424 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Thu, 14 Jan 2010 15:23:57 -0600 Subject: [PATCH] Modifications to get session tests running green under JRuby. --- lib/session.rb | 16 +++++++++++----- test/session.rb | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/session.rb b/lib/session.rb index dffa1f3..824c76f 100755 --- a/lib/session.rb +++ b/lib/session.rb @@ -86,7 +86,9 @@ module Session class << self def default_prog return @default_prog if defined? @default_prog and @default_prog - if defined? self::DEFAULT_PROG + # Workaround for http://jira.codehaus.org/browse/JRUBY-4479 + if (self::DEFAULT_PROG rescue nil) +# if defined? self::DEFAULT_PROG return @default_prog = self::DEFAULT_PROG else @default_prog = ENV["SESSION_#{ self }_PROG"] @@ -150,10 +152,14 @@ module Session @use_spawn = self.class::use_spawn unless self.class::use_spawn.nil? @use_spawn = getopt('use_spawn', opts) if hasopt('use_spawn', opts) - @use_open3 = nil - @use_open3 = Session::use_open3 unless Session::use_open3.nil? - @use_open3 = self.class::use_open3 unless self.class::use_open3.nil? - @use_open3 = getopt('use_open3', opts) if hasopt('use_open3', opts) + if defined? JRUBY_VERSION + @use_open3 = true + else + @use_open3 = nil + @use_open3 = Session::use_open3 unless Session::use_open3.nil? + @use_open3 = self.class::use_open3 unless self.class::use_open3.nil? + @use_open3 = getopt('use_open3', opts) if hasopt('use_open3', opts) + end @debug = nil @debug = Session::debug unless Session::debug.nil? diff --git a/test/session.rb b/test/session.rb index 0b0f265..46fe19b 100644 --- a/test/session.rb +++ b/test/session.rb @@ -17,6 +17,9 @@ Session::debug = true class TimeoutError < StandardError; end def timeout n #{{{ + # JRuby does not support fork, so we stub out timeout here + return yield if defined? JRUBY_VERSION + ret = nil cid = fork unless cid -- 1.6.6