Author: pburba Date: Wed Jun 12 17:21:02 2013 New Revision: 1492295 URL: http://svn.apache.org/r1492295 Log: Follow-up to r1480412: Unbreak the Ruby binding tests with out-of-tree builds.
See http://svn.haxx.se/dev/archive-2013-06/0134.shtml * subversion/bindings/swig/ruby/test/util.rb (util.rb): Adjust requirement of ../svn/util.rb so it works with Ruby 1.8 or 1.9 and when the CWD is not the parent of the required file. Modified: subversion/trunk/subversion/bindings/swig/ruby/test/util.rb Modified: subversion/trunk/subversion/bindings/swig/ruby/test/util.rb URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/ruby/test/util.rb?rev=1492295&r1=1492294&r2=1492295&view=diff ============================================================================== --- subversion/trunk/subversion/bindings/swig/ruby/test/util.rb (original) +++ subversion/trunk/subversion/bindings/swig/ruby/test/util.rb Wed Jun 12 17:21:02 2013 @@ -19,7 +19,41 @@ require "fileutils" require "pathname" -require "./svn/util" + +# Tale of a hack... +# +# Here we are, %SVN-WC-ROOT%/subversion/bindings/swig/ruby/test/util.rb, +# trying to require %SVN-WC-ROOT%/subversion/bindings/swig/ruby/svn/util.rb, +# all the while supporting both Ruby 1.8 and 1.9. Simply using this, +# +# require "svn/util" +# +# works for Ruby 1.8 if the CWD is subversion/bindings/swig/ruby +# when we are running the tests, e.g.: +# +# %SVN-WC-ROOT%/subversion/bindings/swig/ruby>ruby test\run-test.rb +# +# This is because the CWD is included in the load path when Ruby 1.8 +# searches for required files. But this doesn't work for Ruby 1.9, +# which doesn't include the CWD this way, so instead we could use this: +# +# require "./svn/util" +# +# But that only works if ./svn/util is relative to the CWD (again if the +# CWD is %SVN-WC-ROOT%/subversion/bindings/swig/ruby). However, if we run +# the tests from a different CWD and specify +# %SVN-WC-ROOT%/subversion/bindings/swig/ruby as an additional $LOAD_PATH +# using the ruby -I option, then that fails on both 1.8 and 1.9 with a +# LoadError. +# +# The usual solution in a case like this is to use require_relative, +# +# require_relative "../svn/util" +# +# But that's only available in Ruby 1.9. We could require the backports gem +# but there is a simple workaround, just calculate the full path of util: +require File.join(File.dirname(__FILE__), '../svn/util') + require "tmpdir" require "my-assertions"
