Skip to content

Commit

Permalink
- Fixes for maglev to find headers in the correct location.
Browse files Browse the repository at this point in the history
- Fixes for tests, mostly for maglev.
Cleaning out some oooold cruft.

[git-p4: depot-paths = "//src/RubyInline/dev/": change = 8164]
  • Loading branch information
zenspider committed Feb 1, 2013
1 parent 432ae55 commit 3ef9d5f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/inline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ def build

if recompile then

hdrdir = %w(srcdir archdir rubyhdrdir).map { |name|
hdrdir = %w(srcdir includedir archdir rubyhdrdir).map { |name|
RbConfig::CONFIG[name]
}.find { |dir|
dir and File.exist? File.join(dir, "/ruby.h")
dir and File.exist? File.join(dir, "ruby.h")
} or abort "ERROR: Can't find header dir for ruby. Exiting..."

flags = @flags.join(' ')
Expand Down
38 changes: 21 additions & 17 deletions test/test_inline.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$TESTING = true

$0 = __FILE__ if $0 =~ /-e|\(eval\)/
$0 = __FILE__ if $0 =~ /-e|\(eval\)|^$/
$0 = $0.sub(Dir.pwd, '.')

require 'inline'
require 'tempfile'
Expand All @@ -13,15 +14,9 @@

require 'pathname'

$expand_paths = Pathname.new(__FILE__).absolute?
$inline_path = './lib/inline.rb'
$test_inline_path = './test/test_inline.rb'

if $expand_paths then
$inline_path = File.expand_path $inline_path
$test_inline_path = File.expand_path $test_inline_path
end

class InlineTestCase < MiniTest::Unit::TestCase
def setup
super
Expand All @@ -36,10 +31,6 @@ def teardown
ENV.delete 'INLINEDIR'
end
end

def test_stupid
#shuts test unit up
end
end

class TestDir < InlineTestCase
Expand Down Expand Up @@ -521,7 +512,7 @@ def test_parse_signature_register
def util_generate(src, expected, expand_types=true)
result = @builder.generate src, expand_types
result = util_strip_lines result
result.gsub!(/\# line \d+/, '# line N')

expected = "# line N \"#{$0}\"\n" + expected
assert_equal(expected, result)
end
Expand All @@ -533,7 +524,7 @@ def util_generate_raw(src, expected)
def util_strip_lines(src)
case src
when String then
src.gsub(/\# line \d+/, '# line N')
src.gsub(/\# line \d+/, '# line N').gsub(Dir.pwd, '.')
when Array then
src.map do |chunk|
util_strip_lines chunk
Expand Down Expand Up @@ -807,21 +798,22 @@ def test_c

expected = "# line N \"#{$0}\"\nstatic VALUE add(VALUE self, VALUE _a, VALUE _b) {\n int a = FIX2INT(_a);\n int b = FIX2INT(_b);\n return INT2FIX(a + b); }"

result.gsub!(/\# line \d+/, '# line N')
result = util_strip_lines result

assert_equal expected, result
assert_equal [expected], @builder.src
assert_equal [expected], util_strip_lines(@builder.src)
end

def test_c_raw
src = "static VALUE answer_raw(int argc, VALUE *argv, VALUE self) { return INT2NUM(42); }"

result = @builder.c_raw src.dup
result = util_strip_lines result

result.gsub!(/\# line \d+/, '# line N')
expected = "# line N \"#{$0}\"\n" + src

assert_equal expected, result
assert_equal [expected], @builder.src
assert_equal [expected], util_strip_lines(@builder.src)
end

def test_map_c_const
Expand Down Expand Up @@ -874,6 +866,8 @@ def util_test_build(src)
end

def test_build_good
skip "https://github.com/MagLev/maglev/issues/231" if maglev?

code = util_simple_code(:DumbTest1, "long dumbpi() { return 314; }")
util_test_build(code) do
result = DumbTest1.new.dumbpi
Expand Down Expand Up @@ -983,6 +977,8 @@ class Bar

class TestModule < InlineTestCase
def test_nested
skip "https://github.com/MagLev/maglev/issues/231" if maglev?

Object.class_eval $test_module_code
fb = Foo::Bar.new
assert_equal(42, fb.forty_two_instance)
Expand All @@ -1003,12 +999,16 @@ def test_nested
end

def test_argument_check_good
skip "https://github.com/MagLev/maglev/issues/231" if maglev?

util_arity_check
fb = Foo::Bar.new
assert_equal 13, fb.arity6(1, 2, 3, 4, 5, "blah")
end

def test_argument_check_fewer
skip "https://github.com/MagLev/maglev/issues/231" if maglev?

util_arity_check
fb = Foo::Bar.new

Expand All @@ -1018,6 +1018,8 @@ def test_argument_check_fewer
end

def test_argument_check_more
skip "https://github.com/MagLev/maglev/issues/231" if maglev?

util_arity_check
fb = Foo::Bar.new
assert_raises ArgumentError do
Expand All @@ -1026,6 +1028,8 @@ def test_argument_check_more
end

def test_inline
skip "https://github.com/MagLev/maglev/issues/231" if maglev?

self.class.inline(:C) do |builder|
builder.c "int add(int a, int b) { return a + b; }"
end
Expand Down

0 comments on commit 3ef9d5f

Please sign in to comment.