swig: add test
Closes Homebrew/homebrew#35493. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
b330bd06dc
commit
f628661a33
1 changed files with 25 additions and 3 deletions
|
@ -1,5 +1,3 @@
|
|||
require "formula"
|
||||
|
||||
class Swig < Formula
|
||||
homepage "http://www.swig.org/"
|
||||
url "https://downloads.sourceforge.net/project/swig/swig/swig-3.0.2/swig-3.0.2.tar.gz"
|
||||
|
@ -21,6 +19,30 @@ class Swig < Formula
|
|||
system "./configure", "--disable-dependency-tracking",
|
||||
"--prefix=#{prefix}"
|
||||
system "make"
|
||||
system "make install"
|
||||
system "make", "install"
|
||||
end
|
||||
|
||||
test do
|
||||
(testpath/"test.c").write <<-EOS.undent
|
||||
int add(int x, int y)
|
||||
{
|
||||
return x + y;
|
||||
}
|
||||
EOS
|
||||
(testpath/"test.i").write <<-EOS.undent
|
||||
%module test
|
||||
%inline %{
|
||||
extern int add(int x, int y);
|
||||
%}
|
||||
EOS
|
||||
(testpath/"run.rb").write <<-EOS.undent
|
||||
require "./test"
|
||||
puts Test.add(1, 1)
|
||||
EOS
|
||||
system "#{bin}/swig", "-ruby", "test.i"
|
||||
system ENV.cc, "-c", "test.c"
|
||||
system ENV.cc, "-c", "test_wrap.c", "-I/System/Library/Frameworks/Ruby.framework/Headers/"
|
||||
system ENV.cc, "-bundle", "-flat_namespace", "-undefined", "suppress", "test.o", "test_wrap.o", "-o", "test.bundle"
|
||||
assert_equal "2", shell_output("ruby run.rb").strip
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue