From f3ffcd8c96c9dc7cbea1a705b31b494a94c0ecac Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Fri, 2 Aug 2013 21:02:51 -0400 Subject: [PATCH] icalendar-tests.el tweaks related to timezone handling * test/automated/icalendar-tests.el (icalendar-tests--test-export) (icalendar-tests--test-import): Use getenv/setenv rather than set-time-zone-rule. (icalendar-tests--test-import): Reset zone even if error occurred. --- test/ChangeLog | 7 +++ test/automated/icalendar-tests.el | 72 ++++++++++++++++--------------- 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/test/ChangeLog b/test/ChangeLog index 554db3649d9..0b42f5d2be3 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,10 @@ +2013-08-03 Glenn Morris + + * automated/icalendar-tests.el (icalendar-tests--test-export) + (icalendar-tests--test-import): + Use getenv/setenv rather than set-time-zone-rule. + (icalendar-tests--test-import): Reset zone even if error occurred. + 2013-08-02 Stefan Monnier * automated/core-elisp-tests.el: New file. diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index 28fa47630a8..87c474b1a3f 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el @@ -428,12 +428,12 @@ Argument EXPECTED-OUTPUT expected iCalendar result string. European style input data must use german month names. American and ISO style input data must use english month names." - (let ((tz (cadr (current-time-zone))) + (let ((tz (getenv "TZ")) (calendar-date-style 'iso) (icalendar-recurring-start-year 2000)) (unwind-protect (progn - (set-time-zone-rule "CET") + (setenv "TZ" "CET") (when input-iso (let ((calendar-month-name-array ["January" "February" "March" "April" "May" "June" "July" "August" @@ -461,8 +461,8 @@ and ISO style input data must use english month names." "Saturday"])) (setq calendar-date-style 'american) (icalendar-tests--do-test-export input-american expected-output)))) - ;; restore time-zone if something went terribly wrong - (set-time-zone-rule tz)))) + ;; restore time-zone even if something went terribly wrong + (setenv "TZ" tz)))) (defun icalendar-tests--do-test-export (input expected-output) "Actually perform export test. @@ -671,37 +671,39 @@ Argument INPUT icalendar event string. Argument EXPECTED-ISO expected iso style diary string. Argument EXPECTED-EUROPEAN expected european style diary string. Argument EXPECTED-AMERICAN expected american style diary string." - (let ((timezone (cadr (current-time-zone)))) - (set-time-zone-rule "CET") - (with-temp-buffer - (if (string-match "^BEGIN:VCALENDAR" input) - (insert input) - (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n") - (insert "VERSION:2.0\nBEGIN:VEVENT\n") - (insert input) - (unless (eq (char-before) ?\n) - (insert "\n")) - (insert "END:VEVENT\nEND:VCALENDAR\n")) - (let ((icalendar-import-format "%s%d%l%o%t%u%c%U") - (icalendar-import-format-summary "%s") - (icalendar-import-format-location "\n Location: %s") - (icalendar-import-format-description "\n Desc: %s") - (icalendar-import-format-organizer "\n Organizer: %s") - (icalendar-import-format-status "\n Status: %s") - (icalendar-import-format-url "\n URL: %s") - (icalendar-import-format-class "\n Class: %s") - (icalendar-import-format-uid "\n UID: %s") - calendar-date-style) - (when expected-iso - (setq calendar-date-style 'iso) - (icalendar-tests--do-test-import input expected-iso)) - (when expected-european - (setq calendar-date-style 'european) - (icalendar-tests--do-test-import input expected-european)) - (when expected-american - (setq calendar-date-style 'american) - (icalendar-tests--do-test-import input expected-american)))) - (set-time-zone-rule timezone))) + (let ((timezone (getenv "TZ"))) + (unwind-protect + (progn + (setenv "TZ" "CET") + (with-temp-buffer + (if (string-match "^BEGIN:VCALENDAR" input) + (insert input) + (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n") + (insert "VERSION:2.0\nBEGIN:VEVENT\n") + (insert input) + (unless (eq (char-before) ?\n) + (insert "\n")) + (insert "END:VEVENT\nEND:VCALENDAR\n")) + (let ((icalendar-import-format "%s%d%l%o%t%u%c%U") + (icalendar-import-format-summary "%s") + (icalendar-import-format-location "\n Location: %s") + (icalendar-import-format-description "\n Desc: %s") + (icalendar-import-format-organizer "\n Organizer: %s") + (icalendar-import-format-status "\n Status: %s") + (icalendar-import-format-url "\n URL: %s") + (icalendar-import-format-class "\n Class: %s") + (icalendar-import-format-uid "\n UID: %s") + calendar-date-style) + (when expected-iso + (setq calendar-date-style 'iso) + (icalendar-tests--do-test-import input expected-iso)) + (when expected-european + (setq calendar-date-style 'european) + (icalendar-tests--do-test-import input expected-european)) + (when expected-american + (setq calendar-date-style 'american) + (icalendar-tests--do-test-import input expected-american))))) + (setenv "TZ" timezone)))) (defun icalendar-tests--do-test-import (input expected-output) "Actually perform import test. -- 2.39.2