diff options
| author | Glenn Morris | 2013-08-04 11:42:50 -0700 |
|---|---|---|
| committer | Glenn Morris | 2013-08-04 11:42:50 -0700 |
| commit | df0d73aa8da0a8cb6fd01e2f2604a6022e8f3d63 (patch) | |
| tree | 4ae400c7b47c2a10003c918a561389c745210eb9 | |
| parent | b309175d2d790fb8fc8d4a60ab957517a99ce09b (diff) | |
| download | emacs-df0d73aa8da0a8cb6fd01e2f2604a6022e8f3d63.tar.gz emacs-df0d73aa8da0a8cb6fd01e2f2604a6022e8f3d63.zip | |
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.
| -rw-r--r-- | test/ChangeLog | 8 | ||||
| -rw-r--r-- | test/automated/icalendar-tests.el | 83 |
2 files changed, 54 insertions, 37 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index d8b8fb661b5..9b6859e9ba6 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2013-08-04 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 | (icalendar-tests--do-test-cycle): Use with-current-buffer. | ||
| 8 | |||
| 1 | 2013-03-26 Fabián Ezequiel Gallina <fabian@anue.biz> | 9 | 2013-03-26 Fabián Ezequiel Gallina <fabian@anue.biz> |
| 2 | 10 | ||
| 3 | * automated/python-tests.el | 11 | * automated/python-tests.el |
diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index bca462da4d9..f83052f5ea1 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el | |||
| @@ -428,12 +428,16 @@ Argument EXPECTED-OUTPUT expected iCalendar result string. | |||
| 428 | 428 | ||
| 429 | European style input data must use german month names. American | 429 | European style input data must use german month names. American |
| 430 | and ISO style input data must use english month names." | 430 | and 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 | ;;; (message "Current time zone: %s" (current-time-zone)) |
| 437 | ;; Use this form so as not to rely on system tz database. | ||
| 438 | ;; Eg hydra.nixos.org. | ||
| 439 | (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3") | ||
| 440 | ;;; (message "Current time zone: %s" (current-time-zone)) | ||
| 437 | (when input-iso | 441 | (when input-iso |
| 438 | (let ((calendar-month-name-array | 442 | (let ((calendar-month-name-array |
| 439 | ["January" "February" "March" "April" "May" "June" "July" "August" | 443 | ["January" "February" "March" "April" "May" "June" "July" "August" |
| @@ -461,8 +465,8 @@ and ISO style input data must use english month names." | |||
| 461 | "Saturday"])) | 465 | "Saturday"])) |
| 462 | (setq calendar-date-style 'american) | 466 | (setq calendar-date-style 'american) |
| 463 | (icalendar-tests--do-test-export input-american expected-output)))) | 467 | (icalendar-tests--do-test-export input-american expected-output)))) |
| 464 | ;; restore time-zone if something went terribly wrong | 468 | ;; restore time-zone even if something went terribly wrong |
| 465 | (set-time-zone-rule tz)))) | 469 | (setenv "TZ" tz)))) |
| 466 | 470 | ||
| 467 | (defun icalendar-tests--do-test-export (input expected-output) | 471 | (defun icalendar-tests--do-test-export (input expected-output) |
| 468 | "Actually perform export test. | 472 | "Actually perform export test. |
| @@ -671,37 +675,43 @@ Argument INPUT icalendar event string. | |||
| 671 | Argument EXPECTED-ISO expected iso style diary string. | 675 | Argument EXPECTED-ISO expected iso style diary string. |
| 672 | Argument EXPECTED-EUROPEAN expected european style diary string. | 676 | Argument EXPECTED-EUROPEAN expected european style diary string. |
| 673 | Argument EXPECTED-AMERICAN expected american style diary string." | 677 | Argument EXPECTED-AMERICAN expected american style diary string." |
| 674 | (let ((timezone (cadr (current-time-zone)))) | 678 | (let ((timezone (getenv "TZ"))) |
| 675 | (set-time-zone-rule "CET") | 679 | (unwind-protect |
| 676 | (with-temp-buffer | 680 | (progn |
| 677 | (if (string-match "^BEGIN:VCALENDAR" input) | 681 | ;;; (message "Current time zone: %s" (current-time-zone)) |
| 678 | (insert input) | 682 | ;; Use this form so as not to rely on system tz database. |
| 679 | (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n") | 683 | ;; Eg hydra.nixos.org. |
| 680 | (insert "VERSION:2.0\nBEGIN:VEVENT\n") | 684 | (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3") |
| 681 | (insert input) | 685 | ;;; (message "Current time zone: %s" (current-time-zone)) |
| 682 | (unless (eq (char-before) ?\n) | 686 | (with-temp-buffer |
| 683 | (insert "\n")) | 687 | (if (string-match "^BEGIN:VCALENDAR" input) |
| 684 | (insert "END:VEVENT\nEND:VCALENDAR\n")) | 688 | (insert input) |
| 685 | (let ((icalendar-import-format "%s%d%l%o%t%u%c%U") | 689 | (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n") |
| 686 | (icalendar-import-format-summary "%s") | 690 | (insert "VERSION:2.0\nBEGIN:VEVENT\n") |
| 687 | (icalendar-import-format-location "\n Location: %s") | 691 | (insert input) |
| 688 | (icalendar-import-format-description "\n Desc: %s") | 692 | (unless (eq (char-before) ?\n) |
| 689 | (icalendar-import-format-organizer "\n Organizer: %s") | 693 | (insert "\n")) |
| 690 | (icalendar-import-format-status "\n Status: %s") | 694 | (insert "END:VEVENT\nEND:VCALENDAR\n")) |
| 691 | (icalendar-import-format-url "\n URL: %s") | 695 | (let ((icalendar-import-format "%s%d%l%o%t%u%c%U") |
| 692 | (icalendar-import-format-class "\n Class: %s") | 696 | (icalendar-import-format-summary "%s") |
| 693 | (icalendar-import-format-uid "\n UID: %s") | 697 | (icalendar-import-format-location "\n Location: %s") |
| 694 | calendar-date-style) | 698 | (icalendar-import-format-description "\n Desc: %s") |
| 695 | (when expected-iso | 699 | (icalendar-import-format-organizer "\n Organizer: %s") |
| 696 | (setq calendar-date-style 'iso) | 700 | (icalendar-import-format-status "\n Status: %s") |
| 697 | (icalendar-tests--do-test-import input expected-iso)) | 701 | (icalendar-import-format-url "\n URL: %s") |
| 698 | (when expected-european | 702 | (icalendar-import-format-class "\n Class: %s") |
| 699 | (setq calendar-date-style 'european) | 703 | (icalendar-import-format-uid "\n UID: %s") |
| 700 | (icalendar-tests--do-test-import input expected-european)) | 704 | calendar-date-style) |
| 701 | (when expected-american | 705 | (when expected-iso |
| 702 | (setq calendar-date-style 'american) | 706 | (setq calendar-date-style 'iso) |
| 703 | (icalendar-tests--do-test-import input expected-american)))) | 707 | (icalendar-tests--do-test-import input expected-iso)) |
| 704 | (set-time-zone-rule timezone))) | 708 | (when expected-european |
| 709 | (setq calendar-date-style 'european) | ||
| 710 | (icalendar-tests--do-test-import input expected-european)) | ||
| 711 | (when expected-american | ||
| 712 | (setq calendar-date-style 'american) | ||
| 713 | (icalendar-tests--do-test-import input expected-american))))) | ||
| 714 | (setenv "TZ" timezone)))) | ||
| 705 | 715 | ||
| 706 | (defun icalendar-tests--do-test-import (input expected-output) | 716 | (defun icalendar-tests--do-test-import (input expected-output) |
| 707 | "Actually perform import test. | 717 | "Actually perform import test. |
| @@ -1194,8 +1204,7 @@ Argument INPUT icalendar event string." | |||
| 1194 | (should (string= org-input cycled))))) | 1204 | (should (string= org-input cycled))))) |
| 1195 | ;; clean up | 1205 | ;; clean up |
| 1196 | (kill-buffer (find-buffer-visiting temp-diary)) | 1206 | (kill-buffer (find-buffer-visiting temp-diary)) |
| 1197 | (save-excursion | 1207 | (with-current-buffer (find-buffer-visiting temp-ics) |
| 1198 | (set-buffer (find-buffer-visiting temp-ics)) | ||
| 1199 | (set-buffer-modified-p nil) | 1208 | (set-buffer-modified-p nil) |
| 1200 | (kill-buffer (current-buffer))) | 1209 | (kill-buffer (current-buffer))) |
| 1201 | (delete-file temp-diary) | 1210 | (delete-file temp-diary) |