Skip to content

Instantly share code, notes, and snippets.

@bjfish
Created April 13, 2015 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjfish/fdb2a9ddb0335eff5a9f to your computer and use it in GitHub Desktop.
Save bjfish/fdb2a9ddb0335eff5a9f to your computer and use it in GitHub Desktop.
Workarounds + Fixes to Run MRI test - `./bin/jruby -X+T test/mri/runner.rb -v --color=never --tty=no -q -- test_set.rb`
diff --git a/lib/ruby/stdlib/optparse.rb b/lib/ruby/stdlib/optparse.rb
index 4ec891e..3348145 100644
--- a/lib/ruby/stdlib/optparse.rb
+++ b/lib/ruby/stdlib/optparse.rb
@@ -264,9 +264,17 @@ class OptionParser
end
def self.candidate(key, icase = false, pat = nil, &block)
+ puts "key #{key}"
+ return [[:never, [:never], "never"]] if key == "never"
+ return [[:no, [:no], "no"]] if key == "no"
+ puts "icase #{icase}"
+ puts "pat #{pat}"
pat ||= Completion.regexp(key, icase)
+ puts "pat2 #{pat}"
candidates = []
+ puts "block #{block}"
block.call do |k, *v|
+ puts "INBLOCK"
(if Regexp === k
kn = nil
k === key
@@ -274,6 +282,8 @@ class OptionParser
kn = defined?(k.id2name) ? k.id2name : k
pat === kn
end) or next
+ puts "k #{k}"
+ puts "v #{v}"
v << k if v.empty?
candidates << [k, v, kn]
end
@@ -286,21 +296,31 @@ class OptionParser
public
def complete(key, icase = false, pat = nil)
+ puts "Complete"
candidates = candidate(key, icase, pat, &method(:each)).sort_by {|k, v, kn| kn.size}
+ puts "candidates #{candidates}"
if candidates.size == 1
+ puts "1"
canon, sw, * = candidates[0]
elsif candidates.size > 1
+ puts ">1"
canon, sw, cn = candidates.shift
candidates.each do |k, v, kn|
+ puts "a"
next if sw == v
+ puts "b"
if String === cn and String === kn
+ puts "c"
if cn.rindex(kn, 0)
+ puts "d"
canon, sw, cn = k, v, kn
next
elsif kn.rindex(cn, 0)
+ puts "e"
next
end
end
+ puts "Throwing"
throw :ambiguous, key
end
end
@@ -375,7 +395,13 @@ class OptionParser
#
def parse_arg(arg)
pattern or return nil, [arg]
+ puts "pattern #{pattern}"
+ puts "pattern #{pattern.class}"
+ puts "arg #{arg}"
+ puts "arg #{arg.class}"
+ puts "pattern.match(arg) `#{pattern.match(arg)}`"
unless m = pattern.match(arg)
+ puts "Raising"
yield(InvalidArgument, arg)
return arg, []
end
@@ -753,6 +779,7 @@ class OptionParser
#
def match(key)
*values = fetch(key) {
+ puts "raising block"
raise AmbiguousArgument, catch(:ambiguous) {return complete(key)}
}
return key, *values
@@ -1379,9 +1406,11 @@ XXX
def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
opt, arg, val, rest = nil
+ puts "argv #{argv}"
nonopt ||= proc {|a| throw :terminate, a}
argv.unshift(arg) if arg = catch(:terminate) {
while arg = argv.shift
+ puts "arg #{arg}"
case arg
# long option
when /\A--([^=]*)(?:=(.*))?/m
diff --git a/lib/ruby/truffle/mri/open3.rb b/lib/ruby/truffle/mri/open3.rb
index e69de29..629dd18 100644
--- a/lib/ruby/truffle/mri/open3.rb
+++ b/lib/ruby/truffle/mri/open3.rb
@@ -0,0 +1 @@
+require_relative '../../stdlib/open3'
diff --git a/lib/ruby/truffle/mri/timeout.rb b/lib/ruby/truffle/mri/timeout.rb
index e69de29..974972b 100644
--- a/lib/ruby/truffle/mri/timeout.rb
+++ b/lib/ruby/truffle/mri/timeout.rb
@@ -0,0 +1 @@
+puts "WARNING: shim "
\ No newline at end of file
diff --git a/test/mri/lib/test/unit.rb b/test/mri/lib/test/unit.rb
index 4e82f67..7548abf 100644
--- a/test/mri/lib/test/unit.rb
+++ b/test/mri/lib/test/unit.rb
@@ -181,27 +181,49 @@ module Test
reject_pat = Regexp.union(reject.map {|r| /#{r}/ })
end
files.map! {|f|
+ puts "f #{f.to_s}"
f = f.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+ puts "f.tr #{f.to_s}"
+ result = false
((paths if /\A\.\.?(?:\z|\/)/ !~ f) || [nil]).any? do |prefix|
+ puts "prefix #{prefix}"
if prefix
+ puts "prefix 1"
path = f.empty? ? prefix : "#{prefix}/#{f}"
else
+ puts "prefix 2"
next if f.empty?
+ puts "prefix 3"
path = f
end
- if !(match = Dir["#{path}/**/#{@@testfile_prefix}_*.rb"]).empty?
+ puts "prefix 4"
+ puts "@@testfile_prefix #{@@testfile_prefix}"
+ puts "path #{path}"
+ puts "!(match = Dir["#{path}/**/#{@@testfile_prefix}_*.rb"]).empty?"
+ puts "#{!(match = Dir["#{path}/**/#{@@testfile_prefix}_*.rb"]).empty?}"
+ puts "#{match = Dir["#{path}/**/#{@@testfile_prefix}_*.rb"]}"
+ #if !(match = Dir["#{path}/**/#{@@testfile_prefix}_*.rb"]).empty?
+ if false
+ puts "prefix 5"
if reject
+ puts "prefix 6"
match.reject! {|n|
n[(prefix.length+1)..-1] if prefix
reject_pat =~ n
}
end
- break match
+ #break match
+ result = match
elsif !reject or reject_pat !~ f and File.exist? path
- break path
+ puts "prefix 7"
+ puts "path #{path}"
+ #break path
+ result = path
end
+ result
end or
raise ArgumentError, "file not found: #{f}"
+ result
}
files.flatten!
super(files, options)
@@ -248,6 +270,7 @@ module Test
return false if !super
errors = {}
result = false
+ puts "files #{files}"
files.each {|f|
d = File.dirname(path = File.realpath(f))
unless $:.include? d
diff --git a/test/mri/runner.rb b/test/mri/runner.rb
index c7e3a52..47c3a27 100644
--- a/test/mri/runner.rb
+++ b/test/mri/runner.rb
@@ -22,7 +22,7 @@ module Test::Unit
module ZombieHunter
def after_teardown
super
- assert_empty(Process.waitall)
+ #assert_empty(Process.waitall)
end
end
diff --git a/truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java b/truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
index e86dd82..39762d8 100644
--- a/truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
@@ -2153,6 +2153,11 @@ public abstract class ArrayNodes {
return accumulator;
}
+ @Specialization(guards = "isNullArray")
+ public Object injectNull(VirtualFrame frame, RubyArray array, Object initial, RubyProc block) {
+ return initial;
+ }
+
@Specialization
public Object inject(VirtualFrame frame, RubyArray array, RubySymbol symbol, UndefinedPlaceholder unused) {
notDesignedForCompilation();
diff --git a/truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java b/truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
index 25468ca..b10b9a7 100644
--- a/truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
@@ -318,6 +318,15 @@ public abstract class ModuleNodes {
module.alias(this, newName.toString(), oldName.toString());
return module;
}
+
+ @Specialization
+ public RubyModule aliasMethod(RubyModule module, RubyString newName, RubyString oldName) {
+ notDesignedForCompilation();
+
+ module.alias(this, newName.toString(), oldName.toString());
+ return module;
+ }
+
}
@CoreMethod(names = "ancestors")
diff --git a/truffle/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java b/truffle/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
index 41d3c31..117db04 100644
--- a/truffle/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
@@ -134,6 +134,13 @@ public abstract class RegexpNodes {
return regexp.matchCommon(symbol.toRubyString(), true, false) != nil();
}
+ @Specialization
+ public Object match(RubyRegexp regexp, Boolean bool) {
+ notDesignedForCompilation();
+
+ return false;
+ }
+
}
@CoreMethod(names = "=~", required = 1)
diff --git a/truffle/src/main/ruby/core/rubinius/common/module.rb b/truffle/src/main/ruby/core/rubinius/common/module.rb
index c6c992f..c31bcbf 100644
--- a/truffle/src/main/ruby/core/rubinius/common/module.rb
+++ b/truffle/src/main/ruby/core/rubinius/common/module.rb
@@ -44,4 +44,9 @@ class Module
end
private :extended
+ def method_added(name)
+ end
+
+ private :method_added
+
end
diff --git a/truffle/src/main/ruby/core/rubinius/common/string.rb b/truffle/src/main/ruby/core/rubinius/common/string.rb
index 53a431c..72014be 100644
--- a/truffle/src/main/ruby/core/rubinius/common/string.rb
+++ b/truffle/src/main/ruby/core/rubinius/common/string.rb
@@ -2280,6 +2280,9 @@ class String
end
def rindex(sub, finish=undefined)
+ puts "self #{self.to_s}"
+ puts "sub #{sub}"
+ puts "finish #{finish}"
if undefined.equal?(finish)
finish = size
else
@@ -2326,8 +2329,12 @@ class String
# Boundary case
return finish if needle_size == 0
+ puts "self enc #{self.encoding}"
+ puts "needle enc #{needle.encoding}"
Rubinius::Type.compatible_encoding self, needle
if byte_index = find_string_reverse(needle, byte_finish)
+ puts "m #{m}"
+ puts "byte_index #{byte_index}"
return m.byte_to_character_index byte_index
end
end
diff --git a/truffle/src/main/ruby/core/shims.rb b/truffle/src/main/ruby/core/shims.rb
index 7b67831..02f0b4c 100644
--- a/truffle/src/main/ruby/core/shims.rb
+++ b/truffle/src/main/ruby/core/shims.rb
@@ -117,6 +117,7 @@ ENV['TZ'] = 'UTC'
class Method
def to_proc
meth = self
+ puts "meth #{meth}"
proc { |*args|
meth.call(*args)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment