aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/libxml2.rb
diff options
context:
space:
mode:
authorXu Cheng2015-02-03 21:25:41 +0800
committerMike McQuaid2015-02-03 16:22:00 +0000
commitdc5047f10ae38ad67a34ef95d283e6cd9b24414f (patch)
treed6f08d562316ba2435397b91ba7e11c0f93faba7 /Library/Formula/libxml2.rb
parent0c0800a7b6679d55d4d235f1a5bb822aaba4e5ef (diff)
downloadhomebrew-dc5047f10ae38ad67a34ef95d283e6cd9b24414f.tar.bz2
libxml2: add test
Closes #36497. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Formula/libxml2.rb')
-rw-r--r--Library/Formula/libxml2.rb37
1 files changed, 27 insertions, 10 deletions
diff --git a/Library/Formula/libxml2.rb b/Library/Formula/libxml2.rb
index 5b93b7beb..2f0d48129 100644
--- a/Library/Formula/libxml2.rb
+++ b/Library/Formula/libxml2.rb
@@ -1,5 +1,3 @@
-require "formula"
-
class Libxml2 < Formula
homepage "http://xmlsoft.org"
url "http://xmlsoft.org/sources/libxml2-2.9.2.tar.gz"
@@ -13,7 +11,7 @@ class Libxml2 < Formula
end
head do
- url 'https://git.gnome.org/browse/libxml2', :using => :git
+ url "https://git.gnome.org/browse/libxml2", :using => :git
depends_on "autoconf" => :build
depends_on "automake" => :build
@@ -34,8 +32,8 @@ class Libxml2 < Formula
def install
ENV.universal_binary if build.universal?
if build.head?
- inreplace 'autogen.sh', 'libtoolize', 'glibtoolize'
- system './autogen.sh'
+ inreplace "autogen.sh", "libtoolize", "glibtoolize"
+ system "./autogen.sh"
end
system "./configure", "--disable-dependency-tracking",
@@ -44,14 +42,33 @@ class Libxml2 < Formula
"--without-lzma"
system "make"
ENV.deparallelize
- system "make install"
+ system "make", "install"
- if build.with? 'python'
- cd 'python' do
+ if build.with? "python"
+ cd "python" do
# We need to insert our include dir first
- inreplace 'setup.py', 'includes_dir = [', "includes_dir = ['#{include}', '#{MacOS.sdk_path}/usr/include',"
- system "python", 'setup.py', "install", "--prefix=#{prefix}"
+ inreplace "setup.py", "includes_dir = [", "includes_dir = ['#{include}', '#{MacOS.sdk_path}/usr/include',"
+ system "python", "setup.py", "install", "--prefix=#{prefix}"
end
end
end
+
+ test do
+ (testpath/"test.c").write <<-EOS.undent
+ #include <libxml/tree.h>
+
+ int main()
+ {
+ xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
+ xmlNodePtr root_node = xmlNewNode(NULL, BAD_CAST "root");
+ xmlDocSetRootElement(doc, root_node);
+ xmlFreeDoc(doc);
+ return 0;
+ }
+ EOS
+ args = `#{bin}/xml2-config --cflags --libs`.split
+ args += %w[test.c -o test]
+ system ENV.cc, *args
+ system "./test"
+ end
end