From 3b56c0653b796a8d0957cb4aec30d01d68cf87c0 Mon Sep 17 00:00:00 2001 From: Sven-S. Porst Date: Mon, 25 Aug 2014 13:06:52 +0200 Subject: yaz: recommend depending on icu4c as discussed in #31830 Also: * add test for yaz-icu when building with ICU * do not use File.open for writing test configuration files --- Library/Formula/yaz.rb | 49 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'Library/Formula') diff --git a/Library/Formula/yaz.rb b/Library/Formula/yaz.rb index f0fbf3473..6bee9a4b0 100644 --- a/Library/Formula/yaz.rb +++ b/Library/Formula/yaz.rb @@ -14,6 +14,7 @@ class Yaz < Formula end depends_on "pkg-config" => :build + depends_on "icu4c" => :recommended depends_on "gnutls" => :optional def install @@ -23,15 +24,49 @@ class Yaz < Formula system "make install" end - # This test converts between MARC8, an obscure mostly-obsolete library - # text encoding supported by yaz-iconv, and UTF8. test do - File.open("marc8.txt", "w") do |f| - f.write "$1!0-!L,i$3i$si$Ki$Ai$O!+=(B" - end - - result = `"#{bin}/yaz-iconv" -f marc8 -t utf8 marc8.txt`.chomp + # This test converts between MARC8, an obscure mostly-obsolete library + # text encoding supported by yaz-iconv, and UTF8. + marc8file = testpath/"marc8.txt" + marc8file.write "$1!0-!L,i$3i$si$Ki$Ai$O!+=(B" + result = `#{bin}/yaz-iconv -f marc8 -t utf8 #{marc8file}` result.force_encoding(Encoding::UTF_8) if result.respond_to?(:force_encoding) assert_equal "世界こんにちは!", result + + # Test ICU support if building with ICU by running yaz-icu + # with the example icu_chain from its man page. + if build.with? "icu4c" + # The input string should be transformed to be: + # * without control characters (tab) + # * split into tokens at word boundaries (including -) + # * without whitespace and Punctuation + # * xy transformed to z + # * lowercase + configurationfile = testpath/"icu-chain.xml" + configurationfile.write <<-EOS.undent + + + + + + + + + + EOS + + inputfile = testpath/"icu-test.txt" + inputfile.write "yaz-ICU xy!" + + expectedresult = <<-EOS.undent + 1 1 'yaz' 'yaz' + 2 1 '' '' + 3 1 'icuz' 'ICUz' + 4 1 '' '' + EOS + + result = `#{bin}/yaz-icu -c #{configurationfile} #{inputfile}` + assert_equal expectedresult, result + end end end -- cgit v1.2.3