Improve handling of locales in the test suite.
authorMark H Weaver <mhw@netris.org>
Sat, 8 Feb 2014 02:42:28 +0000 (21:42 -0500)
committerMark H Weaver <mhw@netris.org>
Sat, 8 Feb 2014 02:49:35 +0000 (21:49 -0500)
* test-suite/guile-test (run-tests): Load each test file within
  (with-locale "C" ...).

* test-suite/tests/encoding-iso88591.test:
* test-suite/tests/encoding-iso88597.test:
* test-suite/tests/encoding-utf8.test:
* test-suite/tests/srfi-14.test: Remove broken code to save and restore
  the previous locale.

* test-suite/tests/bytevectors.test:
* test-suite/tests/format.test:
* test-suite/tests/regexp.test:
* test-suite/tests/srfi-19.test:
* test-suite/tests/tree-il.test: Make sure 'setlocale' is defined before
  calling it.

test-suite/guile-test
test-suite/tests/bytevectors.test
test-suite/tests/encoding-iso88591.test
test-suite/tests/encoding-iso88597.test
test-suite/tests/encoding-utf8.test
test-suite/tests/format.test
test-suite/tests/regexp.test
test-suite/tests/srfi-14.test
test-suite/tests/srfi-19.test
test-suite/tests/tree-il.test

index cdcfe49..43ea481 100755 (executable)
@@ -5,7 +5,7 @@
 ;;;; guile-test --- run the Guile test suite
 ;;;; Jim Blandy <jimb@red-bean.com> --- May 1999
 ;;;;
-;;;;   Copyright (C) 1999, 2001, 2006, 2010 Free Software Foundation, Inc.
+;;;; Copyright (C) 1999, 2001, 2006, 2010, 2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This program is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
                  (lambda ()
                    (for-each (lambda (test)
                                (display (string-append "Running " test "\n"))
-                               (with-test-prefix test
-                                                 (load (test-file-name test))))
+                               (with-locale "C"
+                                 (with-test-prefix test
+                                   (load (test-file-name test)))))
                              tests))))
             (if (opt 'coverage #f)
                 (let-values (((coverage-data _)
 \f
 ;;; Local Variables:
 ;;; mode: scheme
+;;; eval: (put 'with-locale 'scheme-indent-function 1)
 ;;; End:
index 524ce86..637d6d4 100644 (file)
@@ -1,6 +1,8 @@
 ;;;; bytevectors.test --- R6RS bytevectors. -*- mode: scheme; coding: utf-8; -*-
 ;;;;
-;;;; Copyright (C) 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+;;;; Copyright (C) 2009, 2010, 2011, 2012, 2013,
+;;;;   2014 Free Software Foundation, Inc.
+;;;;
 ;;;; Ludovic Courtès
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 \f
 
 ;; Default to the C locale for the following tests.
-(setlocale LC_ALL "C")
+(when (defined? 'setlocale)
+  (setlocale LC_ALL "C"))
 
 
 (with-test-prefix "2.9 Operations on Strings"
index 8265ff1..2af2b48 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; encoding-iso88591.test --- test suite for Guile's string encodings    -*- mode: scheme; coding: iso-8859-1 -*-
 ;;;;
-;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;;;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -25,9 +25,8 @@
   (apply string (map integer->char args)))
 
 ;; Set locale to the environment's locale, so that the prints look OK.
-(define oldlocale #f)
-(if (defined? 'setlocale)
-    (set! oldlocale (setlocale LC_ALL "")))
+(when (defined? 'setlocale)
+  (setlocale LC_ALL ""))
 
 (define ascii-a (integer->char 65))     ; LATIN CAPITAL LETTER A
 (define a-acute (integer->char #x00c1)) ; LATIN CAPITAL LETTER A WITH ACUTE
                       (set-port-encoding! pt "ISO-8859-1")
                       (set-port-conversion-strategy! pt 'error)
                       (display (string-ints 256) pt))))
-
-;; Reset locales
-(if (defined? 'setlocale)
-    (setlocale LC_ALL oldlocale))
index a577b2a..e88b9d3 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; encoding-iso88697.test --- test suite for Guile's string encodings    -*- mode: scheme; coding: iso-8859-7 -*-
 ;;;;
-;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;;;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -24,9 +24,9 @@
 (define (string-ints . args)
   (apply string (map integer->char args)))
 
-(define oldlocale #f)
-(if (defined? 'setlocale)
-    (set! oldlocale (setlocale LC_ALL "")))
+(when (defined? 'setlocale)
+  (setlocale LC_ALL ""))
+
 (define ascii-a (integer->char 65))     ; LATIN CAPITAL LETTER A
 (define a-acute (integer->char #x00c1)) ; LATIN CAPITAL LETTER A WITH ACUTE
 (define alpha (integer->char #x03b1))   ; GREEK SMALL LETTER ALPHA
                       (set-port-encoding! pt "ISO-8859-7")
                       (set-port-conversion-strategy! pt 'error)
                       (display (string-ints #x0400) pt))))
-
-;; Reset locale
-(if (defined? 'setlocale)
-    (setlocale LC_ALL oldlocale))
index 1de3fa7..786170e 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; encoding-utf8.test --- test suite for Guile's string encodings    -*- mode: scheme; coding: utf-8 -*-
 ;;;;
-;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;;;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -24,9 +24,8 @@
 (define (string-ints . args)
   (apply string (map integer->char args)))
 
-(define oldlocale #f)
-(if (defined? 'setlocale)
-    (set! oldlocale (setlocale LC_ALL "")))
+(when (defined? 'setlocale)
+  (setlocale LC_ALL ""))
 
 (define ascii-a (integer->char 65))     ; LATIN CAPITAL LETTER A
 (define a-acute (integer->char #x00c1)) ; LATIN CAPITAL LETTER A WITH ACUTE
           (let ((芥川龍之介  1)
                 (ñ 2))
             (eqv? (+  芥川龍之介 ñ) 3))))
-
-(if (defined? 'setlocale)
-    (setlocale LC_ALL oldlocale))
index a411b49..3349847 100644 (file)
@@ -1,7 +1,8 @@
 ;;;; format.test --- test suite for Guile's CL-ish format  -*- scheme -*-
 ;;;; Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de> --- June 2001
 ;;;;
-;;;; Copyright (C) 2001, 2003, 2004, 2006, 2010, 2011, 2012 Free Software Foundation, Inc.
+;;;; Copyright (C) 2001, 2003, 2004, 2006, 2010, 2011, 2012,
+;;;;   2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
 ;;; ~h
 ;;;
 
-(setlocale LC_ALL "C")
+(when (defined? 'setlocale)
+  (setlocale LC_ALL "C"))
+
 (with-test-prefix "~h localized number"
 
   (pass-if "1234.5"
index b5c59f0..974071a 100644 (file)
@@ -2,7 +2,7 @@
 ;;;; Jim Blandy <jimb@red-bean.com> --- September 1999
 ;;;;
 ;;;;   Copyright (C) 1999, 2004, 2006, 2007, 2008, 2009, 2010,
-;;;;      2012, 2013 Free Software Foundation, Inc.
+;;;;      2012, 2013, 2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -23,8 +23,8 @@
   #:use-module (srfi srfi-1)
   #:use-module (ice-9 regex))
 
-(if (defined? 'setlocale)
-    (setlocale LC_ALL "C"))
+(when (defined? 'setlocale)
+  (setlocale LC_ALL "C"))
 
 ;; Don't fail if we can't display a test name to stdout/stderr.
 (set-port-conversion-strategy! (current-output-port) 'escape)
index 5f93760..f511f1c 100644 (file)
@@ -2,7 +2,7 @@
 ;;;; --- Test suite for Guile's SRFI-14 functions.
 ;;;; Martin Grabmueller, 2001-07-16
 ;;;;
-;;;; Copyright (C) 2001, 2006, 2009, 2010 Free Software Foundation, Inc.
+;;;; Copyright (C) 2001, 2006, 2009, 2010, 2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
 (define (every? pred lst)
   (not (not (every pred lst))))
 
-(define oldlocale #f)
-(if (defined? 'setlocale)
-    (set! oldlocale (setlocale LC_ALL "")))
+(when (defined? 'setlocale)
+  (setlocale LC_ALL ""))
 
 (with-test-prefix "Latin-1 (8-bit charset)"
 
                                             (map (lambda (x) (+ #x80 x))
                                                  (iota #x20))))))
                 char-set:iso-control)))
-
-(if (defined? 'setlocale)
-    (setlocale LC_ALL oldlocale))
index 8819c4f..d63e622 100644 (file)
@@ -2,7 +2,7 @@
 ;;;; Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de> --- June 2001
 ;;;;
 ;;;; Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007, 2008,
-;;;;   2011 Free Software Foundation, Inc.
+;;;;   2011, 2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,8 @@
   :use-module (ice-9 format))
 
 ;; Make sure we use the default locale.
-(setlocale LC_ALL "C")
+(when (defined? 'setlocale)
+  (setlocale LC_ALL "C"))
 
 (define (with-tz* tz thunk)
   "Temporarily set the TZ environment variable to the passed string
index ddc3e76..34bc810 100644 (file)
@@ -1,7 +1,8 @@
 ;;;; tree-il.test --- test suite for compiling tree-il   -*- scheme -*-
 ;;;; Andy Wingo <wingo@pobox.com> --- May 2009
 ;;;;
-;;;;   Copyright (C) 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+;;;; Copyright (C) 2009, 2010, 2011, 2012, 2013,
+;;;;   2014 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
 ;;;
 
 ;; Make sure we get English messages.
-(setlocale LC_ALL "C")
+(when (defined? 'setlocale)
+  (setlocale LC_ALL "C"))
 
 (define (call-with-warnings thunk)
   (let ((port (open-output-string)))