Permalink
Browse files

imported the Ruby 1.9.2's tests.

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4794 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 303814f commit cbace5437aeff9c3be8fb7c1fbafdb5e6efdbe1e @Watson1978 Watson1978 committed Oct 14, 2010
Showing 718 changed files with 142,171 additions and 0 deletions.
View
@@ -0,0 +1,27 @@
+* About
+
+ This is a unit test for MacRuby which based on Ruby 1.9.2.
+
+* Test
+
+ Execute the unit test following commands.
+ $ rake
+
+ Test results are stored in "result" directory.
+
+* Bootstraptest
+
+ Execute the unit test following commands.
+ $ cd bootstraptest
+ $ ./runner.rb
+
+* Attention
+
+ 1. The zombi process of MacRuby might be generated with Test.
+ When kills all MacRuby process,
+ $ rake kill
+
+ 2. The "~/.gemrc" and "~/.gem" might be changed with Test.
+ Please back up beforehand.
+
+ 3. Now, it takes around 1 hour till Test is completed.
View
@@ -0,0 +1,55 @@
+GET_LOG_SEGFAULT = true
+DIR_RESULT = "result"
+
+task :default do
+ date = Time.now.strftime('%Y-%m-%d-%H%M%S')
+ output = "log_#{date}.txt"
+ error = "crash_#{date}.txt"
+ opts = ENV['opts'] || ""
+ macruby = ENV['ruby'] || "/usr/local/bin/macruby"
+
+ unless(File.directory?(DIR_RESULT))
+ Dir.mkdir(DIR_RESULT)
+ end
+
+ test_files = Dir.glob(File.join('test', '**/test_*'))
+ test_files.each do |file|
+ # run test
+ if(GET_LOG_SEGFAULT)
+ puts file
+ system "sh -c './bin/timeout -t 180 #{macruby} -r require_relative.rb #{file} #{opts} >> #{DIR_RESULT}/#{output} 2>&1' >> #{DIR_RESULT}/#{error} 2>&1"
+ else
+ system "./bin/timeout -t 180 #{macruby} -r require_relative.rb #{file} #{opts} 2>&1 | tee -a -i #{DIR_RESULT}/#{output}"
+ end
+
+ # kill watchdog
+ ps = `ps | grep sleep`
+ ps.each_line do |line|
+ info = line.split(/\s+/)
+ pid = info[0]
+ pname = info[3]
+
+ if(pname == "sleep")
+ system "kill -KILL #{pid}"
+ end
+ end
+ end
+
+end
+
+task :kill do
+ require 'pp'
+
+ COMMAND = "ps aux | grep macruby"
+ result = `#{COMMAND}`
+
+ prc = result.split("\n")
+ pp prc
+ prc.each do |line|
+ unless(line =~ /#{COMMAND}/)
+ process = line.split(/\s+/)[1]
+ sh "kill -KILL #{process}"
+ end
+ end
+
+end
View
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+#
+# adapted from http://www.shelldorado.com/scripts/cmds/timeout
+
+NAME=`basename "$0"` # Program name
+VERSION='1.3'
+
+TIMEOUT=10 # Default [seconds]
+
+usage () {
+ echo >&2 "$NAME - set timeout for a command, $VERSION
+usage: $NAME [-t timeout] command [argument ...]
+ -t: timeout (in seconds, default is $TIMEOUT)"
+ exit 1
+}
+
+message () {
+ for msg_line
+ do echo "$NAME: $msg_line" >&2
+ done
+}
+
+fatal () { message "$@"; exit 1; }
+
+while [ $# -gt 0 ]
+do
+ case "$1" in
+ -p) parent_pid=$2; shift;; # Used internally!
+ -t) time_out="$2"; shift;;
+ --) shift; break;;
+ -h) usage;;
+ -*) usage;;
+ *) break;; # First file name
+ esac
+ shift
+done
+
+: ${time_out:=$TIMEOUT} # Set default [seconds]
+
+if [ -z "$parent_pid" ]
+then
+ # This is the first invokation of this script.
+ # Start "watchdog" process, and then run the command.
+ [ $# -lt 1 ] && fatal "please specify a command to execute"
+ "$0" -p $$ -t $time_out & # Start watchdog
+ #echo >&2 "DEBUG: process id is $$"
+ exec "$@" # Run command
+ exit 2 # NOT REACHED
+else
+ # We run in "watchdog" mode, $parent_pid contains the PID
+ # of the process we should terminate after $time_out seconds.
+ [ $# -ne 0 ] && fatal "please do not use -p option interactively"
+
+ #echo >&2 "DEBUG: $$: parent PID to terminate is $parent_pid"
+
+ exec >/dev/null 0<&1 2>&1 # Suppress error messages
+ sleep $time_out
+ kill $parent_pid && # Give process time to terminate
+ (sleep 2; kill -1 $parent_pid) && (sleep 2; kill -9 $parent_pid)
+ exit 0
+fi
@@ -0,0 +1,39 @@
+assert_equal 'A', %q{
+ class A
+ @@a = 'A'
+ def a=(x)
+ @@a = x
+ end
+ def a
+ @@a
+ end
+ end
+
+ B = A.dup
+ B.new.a = 'B'
+ A.new.a
+}, '[ruby-core:17019]'
+
+assert_equal 'ok', %q{
+ def m
+ lambda{
+ proc{
+ return :ng1
+ }
+ }.call.call
+ :ng2
+ end
+
+ begin
+ m()
+ rescue LocalJumpError
+ :ok
+ end
+}
+
+assert_normal_exit %q{
+ r = Range.allocate
+ def r.<=>(o) true end
+ r.instance_eval { initialize r, r }
+ r.inspect
+}
Oops, something went wrong.

0 comments on commit cbace54

Please sign in to comment.