rubytest.rb


DEFINITIONS

This source file includes following functions.


   1  #! ./miniruby
   2  
   3  load './rbconfig.rb'
   4  include Config
   5  
   6  unless File.exist? "./#{CONFIG['ruby_install_name']}#{CONFIG['EXEEXT']}"
   7    print "./#{CONFIG['ruby_install_name']} is not found.\n"
   8    print "Try `make' first, then `make test', please.\n"
   9    exit 1
  10  end
  11  
  12  if File.exist? CONFIG['LIBRUBY_SO']
  13    case RUBY_PLATFORM
  14    when /-hpux/
  15      dldpath = "SHLIB_PATH"
  16    when /-aix/
  17      dldpath = "LIBPATH"
  18    when /-beos/
  19      dldpath = "LIBRARY_PATH"
  20    else
  21      dldpath = "LD_LIBRARY_PATH"
  22    end
  23    x = ENV[dldpath]
  24    x = x ? ".:"+x : "."
  25    ENV[dldpath] = x
  26  end
  27  
  28  if /linux/ =~ RUBY_PLATFORM and File.exist? CONFIG['LIBRUBY_SO']
  29    ENV["LD_PRELOAD"] = "./#{CONFIG['LIBRUBY_SO']}"
  30  end
  31  
  32  $stderr.reopen($stdout)
  33  error = ''
  34  
  35  `./#{CONFIG["ruby_install_name"]}#{CONFIG["EXEEXT"]} #{CONFIG["srcdir"]}/sample/test.rb`.each do |line|
  36    if line =~ /^end of test/
  37      print "test succeeded\n"
  38      exit 0
  39    end
  40    error << line if line =~ %r:^(sample/test.rb|not):
  41  end
  42  print error
  43  print "test failed\n"
  44  exit 1