emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 r111397: Backport icalendar-tests fixes from trun


From: Glenn Morris
Subject: [Emacs-diffs] emacs-24 r111397: Backport icalendar-tests fixes from trunk
Date: Sun, 04 Aug 2013 18:42:55 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 111397
revision-id: address@hidden
parent: address@hidden
committer: Glenn Morris <address@hidden>
branch nick: emacs-24
timestamp: Sun 2013-08-04 11:42:50 -0700
message:
  Backport icalendar-tests fixes from trunk
  
  * 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.
  (icalendar-tests--do-test-cycle): Use with-current-buffer.
modified:
  test/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-8588
  test/automated/icalendar-tests.el 
icalendartestsuite.e-20091113204419-o5vbwnq5f7feedwu-8590
=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2013-03-26 01:55:11 +0000
+++ b/test/ChangeLog    2013-08-04 18:42:50 +0000
@@ -1,3 +1,11 @@
+2013-08-04  Glenn Morris  <address@hidden>
+
+       * 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.
+       (icalendar-tests--do-test-cycle): Use with-current-buffer.
+
 2013-03-26  Fabián Ezequiel Gallina  <address@hidden>
 
        * automated/python-tests.el

=== modified file 'test/automated/icalendar-tests.el'
--- a/test/automated/icalendar-tests.el 2013-01-01 09:11:05 +0000
+++ b/test/automated/icalendar-tests.el 2013-08-04 18:42:50 +0000
@@ -428,12 +428,16 @@
 
 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")
+;;;      (message "Current time zone: %s" (current-time-zone))
+         ;; Use this form so as not to rely on system tz database.
+         ;; Eg hydra.nixos.org.
+         (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3")
+;;;      (message "Current time zone: %s" (current-time-zone))
          (when input-iso
            (let ((calendar-month-name-array
                   ["January" "February" "March" "April" "May" "June" "July" 
"August"
@@ -461,8 +465,8 @@
                    "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 +675,43 @@
 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
+;;;      (message "Current time zone: %s" (current-time-zone))
+         ;; Use this form so as not to rely on system tz database.
+         ;; Eg hydra.nixos.org.
+         (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3")
+;;;      (message "Current time zone: %s" (current-time-zone))
+         (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.
@@ -1194,8 +1204,7 @@
              (should (string= org-input cycled)))))
       ;; clean up
       (kill-buffer (find-buffer-visiting temp-diary))
-      (save-excursion
-       (set-buffer (find-buffer-visiting temp-ics))
+      (with-current-buffer (find-buffer-visiting temp-ics)
        (set-buffer-modified-p nil)
        (kill-buffer (current-buffer)))
       (delete-file temp-diary)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]