From 9231460ac02a6ded0d6b198bb4a3dcc44968147a Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Mon, 5 Jan 2015 20:20:07 +0100 Subject: [PATCH] test-org-clocktable: fix batch testing * testing/lisp/test-org-clock.el (test-org-clock/clocktable): New function, refactor the original test sequence. (test-org-clock/clocktable1, test-org-clock/clocktable2): New tests using the new function. ert-deftest is a macro. Let-binding a defvar before it is defined causes the variable to be undefined later on, so the second test fails for Emacsen that do not perform eager macro expansion. --- testing/lisp/test-org-clock.el | 67 +++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 40 deletions(-) diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index 813b02f84..7af004691 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -84,7 +84,25 @@ contents. The clocktable doesn't appear in the buffer." ;;; Clocktable -(ert-deftest test-org-clock/clocktable () +(defun test-org-clock/clocktable (string) + (let ((org-clock-total-time-cell-format "*%s*")) + ;; Install Clock lines in "Foo". + (search-forward "** Foo") + (forward-line) + (insert (org-test-clock-create-clock "-2d 8:00" "-2d 13:00")) + (insert (org-test-clock-create-clock ". 8:00" "13:00")) + ;; Install Clock lines in "Bar". + (search-forward "** Bar") + (forward-line) + (insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00")) + (insert (org-test-clock-create-clock "-1d 8:00" "-1d 13:00")) + (insert (org-test-clock-create-clock "-1d 15:00" "-1d 18:00")) + (insert (org-test-clock-create-clock ". 15:00")) + ;; Previous two days. + (goto-char (point-min)) + (forward-line) + (test-org-clock-clocktable-contents-at-point string))) +(ert-deftest test-org-clock/clocktable1 () "Test clocktable specifications." ;; Relative time: Previous two days. (should @@ -97,25 +115,11 @@ contents. The clocktable doesn't appear in the buffer." | Foo | | 5:00 | | Bar | | 11:00 | " - (org-test-with-temp-text "* Relative times in clocktable\n** Foo\n** Bar\n" - (let ((org-clock-total-time-cell-format "*%s*")) - ;; Install Clock lines in "Foo". - (search-forward "** Foo") - (forward-line) - (insert (org-test-clock-create-clock "-2d 8:00" "-2d 13:00")) - (insert (org-test-clock-create-clock ". 8:00" "13:00")) - ;; Install Clock lines in "Bar". - (search-forward "** Bar") - (forward-line) - (insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00")) - (insert (org-test-clock-create-clock "-1d 8:00" "-1d 13:00")) - (insert (org-test-clock-create-clock "-1d 15:00" "-1d 18:00")) - (insert (org-test-clock-create-clock ". 15:00")) - ;; Previous two days. - (goto-char (point-min)) - (forward-line) - (test-org-clock-clocktable-contents-at-point - ":tstart \"\" :tend \"\" :indent nil"))))) + (org-test-with-temp-text + "* Relative times in clocktable\n** Foo\n** Bar\n" + (test-org-clock/clocktable ":tstart \"\" :tend \"\" :indent nil"))))) +(ert-deftest test-org-clock/clocktable2 () + "Test clocktable specifications." ;; Relative time: Yesterday until now. (should (equal @@ -127,26 +131,9 @@ contents. The clocktable doesn't appear in the buffer." | Foo | | 5:00 | | Bar | | 8:00 | " - (org-test-with-temp-text "* Relative times in clocktable\n** Foo\n** Bar\n" - (progn - ;; Install Clock lines in "Foo". - (search-forward "** Foo") - (forward-line) - (insert (org-test-clock-create-clock "-2d 8:00" "-2d 13:00")) - (insert (org-test-clock-create-clock ". 8:00" "13:00")) - ;; Install Clock lines in "Bar". - (search-forward "** Bar") - (forward-line) - (insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00")) - (insert (org-test-clock-create-clock "-1d 8:00" "-1d 13:00")) - (insert (org-test-clock-create-clock "-1d 15:00" "-1d 18:00")) - (insert (org-test-clock-create-clock ". 15:00")) - ;; Previous two days. - (goto-char (point-min)) - (forward-line) - (test-org-clock-clocktable-contents-at-point - ":tstart \"\" :tend \"\" :indent nil")))))) - + (org-test-with-temp-text + "* Relative times in clocktable\n** Foo\n** Bar\n" + (test-org-clock/clocktable ":tstart \"\" :tend \"\" :indent nil"))))) (provide 'test-org-clock) ;;; test-org-clock.el end here -- 2.11.4.GIT