test/bioruby_test_helper.rb in bio-1.4.2 vs test/bioruby_test_helper.rb in bio-1.4.3
- old
+ new
@@ -12,29 +12,54 @@
if BioRubyTestDebug then
$stderr.puts "BioRuby test debug enabled."
end
end #BioRubyTestDebug
-unless defined? BioRubyTestLibPath and BioRubyTestLibPath then
+unless defined? BioRubyTestGem then
+ gem_version = ENV['BIORUBY_TEST_GEM']
+ if gem_version then
+ $stderr.puts 'require "rubygems"' if BioRubyTestDebug
+ require "rubygems"
+ if gem_version.empty? then
+ $stderr.puts "gem 'bio'" if BioRubyTestDebug
+ gem 'bio'
+ else
+ $stderr.puts "gem 'bio', #{gem_version.inspect}" if BioRubyTestDebug
+ gem 'bio', gem_version
+ end
+ end
+ BioRubyTestGem = gem_version
+end
+
+unless defined? BioRubyTestLibPath then
libpath = ENV['BIORUBY_TEST_LIB']
- if libpath.to_s.empty? then
+ unless libpath then
libpath = Pathname.new(File.join(File.dirname(__FILE__),
"..", "lib")).cleanpath.to_s
end
- libpath.freeze
- unless $:.include?(libpath)
- $:.unshift(libpath)
- if BioRubyTestDebug then
- $stderr.puts "Added #{libpath.inspect} to $:."
+ # do not add path to $: if BIORUBY_TEST_LIB is empty string
+ # or BioRubyTestGem is true.
+ if (libpath and libpath.empty?) or BioRubyTestGem then
+ libpath = nil
+ end
+
+ if libpath then
+ libpath.freeze
+
+ unless $:[0] == libpath then
+ $:.unshift(libpath)
+ if BioRubyTestDebug then
+ $stderr.puts "Added #{libpath.inspect} to $:."
+ end
+ else
+ if BioRubyTestDebug then
+ $stderr.puts "NOT added #{libpath.inspect} to $:. because it is already on the top of $:."
+ end
end
- else
- if BioRubyTestDebug then
- $stderr.puts "NOT added #{libpath.inspect} to $:. because it is already in $:."
- end
end
- # (String) Path to be added to $:.
+ # (String or nil) Path to be added to $:.
# It may or may not be the path of bioruby.
BioRubyTestLibPath = libpath
if BioRubyTestDebug then
$stderr.print "$: = [", "\n"