tests: Improve test for supported encodings.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 11 Feb 2012 18:16:25 +0000 (10:16 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 11 Feb 2012 18:16:36 +0000 (10:16 -0800)
I misunderstood the purpose for the config.charset script.  I had a
notion that it was supposed to print all of the character sets that
are supported by the operating system.  It doesn't (it prints
character set names that need translation for the operating system).

This change switches to using the same code that will be used at
PSPP runtime to determine whether an encoding is supported, for
determining during the tests whether an encoding is supported.

This should cause fewer tests to be skipped on Mac OS.

Reported-by: Jeremy Lavergne <jeremy@lavergne.gotdns.org>
tests/data/sys-file.at
tests/language/data-io/data-reader.at
tests/libpspp/encoding-guesser.at
tests/libpspp/i18n-test.c
tests/libpspp/i18n.at
tests/libpspp/u8-istream.at

index 5975e0f3b7326c4e44e8141d735d64c418648b97..85ccfd8b495fb464030fd0e437f93fd853eca719 100644 (file)
@@ -384,7 +384,7 @@ dnl This test writes non-ASCII characters to most of the string fields in
 dnl a .sav file and demonstrates that they are properly read back in.
 dnl XXX mrsets tests are missing.
 AT_SETUP([system file character encoding])
-AT_CHECK([supports_encodings windows-1252])
+AT_CHECK([i18n-test supports_encodings windows-1252])
 AT_DATA([save.sps], [dnl
 SET LOCALE='windows-1252'.
 DATA LIST LIST NOTABLE /àéîöçxyzabc * roué (A9) croûton (A1000).
index a6a5f360aeb06f6142d148cd57f54a50a00ae7b1..b9e7607595a2a2d5292d4972026d813c37d6fa8b 100644 (file)
@@ -206,14 +206,14 @@ DATA_READER_BINARY([MODE=360 /RECFORM=FIXED /LRECL=32],
        length ($out) == 32 or die;
        print +a2e ($out);
    }],
-  [AT_CHECK([supports_encodings EBCDIC-US])])
+  [AT_CHECK([i18n-test supports_encodings EBCDIC-US])])
 
 DATA_READER_BINARY([MODE=360 /RECFORM=VARIABLE],
   [for $_ (@data) {
        push (@records, pack ("n xx", length ($_) + 4) . a2e ($_));
    }
    dump_records ();],
-  [AT_CHECK([supports_encodings EBCDIC-US])])
+  [AT_CHECK([i18n-test supports_encodings EBCDIC-US])])
 
 DATA_READER_BINARY([MODE=360 /RECFORM=SPANNED],
   [[for my $line (@data) {
@@ -233,4 +233,4 @@ DATA_READER_BINARY([MODE=360 /RECFORM=SPANNED],
        }
    }
    dump_records ();]],
-  [AT_CHECK([supports_encodings EBCDIC-US])])
+  [AT_CHECK([i18n-test supports_encodings EBCDIC-US])])
index d63dc37e7990ea90b5063f9d6f791ebe31252938..a2b0aabd9dcf1d4d84322074696568758caee5cb 100644 (file)
@@ -8,14 +8,14 @@ AT_CLEANUP
 
 AT_SETUP([UTF-8])
 AT_KEYWORDS([encoding guesser])
-AT_CHECK([supports_encodings ISO-8859-1])
+AT_CHECK([i18n-test supports_encodings ISO-8859-1])
 AT_CHECK([printf '\346\227\245\346\234\254\350\252\236\n' | encoding-guesser-test Auto,ISO-8859-1], [0], [UTF-8
 ])
 AT_CLEANUP
 
 AT_SETUP([UTF-8 starting with ASCII])
 AT_KEYWORDS([encoding guesser])
-AT_CHECK([supports_encodings ISO-8859-1])
+AT_CHECK([i18n-test supports_encodings ISO-8859-1])
 AT_CHECK([printf 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\346\227\245\346\234\254\350\252\236\n' | encoding-guesser-test Auto,ISO-8859-1 32], [0], [UTF-8
 ])
 AT_CLEANUP
@@ -96,7 +96,7 @@ AT_CLEANUP
 
 AT_SETUP([ISO-8859-1])
 AT_KEYWORDS([encoding guesser])
-AT_CHECK([supports_encodings ISO-8859-1])
+AT_CHECK([i18n-test supports_encodings ISO-8859-1])
 AT_CHECK([printf 'entr\351e\n' | encoding-guesser-test Auto,ISO-8859-1], 
   [0], [ISO-8859-1
 ])
@@ -104,7 +104,7 @@ AT_CLEANUP
 
 AT_SETUP([GB-18030 with byte order mark])
 AT_KEYWORDS([encoding guesser])
-AT_CHECK([supports_encodings ISO-8859-1])
+AT_CHECK([i18n-test supports_encodings ISO-8859-1])
 AT_CHECK([printf '\204\061\225\063' | encoding-guesser-test Auto,ISO-8859-1], 
   [0], [GB-18030
 ])
@@ -112,7 +112,7 @@ AT_CLEANUP
 
 AT_SETUP([UTF-EBCDIC with byte order mark])
 AT_KEYWORDS([encoding guesser])
-AT_CHECK([supports_encodings ISO-8859-1])
+AT_CHECK([i18n-test supports_encodings ISO-8859-1])
 AT_CHECK([printf '\335\163\146\163' | encoding-guesser-test Auto,ISO-8859-1], 
   [0], [UTF-EBCDIC
 ])
@@ -120,7 +120,7 @@ AT_CLEANUP
 
 AT_SETUP([EUC-JP as Auto,EUC-JP])
 AT_KEYWORDS([encoding guesser])
-AT_CHECK([supports_encodings EUC-JP])
+AT_CHECK([i18n-test supports_encodings EUC-JP])
 AT_CHECK([printf '\244\241 \244\242 \244\243 \244\244 \244\245 \244\246 \244\247 \244\250 \244\251 \244\252\n' | encoding-guesser-test Auto,EUC-JP],
   [0], [EUC-JP
 ])
@@ -128,7 +128,7 @@ AT_CLEANUP
 
 AT_SETUP([EUC-JP starting with ASCII as Auto,EUC-JP])
 AT_KEYWORDS([encoding guesser])
-AT_CHECK([supports_encodings EUC-JP])
+AT_CHECK([i18n-test supports_encodings EUC-JP])
 AT_CHECK([printf 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \244\241 \244\242 \244\243 \244\244 \244\245 \244\246 \244\247 \244\250 \244\251 \244\252\n' | encoding-guesser-test Auto,EUC-JP 32],
   [0], [EUC-JP
 ])
@@ -136,7 +136,7 @@ AT_CLEANUP
 
 AT_SETUP([UTF-8 with character split across input buffers])
 AT_KEYWORDS([encoding guesser])
-AT_CHECK([supports_encodings ISO-8859-1])
+AT_CHECK([i18n-test supports_encodings ISO-8859-1])
 AT_CHECK([printf '\343\201\201\343\201\202\343\201\203\343\201\204\343\201\205\343\201\206\343\201\207\343\201\210\343\201\211\343\201\212\343\201\201\343\201\202\343\201\203\343\201\204\343\201\205\343\201\206\343\201\207\343\201\210\343\201\211\343\201\212\n' | encoding-guesser-test Auto,ISO-8859-1 32],
   [0], [UTF-8
 ])
index b433756b0d21b2a1d9e455f1833de3b43eba006b..b0d027090e967a51977e6fe98c8669fe1a621e8b 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -30,6 +30,20 @@ main (int argc, char *argv[])
 {
   i18n_init ();
 
+  if (argc > 1 && !strcmp (argv[1], "supports_encodings"))
+    {
+      int status = 0;
+      int i;
+
+      for (i = 2; i < argc; i++)
+        if (!is_encoding_supported (argv[i]))
+          {
+            printf ("encoding \"%s\" is NOT supported\n", argv[i]);
+            status = 77;
+          }
+      i18n_done ();
+      exit (status);
+    }
   if (argc == 5 && !strcmp (argv[1], "recode"))
     {
       const char *from = argv[2];
@@ -68,6 +82,10 @@ main (int argc, char *argv[])
   else
     {
       fprintf (stderr, "\
+usage: %s supports_encodings ENCODING...\n\
+where ENCODING is the name of an encoding.\n\
+Exits with status 0 if all the encodings are supported, 77 otherwise.\n\
+\n\
 usage: %s recode FROM TO STRING\n\
 where FROM is the source encoding,\n\
       TO is the target encoding,\n\
@@ -78,7 +96,7 @@ where HEAD is the first string to concatenate\n\
       TAIL is the second string to concatenate\n\
       ENCODING is the encoding in which to measure the result's length\n\
       MAX_LEN is the maximum length of the result in ENCODING.\n",
-               argv[0], argv[0]);
+               argv[0], argv[0], argv[0]);
       return EXIT_FAILURE;
     }
 
index 421241e5db2f08b57cb766cf83b5c2bd9e16093a..5f4bb65961ed21ccc775a66a053b5ca1960261df 100644 (file)
@@ -1,23 +1,5 @@
 AT_BANNER([i18n recoding])
 
-m4_divert_push([PREPARE_TESTS])
-supports_encodings () {
-  case "$host" in
-    *-*-linux* | *-*-*-gnu*)
-      dnl GNU/Linux always has the encodings we want.  We can't ask
-      dnl config.charset about them because it has a special case here
-      dnl too and won't tell us.
-      return 0
-      ;;
-    *)
-      for encoding in "$@"; do
-       $SHELL $top_srcdir/gl/config.charset "$host" | grep '$2' || return 77
-      done
-      ;;
-  esac
-}
-m4_divert_pop([PREPARE_TESTS])
-
 # CHECK_I18N_RECODE([TITLE], [FROM-CODING], [TO-CODING],
 #                   [FROM-TEXT], [TO-TEXT])
 #
@@ -30,7 +12,7 @@ m4_define([CHECK_I18N_RECODE],
    AT_KEYWORDS([i18n])
 
    dnl Skip the test if this host doesn't know the source and target encodings.
-   AT_CHECK([supports_encodings '$2' '$3'])
+   AT_CHECK([i18n-test supports_encodings '$2' '$3'])
    AT_CHECK_UNQUOTED([i18n-test recode '$2' '$3' `printf '$4'`], [0], [`printf '$5'`
 ])
    AT_CLEANUP])
@@ -80,7 +62,7 @@ m4_define([CHECK_I18N_CONCAT],
    AT_KEYWORDS([i18n])
 
    dnl Skip the test if this host doesn't know the encoding.
-   AT_CHECK([supports_encodings '$3'])
+   AT_CHECK([i18n-test supports_encodings '$3'])
    AT_CHECK_UNQUOTED(
      [i18n-test concat "`printf '$1'`" "`printf '$2'`" '$3' '$4'], [0],
      [`printf '$5'`
index 2d8baa4745448d76a906ef739acc5421193bcac9..985805d7ee0e6605bc24651e0c61a6167f53fda1 100644 (file)
@@ -2,7 +2,7 @@ AT_BANNER([u8_istream])
 
 AT_SETUP([read ASCII])
 AT_KEYWORDS([u8_istream])
-AT_CHECK([supports_encodings ASCII])
+AT_CHECK([i18n-test supports_encodings ASCII])
 AT_CHECK([echo string | u8-istream-test read - ASCII], [0], [string
 ])
 AT_CLEANUP
@@ -18,7 +18,7 @@ AT_CLEANUP
 
 AT_SETUP([read EUC-JP])
 AT_KEYWORDS([u8_istream])
-AT_CHECK([supports_encodings EUC-JP])
+AT_CHECK([i18n-test supports_encodings EUC-JP])
 AT_CHECK([printf '\244\241 \244\242 \244\243 \244\244 \244\245 \244\246 \244\247 \244\250 \244\251 \244\252\n' | u8-istream-test read - EUC-JP],
   [0],
   [ぁ あ ぃ い ぅ う ぇ え ぉ お
@@ -58,7 +58,7 @@ AT_CLEANUP
 
 AT_SETUP([read EUC-JP with character split across input buffers])
 AT_KEYWORDS([u8_istream])
-AT_CHECK([supports_encodings EUC-JP])
+AT_CHECK([i18n-test supports_encodings EUC-JP])
 buffer_size=`u8-istream-test buffer-size`
 ($PERL -e "print 'x' x ($buffer_size - 16)"
  printf '\244\241 \244\242 \244\243 \244\244 \244\245 \244\246 \244\247 '
@@ -72,7 +72,7 @@ AT_CLEANUP
 
 AT_SETUP([read EUC-JP with character split across output buffers])
 AT_KEYWORDS([u8_istream])
-AT_CHECK([supports_encodings EUC-JP])
+AT_CHECK([i18n-test supports_encodings EUC-JP])
 AT_CHECK([printf '\244\241\244\242\244\243\244\244\244\245\244\246\244\247\244\250\244\251\244\252\n' | u8-istream-test read - EUC-JP 16],
   [0],
   [ぁあぃいぅうぇえぉお
@@ -81,7 +81,7 @@ AT_CLEANUP
 
 AT_SETUP([read EUC-JP with character split across input and output buffers])
 AT_KEYWORDS([u8_istream])
-AT_CHECK([supports_encodings EUC-JP])
+AT_CHECK([i18n-test supports_encodings EUC-JP])
 buffer_size=`u8-istream-test buffer-size`
 ($PERL -e "print 'x' x ($buffer_size - 16)"
  printf 'xyz\244\241\244\242\244\243\244\244\244\245\244\246\244\247\244\250'
@@ -113,7 +113,7 @@ AT_CLEANUP
 
 AT_SETUP([read ISO-8859-1 as Auto,ISO-8859-1])
 AT_KEYWORDS([u8_istream])
-AT_CHECK([supports_encodings ISO-8859-1])
+AT_CHECK([i18n-test supports_encodings ISO-8859-1])
 buffer_size=`u8-istream-test buffer-size`
 ($PERL -e "print 'x' x int($buffer_size * 2.5)"; printf 'entr\351e\n') > input
 (echo "Auto mode"
@@ -125,7 +125,7 @@ AT_CLEANUP
 dnl UTF-16BE is not ASCII compatible so this doesn't start out in Auto mode.
 AT_SETUP([read UTF-16BE as Auto,UTF-16BE])
 AT_KEYWORDS([u8_istream])
-AT_CHECK([supports_encodings UTF-16BE])
+AT_CHECK([i18n-test supports_encodings UTF-16BE])
 AT_CHECK([printf '\0e\0n\0t\0r\0\351\0e\0\n' | u8-istream-test read - Auto,UTF-16BE], 
   [0], [dnl
 entrée
@@ -134,7 +134,7 @@ AT_CLEANUP
 
 AT_SETUP([read EUC-JP as Auto,EUC-JP])
 AT_KEYWORDS([u8_istream])
-AT_CHECK([supports_encodings EUC-JP])
+AT_CHECK([i18n-test supports_encodings EUC-JP])
 AT_CHECK([printf 'entr\217\253\261e\n' | u8-istream-test read - Auto,EUC-JP], 
   [0], [entrée
 ])