Author: koutou
Date: Sun Mar 22 00:49:44 2009
New Revision: 5920
Modified:
trunk/test/test-intl.scm
Log:
* test/test-intl.scm: use sys-unsetenv for restoring nonexistent
environment variable value.
Modified: trunk/test/test-intl.scm
==============================================================================
--- trunk/test/test-intl.scm (original)
+++ trunk/test/test-intl.scm Sun Mar 22 00:49:44 2009
@@ -34,64 +34,67 @@
(use gauche.process))
(select-module test.test-intl)
-(define current-lang (or (sys-getenv "LANG")
- (sys-getenv "LC_ALL")))
-;; At least on glibc 2.6.1-1ubuntu9 on Ubuntu 7.10, gettext(3)
-;; does not read the translation for "en_US" and "C". So I
-;; specify "ja_JP" as an arbitrary locale for these tests.
-;; -- YamaKen 2008-03-23
-;;(define lang "en_US") ;; doesn't work
-;;(define lang "C") ;; doesn't work
-;;(define lang "ja_JP")
-;;
-;; "ja_JP" doesn't work on "ja_JP" isn't generated environment.
-;; For example, "ja_JP" isn't generated but "ja_JP.UTF-8" is
-;; generated on my environment. So, I guess available locales
-;; from "locale -a" and use the current locale as fallback locale.
-;; -- kou 2009-03-22 -- Wow! just (- a-year 1) ago!
-(define lang
+(define (guess-current-locale)
(let ((locale-process (run-process '("locale" "-a")
:output :pipe
:error :pipe
:wait #t)))
(or (and (= 0 (process-exit-status locale-process))
(find #/\./ (port->string-list (process-output
locale-process))))
- current-lang)))
+ (sys-getenv "LANG")
+ (sys-getenv "LC_ALL"))))
(define locale-dir (uim-test-build-path "test" "locale"))
-(define LC_MESSAGES-dir (build-path locale-dir lang "LC_MESSAGES"))
(define domain "uim")
(define msgid "hello")
(define msgstr "Hello")
-
(define (setup)
- (make-directory* LC_MESSAGES-dir)
- (with-output-to-file (build-path LC_MESSAGES-dir #`",|domain|.po")
- (lambda ()
- (display
- (string-join
- `("msgid \"\""
- "msgstr \"\""
- "\"MIME-Version: 1.0\\n\""
- "\"Content-Type: text/plain; charset=UTF-8\\n\""
- "\"Content-Transfer-Encoding: 8bit\\n\""
- ""
- ,#`"msgid \",|msgid|\""
- ,#`"msgstr \",|msgstr|\"")
- "\n"))))
- (run-process "msgfmt" "-o"
- (build-path LC_MESSAGES-dir #`",|domain|.mo")
- (build-path LC_MESSAGES-dir #`",|domain|.po")
- :wait #t)
+ (let* ((current-LANG (sys-getenv "LANG"))
+ (current-LC_ALL (sys-getenv "LC_ALL"))
+ ;; At least on glibc 2.6.1-1ubuntu9 on Ubuntu 7.10, gettext(3)
+ ;; does not read the translation for "en_US" and "C". So I
+ ;; specify "ja_JP" as an arbitrary locale for these tests.
+ ;; -- YamaKen 2008-03-23
+ ;;(define lang "en_US") ;; doesn't work
+ ;;(define lang "C") ;; doesn't work
+ ;;(define lang "ja_JP")
+ ;;
+ ;; "ja_JP" doesn't work on "ja_JP" isn't generated environment.
+ ;; For example, "ja_JP" isn't generated but "ja_JP.UTF-8" is
+ ;; generated on my environment. So, I guess available locales
+ ;; from "locale -a" and use the current locale as fallback locale.
+ ;; -- kou 2009-03-22 -- Wow! just (- a-year 1) ago!
+ (lang (guess-current-locale))
+ (LC_MESSAGES-dir (build-path locale-dir lang "LC_MESSAGES")))
+ (make-directory* LC_MESSAGES-dir)
+ (with-output-to-file (build-path LC_MESSAGES-dir #`",|domain|.po")
+ (lambda ()
+ (display
+ (string-join
+ `("msgid \"\""
+ "msgstr \"\""
+ "\"MIME-Version: 1.0\\n\""
+ "\"Content-Type: text/plain; charset=UTF-8\\n\""
+ "\"Content-Transfer-Encoding: 8bit\\n\""
+ ""
+ ,#`"msgid \",|msgid|\""
+ ,#`"msgstr \",|msgstr|\"")
+ "\n"))))
+ (run-process "msgfmt" "-o"
+ (build-path LC_MESSAGES-dir #`",|domain|.mo")
+ (build-path LC_MESSAGES-dir #`",|domain|.po")
+ :wait #t)
- (when lang
(sys-putenv "LANG" lang)
- (sys-putenv "LC_ALL" lang))
- (uim-test-setup)
- (when lang
- (sys-putenv "LANG" current-lang)
- (sys-putenv "LC_ALL" current-lang)))
+ (sys-putenv "LC_ALL" lang)
+ (uim-test-setup)
+ (if current-LANG
+ (sys-putenv "LANG" current-LANG)
+ (sys-unsetenv "LANG"))
+ (if current-LC_ALL
+ (sys-putenv "LC_ALL" current-LC_ALL)
+ (sys-unsetenv "LC_ALL"))))
(define (teardown)
(uim-test-teardown)