aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2013-08-02 21:02:51 -0400
committerGlenn Morris2013-08-02 21:02:51 -0400
commitf3ffcd8c96c9dc7cbea1a705b31b494a94c0ecac (patch)
tree690d95e6ce1c0be4e6fecea0c86c22e9ceeb8c60
parent70122acf2f2a15770ba8255844f46290cb85b9c0 (diff)
downloademacs-f3ffcd8c96c9dc7cbea1a705b31b494a94c0ecac.tar.gz
emacs-f3ffcd8c96c9dc7cbea1a705b31b494a94c0ecac.zip
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.
-rw-r--r--test/ChangeLog7
-rw-r--r--test/automated/icalendar-tests.el72
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 @@
12013-08-03 Glenn Morris <rgm@gnu.org>
2
3 * automated/icalendar-tests.el (icalendar-tests--test-export)
4 (icalendar-tests--test-import):
5 Use getenv/setenv rather than set-time-zone-rule.
6 (icalendar-tests--test-import): Reset zone even if error occurred.
7
12013-08-02 Stefan Monnier <monnier@iro.umontreal.ca> 82013-08-02 Stefan Monnier <monnier@iro.umontreal.ca>
2 9
3 * automated/core-elisp-tests.el: New file. 10 * 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.
428 428
429European style input data must use german month names. American 429European style input data must use german month names. American
430and ISO style input data must use english month names." 430and ISO style input data must use english month names."
431 (let ((tz (cadr (current-time-zone))) 431 (let ((tz (getenv "TZ"))
432 (calendar-date-style 'iso) 432 (calendar-date-style 'iso)
433 (icalendar-recurring-start-year 2000)) 433 (icalendar-recurring-start-year 2000))
434 (unwind-protect 434 (unwind-protect
435 (progn 435 (progn
436 (set-time-zone-rule "CET") 436 (setenv "TZ" "CET")
437 (when input-iso 437 (when input-iso
438 (let ((calendar-month-name-array 438 (let ((calendar-month-name-array
439 ["January" "February" "March" "April" "May" "June" "July" "August" 439 ["January" "February" "March" "April" "May" "June" "July" "August"
@@ -461,8 +461,8 @@ and ISO style input data must use english month names."
461 "Saturday"])) 461 "Saturday"]))
462 (setq calendar-date-style 'american) 462 (setq calendar-date-style 'american)
463 (icalendar-tests--do-test-export input-american expected-output)))) 463 (icalendar-tests--do-test-export input-american expected-output))))
464 ;; restore time-zone if something went terribly wrong 464 ;; restore time-zone even if something went terribly wrong
465 (set-time-zone-rule tz)))) 465 (setenv "TZ" tz))))
466 466
467(defun icalendar-tests--do-test-export (input expected-output) 467(defun icalendar-tests--do-test-export (input expected-output)
468 "Actually perform export test. 468 "Actually perform export test.
@@ -671,37 +671,39 @@ Argument INPUT icalendar event string.
671Argument EXPECTED-ISO expected iso style diary string. 671Argument EXPECTED-ISO expected iso style diary string.
672Argument EXPECTED-EUROPEAN expected european style diary string. 672Argument EXPECTED-EUROPEAN expected european style diary string.
673Argument EXPECTED-AMERICAN expected american style diary string." 673Argument EXPECTED-AMERICAN expected american style diary string."
674 (let ((timezone (cadr (current-time-zone)))) 674 (let ((timezone (getenv "TZ")))
675 (set-time-zone-rule "CET") 675 (unwind-protect
676 (with-temp-buffer 676 (progn
677 (if (string-match "^BEGIN:VCALENDAR" input) 677 (setenv "TZ" "CET")
678 (insert input) 678 (with-temp-buffer
679 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n") 679 (if (string-match "^BEGIN:VCALENDAR" input)
680 (insert "VERSION:2.0\nBEGIN:VEVENT\n") 680 (insert input)
681 (insert input) 681 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
682 (unless (eq (char-before) ?\n) 682 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
683 (insert "\n")) 683 (insert input)
684 (insert "END:VEVENT\nEND:VCALENDAR\n")) 684 (unless (eq (char-before) ?\n)
685 (let ((icalendar-import-format "%s%d%l%o%t%u%c%U") 685 (insert "\n"))
686 (icalendar-import-format-summary "%s") 686 (insert "END:VEVENT\nEND:VCALENDAR\n"))
687 (icalendar-import-format-location "\n Location: %s") 687 (let ((icalendar-import-format "%s%d%l%o%t%u%c%U")
688 (icalendar-import-format-description "\n Desc: %s") 688 (icalendar-import-format-summary "%s")
689 (icalendar-import-format-organizer "\n Organizer: %s") 689 (icalendar-import-format-location "\n Location: %s")
690 (icalendar-import-format-status "\n Status: %s") 690 (icalendar-import-format-description "\n Desc: %s")
691 (icalendar-import-format-url "\n URL: %s") 691 (icalendar-import-format-organizer "\n Organizer: %s")
692 (icalendar-import-format-class "\n Class: %s") 692 (icalendar-import-format-status "\n Status: %s")
693 (icalendar-import-format-uid "\n UID: %s") 693 (icalendar-import-format-url "\n URL: %s")
694 calendar-date-style) 694 (icalendar-import-format-class "\n Class: %s")
695 (when expected-iso 695 (icalendar-import-format-uid "\n UID: %s")
696 (setq calendar-date-style 'iso) 696 calendar-date-style)
697 (icalendar-tests--do-test-import input expected-iso)) 697 (when expected-iso
698 (when expected-european 698 (setq calendar-date-style 'iso)
699 (setq calendar-date-style 'european) 699 (icalendar-tests--do-test-import input expected-iso))
700 (icalendar-tests--do-test-import input expected-european)) 700 (when expected-european
701 (when expected-american 701 (setq calendar-date-style 'european)
702 (setq calendar-date-style 'american) 702 (icalendar-tests--do-test-import input expected-european))
703 (icalendar-tests--do-test-import input expected-american)))) 703 (when expected-american
704 (set-time-zone-rule timezone))) 704 (setq calendar-date-style 'american)
705 (icalendar-tests--do-test-import input expected-american)))))
706 (setenv "TZ" timezone))))
705 707
706(defun icalendar-tests--do-test-import (input expected-output) 708(defun icalendar-tests--do-test-import (input expected-output)
707 "Actually perform import test. 709 "Actually perform import test.