testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 21:21:37 +00:00
|
|
|
|
;;; test-org-clock.el --- Tests for org-clock.el -*- lexical-binding: t; -*-
|
2012-11-30 15:28:00 +00:00
|
|
|
|
|
2019-01-01 10:50:56 +00:00
|
|
|
|
;; Copyright (C) 2012, 2014, 2015, 2019 Nicolas Goaziou
|
2012-11-30 15:28:00 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
|
|
|
|
|
|
|
|
|
|
;; Released under the GNU General Public License version 3
|
2021-03-20 07:27:57 +00:00
|
|
|
|
;; see: https://www.gnu.org/licenses/gpl-3.0.html
|
2012-11-30 15:28:00 +00:00
|
|
|
|
|
|
|
|
|
;;;; Comments
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 21:21:37 +00:00
|
|
|
|
(require 'org-duration)
|
|
|
|
|
(require 'org-clock)
|
|
|
|
|
|
2012-11-30 15:28:00 +00:00
|
|
|
|
(defun org-test-clock-create-timestamp (input &optional inactive with-time)
|
|
|
|
|
"Create a timestamp out of a date/time prompt string.
|
|
|
|
|
|
|
|
|
|
INPUT is a string as expected in a date/time prompt, i.e \"+2d\"
|
|
|
|
|
or \"2/5\".
|
|
|
|
|
|
|
|
|
|
When optional argument INACTIVE is non-nil, return an inactive
|
2015-02-20 10:35:16 +00:00
|
|
|
|
timestamp. When optional argument WITH-TIME is non-nil, also
|
2012-11-30 15:28:00 +00:00
|
|
|
|
insert hours and minutes.
|
|
|
|
|
|
|
|
|
|
Return the timestamp as a string."
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(let ((time (decode-time
|
Use `org-encode-time' helper macro
* lisp/ol.el (org-store-link):
* lisp/org-agenda.el (org-agenda-get-timestamps)
(org-agenda-get-progress, agenda-bulk-action):
* lisp/org-capture.el (org-capture-fill-template):
* lisp/org-clock.el (org-clock-get-sum-start)
(org-clock-special-range, org-clocktable-shift)
(org-clocktable-steps):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-datetree.el (org-datetree-find-iso-week-create)
(org-datetree-insert-line):
* lisp/org-element.el (org-element-timestamp-interpreter):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-matcher-time):
* lisp/org.el (org-current-time, org-current-effective-time)
(org-add-planning-info, org-read-date, org-read-date-display)
(org-read-date-analyze, org-eval-in-calendar)
(org-calendar-select, org-display-custom-time)
(org-calendar-select-mouse, org-time-string-to-time)
(org-time-from-absolute, org-at-clock-log-p)
(org-date-from-calendar, org-get-cursor-date)
(org-timestamp-to-time):
* testing/lisp/test-org-clock.el (org-test-clock-create-timestamp):
* lisp/ox-icalendar.el (org-icalendar-convert-timestamp):
Avoid direct calls of `encode-time', use `org-encode-time' instead.
Org supports Emacs-26, but the recommended way to call `encode-time'
changed in Emacs-27. In Emacs-29 DST and TZ elements of the single list
arguments became optional. In Org it is still convenient to call the
function with separate arguments without explicit DST and TZ arguments.
The `org-encode-time' should mitigate attempts to modernize Org code
directly in the Emacs repository.
2022-05-02 14:19:59 +00:00
|
|
|
|
(org-encode-time
|
|
|
|
|
(org-fix-decoded-time
|
|
|
|
|
(org-read-date-analyze
|
|
|
|
|
input nil (decode-time (current-time))))))))
|
2012-11-30 15:28:00 +00:00
|
|
|
|
(list 'timestamp
|
|
|
|
|
(list :type (if inactive 'inactive 'active)
|
|
|
|
|
:minute-start (and with-time (nth 1 time))
|
|
|
|
|
:hour-start (and with-time (nth 2 time))
|
|
|
|
|
:day-start (nth 3 time)
|
|
|
|
|
:month-start (nth 4 time)
|
|
|
|
|
:year-start (nth 5 time))))))
|
|
|
|
|
|
|
|
|
|
(defun org-test-clock-create-clock (input1 &optional input2)
|
|
|
|
|
"Create a clock line out of two date/time prompts.
|
|
|
|
|
|
|
|
|
|
INPUT1 and INPUT2 are strings as expected in a date/time prompt,
|
|
|
|
|
i.e \"+2d\" or \"2/5\". They respectively refer to start and end
|
|
|
|
|
range. INPUT2 can be omitted if clock hasn't finished yet.
|
|
|
|
|
|
|
|
|
|
Return the clock line as a string."
|
|
|
|
|
(let* ((beg (org-test-clock-create-timestamp input1 t t))
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(end (and input2 (org-test-clock-create-timestamp input2 t t)))
|
2017-07-07 16:23:10 +00:00
|
|
|
|
(sec-diff (and input2
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(floor (- (org-time-string-to-seconds end)
|
|
|
|
|
(org-time-string-to-seconds beg))))))
|
2012-11-30 15:28:00 +00:00
|
|
|
|
(concat org-clock-string " " beg
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(when end
|
|
|
|
|
(concat "--" end " => "
|
|
|
|
|
(format "%2d:%02d"
|
|
|
|
|
(/ sec-diff 3600)
|
|
|
|
|
(/ (mod sec-diff 3600) 60))))
|
|
|
|
|
"\n")))
|
2012-11-30 15:28:00 +00:00
|
|
|
|
|
2017-02-18 19:55:40 +00:00
|
|
|
|
(defun test-org-clock-clocktable-contents (options &optional initial)
|
|
|
|
|
"Return contents of a Clock table for current buffer
|
|
|
|
|
|
|
|
|
|
OPTIONS is a string of Clock table options. Optional argument
|
|
|
|
|
INITIAL is a string specifying initial contents within the Clock
|
|
|
|
|
table.
|
|
|
|
|
|
|
|
|
|
Caption is ignored in contents. The clocktable doesn't appear in
|
|
|
|
|
the buffer."
|
|
|
|
|
(declare (indent 2))
|
|
|
|
|
(goto-char (point-min))
|
2012-11-30 15:28:00 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(insert "#+BEGIN: clocktable " options "\n")
|
2017-02-18 19:55:40 +00:00
|
|
|
|
(when initial (insert initial))
|
|
|
|
|
(unless (string-suffix-p "\n" initial) (insert "\n"))
|
2015-02-20 10:35:16 +00:00
|
|
|
|
(insert "#+END:\n"))
|
2012-11-30 15:28:00 +00:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(save-excursion
|
2017-02-17 14:00:07 +00:00
|
|
|
|
(let ((org-duration-format 'h:mm)) (org-update-dblock))
|
|
|
|
|
(forward-line)
|
|
|
|
|
;; Skip caption.
|
|
|
|
|
(when (looking-at "#\\+CAPTION:") (forward-line))
|
2017-02-18 19:55:40 +00:00
|
|
|
|
(buffer-substring-no-properties
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(point) (progn (search-forward "#+END:") (line-end-position 0))))
|
2012-11-30 15:28:00 +00:00
|
|
|
|
;; Remove clocktable.
|
2015-02-20 10:35:16 +00:00
|
|
|
|
(delete-region (point) (search-forward "#+END:\n"))))
|
2012-11-30 15:28:00 +00:00
|
|
|
|
|
2016-05-11 16:44:02 +00:00
|
|
|
|
|
|
|
|
|
;;; Clock drawer
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-clock/into-drawer ()
|
|
|
|
|
"Test `org-clock-into-drawer' specifications."
|
|
|
|
|
;; When `org-clock-into-drawer' is nil, do not use a clock drawer.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-log-into-drawer nil))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(org-clock-into-drawer))))
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-log-into-drawer t))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(org-clock-into-drawer))))
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-log-into-drawer "BAR"))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(org-clock-into-drawer))))
|
|
|
|
|
;; When `org-clock-into-drawer' is a string, use it
|
|
|
|
|
;; unconditionally.
|
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer "FOO")
|
|
|
|
|
(org-log-into-drawer nil))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer "FOO")
|
|
|
|
|
(org-log-into-drawer t))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer "FOO")
|
|
|
|
|
(org-log-into-drawer "BAR"))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
;; When `org-clock-into-drawer' is an integer, return it.
|
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-test-with-temp-text "* H"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(let ((org-clock-into-drawer 1)
|
|
|
|
|
(org-log-into-drawer nil))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-test-with-temp-text "* H"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(let ((org-clock-into-drawer 1)
|
|
|
|
|
(org-log-into-drawer t))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-test-with-temp-text "* H"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(let ((org-clock-into-drawer 1)
|
|
|
|
|
(org-log-into-drawer "BAR"))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
;; Otherwise, any non-nil value defaults to `org-log-into-drawer' or
|
|
|
|
|
;; "LOGBOOK" if it is nil.
|
|
|
|
|
(should
|
|
|
|
|
(equal "LOGBOOK"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer t)
|
|
|
|
|
(org-log-into-drawer nil))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "LOGBOOK"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer t)
|
|
|
|
|
(org-log-into-drawer t))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer t)
|
|
|
|
|
(org-log-into-drawer "FOO"))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
;; A non-nil "CLOCK_INTO_DRAWER" property overrides
|
|
|
|
|
;; `org-clock-into-drawer' value.
|
|
|
|
|
(should
|
|
|
|
|
(equal "LOGBOOK"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: t\n:END:"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
|
|
|
|
(org-log-into-drawer nil))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: FOO\n:END:"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
|
|
|
|
(org-log-into-drawer nil))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: nil\n:END:"
|
|
|
|
|
(let ((org-clock-into-drawer t)
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-log-into-drawer nil))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(org-clock-into-drawer))))
|
|
|
|
|
;; "CLOCK_INTO_DRAWER" can be inherited.
|
|
|
|
|
(should
|
|
|
|
|
(equal "LOGBOOK"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: t\n:END:\n** H2<point>"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
|
|
|
|
(org-log-into-drawer nil))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: FOO\n:END:\n** H2<point>"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
|
|
|
|
(org-log-into-drawer nil))
|
|
|
|
|
(org-clock-into-drawer)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: nil\n:END:\n** H2<point>"
|
|
|
|
|
(let ((org-clock-into-drawer t)
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-log-into-drawer nil))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(org-clock-into-drawer)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-clock/drawer-name ()
|
|
|
|
|
"Test `org-clock-drawer-name' specifications."
|
|
|
|
|
;; A nil value for `org-clock-into-drawer' means no drawer is
|
|
|
|
|
;; expected whatsoever.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-log-into-drawer nil))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(org-clock-drawer-name))))
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-log-into-drawer t))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(org-clock-drawer-name))))
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer nil)
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-log-into-drawer "FOO"))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(org-clock-drawer-name))))
|
|
|
|
|
;; A string value for `org-clock-into-drawer' means to use it
|
|
|
|
|
;; unconditionally.
|
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer "FOO")
|
|
|
|
|
(org-log-into-drawer nil))
|
|
|
|
|
(org-clock-drawer-name)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer "FOO")
|
|
|
|
|
(org-log-into-drawer t))
|
|
|
|
|
(org-clock-drawer-name)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer "FOO")
|
|
|
|
|
(org-log-into-drawer "BAR"))
|
|
|
|
|
(org-clock-drawer-name)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
;; When the value in `org-clock-into-drawer' is a number, re-use
|
|
|
|
|
;; `org-log-into-drawer' or use default "LOGBOOK" value.
|
|
|
|
|
(should
|
|
|
|
|
(equal "FOO"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer 1)
|
|
|
|
|
(org-log-into-drawer "FOO"))
|
|
|
|
|
(org-clock-drawer-name)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "LOGBOOK"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer 1)
|
|
|
|
|
(org-log-into-drawer t))
|
|
|
|
|
(org-clock-drawer-name)))))
|
2016-05-11 16:44:02 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "LOGBOOK"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text "* H"
|
|
|
|
|
(let ((org-clock-into-drawer 1)
|
|
|
|
|
(org-log-into-drawer nil))
|
|
|
|
|
(org-clock-drawer-name))))))
|
2012-11-30 15:28:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Clocktable
|
|
|
|
|
|
2018-12-23 05:35:38 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/insert ()
|
|
|
|
|
"Test insert clocktable dynamic block with `org-dynamic-block-insert-dblock'."
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2019-03-04 22:16:48 +00:00
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+--------|
|
|
|
|
|
| *Total time* | *1:00* |
|
|
|
|
|
|--------------+--------|
|
|
|
|
|
| H1 | 1:00 |"
|
|
|
|
|
(org-test-with-temp-text "* H1\n<point>"
|
2018-12-23 05:35:38 +00:00
|
|
|
|
(insert (org-test-clock-create-clock ". 1:00" ". 2:00"))
|
|
|
|
|
|
|
|
|
|
(goto-line 2)
|
|
|
|
|
(require 'org-clock)
|
|
|
|
|
(org-dynamic-block-insert-dblock "clocktable")
|
|
|
|
|
|
|
|
|
|
(goto-line 1)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(save-excursion
|
|
|
|
|
(when (search-forward "#+CAPTION:") (forward-line))
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(point) (progn (search-forward "#+END:") (line-end-position 0))))
|
|
|
|
|
(delete-region (point) (search-forward "#+END:\n")))))))
|
|
|
|
|
|
2018-04-28 22:22:53 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/ranges ()
|
|
|
|
|
"Test ranges in Clock table."
|
|
|
|
|
;; Relative time: Previous two days.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"| Headline | Time | |
|
|
|
|
|
|------------------------------+--------+------|
|
|
|
|
|
| *Total time* | *8:00* | |
|
|
|
|
|
|------------------------------+--------+------|
|
|
|
|
|
| Relative times in clocktable | 8:00 | |
|
|
|
|
|
| Foo | | 8:00 |"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Relative times in clocktable\n** Foo\n<point>"
|
|
|
|
|
(insert (org-test-clock-create-clock "-3d 8:00" "-3d 12:00"))
|
|
|
|
|
(insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00"))
|
|
|
|
|
(insert (org-test-clock-create-clock "-1d 8:00" "-1d 13:00"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":tstart \"<-2d>\" :tend \"<today>\" :indent nil"))))
|
|
|
|
|
;; Relative time: Yesterday until now.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"| Headline | Time | |
|
|
|
|
|
|------------------------------+--------+------|
|
|
|
|
|
| *Total time* | *6:00* | |
|
|
|
|
|
|------------------------------+--------+------|
|
|
|
|
|
| Relative times in clocktable | 6:00 | |
|
|
|
|
|
| Foo | | 6:00 |"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Relative times in clocktable\n** Foo\n<point>"
|
|
|
|
|
(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 ". 1:00" ". 2:00"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":tstart \"<yesterday>\" :tend \"<tomorrow>\" :indent nil"))))
|
|
|
|
|
;; Test `untilnow' block.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"| Headline | Time | |
|
|
|
|
|
|------------------------------+--------+------|
|
|
|
|
|
| *Total time* | *6:00* | |
|
|
|
|
|
|------------------------------+--------+------|
|
|
|
|
|
| Relative times in clocktable | 6:00 | |
|
|
|
|
|
| Foo | | 6:00 |"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Relative times in clocktable\n** Foo\n<point>"
|
|
|
|
|
(insert (org-test-clock-create-clock "-10y 15:00" "-10y 18:00"))
|
|
|
|
|
(insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00"))
|
|
|
|
|
(test-org-clock-clocktable-contents ":block untilnow :indent nil")))))
|
2018-04-26 18:55:27 +00:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-clock/clocktable/match ()
|
|
|
|
|
"Test \":match\" parameter in Clock table."
|
|
|
|
|
;; Test match filtering.
|
2012-11-30 15:28:00 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2018-04-28 00:47:35 +00:00
|
|
|
|
"| Headline | Time | |
|
|
|
|
|
|--------------+--------+------|
|
2018-04-26 18:55:27 +00:00
|
|
|
|
| *Total time* | *2:00* | |
|
2018-04-28 00:47:35 +00:00
|
|
|
|
|--------------+--------+------|
|
|
|
|
|
| H1 | | 2:00 |"
|
2018-04-26 18:55:27 +00:00
|
|
|
|
(org-test-with-temp-text "** H1\n\n*** H2 :tag:\n\n*** H3\n<point>"
|
2021-03-15 02:06:22 +00:00
|
|
|
|
(insert (org-test-clock-create-clock ". 8:00" ". 9:00"))
|
2018-04-26 18:55:27 +00:00
|
|
|
|
(goto-line 4)
|
2021-03-15 02:06:22 +00:00
|
|
|
|
(insert (org-test-clock-create-clock ". 9:00" ". 11:00"))
|
2018-04-26 18:55:27 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":match \"tag\" :indent nil")))))
|
2017-02-13 20:24:40 +00:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-clock/clocktable/tags ()
|
|
|
|
|
"Test \":tags\" parameter in Clock table."
|
2018-04-26 18:55:27 +00:00
|
|
|
|
;; Test tags column.
|
2016-08-19 22:22:13 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2018-04-28 00:47:35 +00:00
|
|
|
|
"| Tags | Headline | Time | |
|
|
|
|
|
|------+--------------+--------+------|
|
2018-04-26 18:55:27 +00:00
|
|
|
|
| | *Total time* | *1:00* | |
|
2018-04-28 00:47:35 +00:00
|
|
|
|
|------+--------------+--------+------|
|
|
|
|
|
| tag | H1 | | 1:00 |"
|
2018-04-26 18:55:27 +00:00
|
|
|
|
(org-test-with-temp-text "** H1 :tag:\n\n*** H2 \n<point>"
|
2016-08-19 22:22:13 +00:00
|
|
|
|
(insert (org-test-clock-create-clock ". 1:00" ". 2:00"))
|
|
|
|
|
(goto-line 4)
|
2018-04-26 18:55:27 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":tags t :indent nil")))))
|
2017-02-13 20:24:40 +00:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-clock/clocktable/scope ()
|
|
|
|
|
"Test \":scope\" parameter in Clock table."
|
2016-10-27 09:42:27 +00:00
|
|
|
|
;; Test `file-with-archives' scope. In particular, preserve "TBLFM"
|
|
|
|
|
;; line, and ignore "file" column.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-12-03 07:57:37 +00:00
|
|
|
|
"| Headline | Time | |
|
|
|
|
|
|--------------+--------+-----|
|
|
|
|
|
| *Total time* | *8:40* | foo |
|
|
|
|
|
|--------------+--------+-----|
|
|
|
|
|
| Test | 8:40 | foo |
|
2017-02-18 19:55:40 +00:00
|
|
|
|
#+TBLFM: $3=string(\"foo\")"
|
2016-10-27 09:42:27 +00:00
|
|
|
|
(org-test-with-temp-text-in-file
|
2017-02-13 20:24:40 +00:00
|
|
|
|
"* Test
|
2017-12-03 07:57:37 +00:00
|
|
|
|
CLOCK: [2012-03-29 Thu 8:00]--[2012-03-29 Thu 16:40] => 8:40"
|
2017-02-18 19:55:40 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":scope file-with-archives"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
"#+TBLFM: $3=string(\"foo\")"))))
|
2017-03-06 16:57:31 +00:00
|
|
|
|
;; Test "function" scope.
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
|
|
|
|
(regexp-quote "| ALL *Total time* | *1:00* |")
|
|
|
|
|
(org-test-with-temp-text-in-file
|
2018-11-01 18:05:22 +00:00
|
|
|
|
"* Test
|
2017-03-06 16:57:31 +00:00
|
|
|
|
CLOCK: [2012-03-29 Thu 16:00]--[2012-03-29 Thu 17:00] => 1:00"
|
|
|
|
|
(let ((the-file (buffer-file-name)))
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(org-test-with-temp-text-in-file ""
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
(format ":scope (lambda () (list %S))" the-file))))))))
|
2017-02-13 20:24:40 +00:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-clock/clocktable/maxlevel ()
|
|
|
|
|
"Test \":maxlevel\" parameter in Clock table."
|
|
|
|
|
(should
|
2017-05-27 16:15:05 +00:00
|
|
|
|
(equal "| Headline | Time | |
|
|
|
|
|
|--------------+--------+------|
|
|
|
|
|
| *Total time* | *6:00* | |
|
|
|
|
|
|--------------+--------+------|
|
|
|
|
|
| Foo | 6:00 | |
|
|
|
|
|
| \\_ Bar | | 2:00 |"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"* Foo
|
2017-02-13 20:24:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 11:09]--[2016-12-28 Wed 15:09] => 4:00
|
|
|
|
|
** Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 3"))))
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "| Headline | Time | |
|
|
|
|
|
|--------------+--------+------|
|
|
|
|
|
| *Total time* | *6:00* | |
|
|
|
|
|
|--------------+--------+------|
|
|
|
|
|
| Foo | 6:00 | |
|
2017-02-18 19:55:40 +00:00
|
|
|
|
| \\_ Bar | | 2:00 |"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"* Foo
|
2017-02-13 20:24:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 11:09]--[2016-12-28 Wed 15:09] => 4:00
|
|
|
|
|
** Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 2"))))
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal "| Headline | Time |
|
|
|
|
|
|--------------+--------|
|
|
|
|
|
| *Total time* | *6:00* |
|
|
|
|
|
|--------------+--------|
|
2017-02-18 19:55:40 +00:00
|
|
|
|
| Foo | 6:00 |"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"* Foo
|
2017-02-13 20:24:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 11:09]--[2016-12-28 Wed 15:09] => 4:00
|
|
|
|
|
** Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 1"))))
|
2017-02-13 20:24:40 +00:00
|
|
|
|
;; Special ":maxlevel 0" case: only report total file time.
|
|
|
|
|
(should
|
|
|
|
|
(equal "| Headline | Time |
|
|
|
|
|
|--------------+--------|
|
|
|
|
|
| *Total time* | *6:00* |
|
2017-02-18 19:55:40 +00:00
|
|
|
|
|--------------+--------|"
|
2017-02-13 20:24:40 +00:00
|
|
|
|
(org-test-with-temp-text
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"* Foo
|
2017-02-13 20:24:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 11:09]--[2016-12-28 Wed 15:09] => 4:00
|
|
|
|
|
** Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 0")))))
|
2017-02-13 20:24:40 +00:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-clock/clocktable/formula ()
|
|
|
|
|
"Test \":formula\" parameter in Clock table."
|
2016-12-29 00:19:00 +00:00
|
|
|
|
;; Test ":formula %". Handle various duration formats.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"| Headline | Time | % |
|
|
|
|
|
|--------------+--------+-------|
|
|
|
|
|
| *Total time* | *6:00* | 100.0 |
|
|
|
|
|
|--------------+--------+-------|
|
|
|
|
|
| Foo | 4:00 | 66.7 |
|
2017-02-18 19:55:40 +00:00
|
|
|
|
| Bar | 2:00 | 33.3 |"
|
2016-12-29 00:19:00 +00:00
|
|
|
|
(org-test-with-temp-text
|
2017-02-13 20:24:40 +00:00
|
|
|
|
"* Foo
|
2016-12-29 00:19:00 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 11:09]--[2016-12-28 Wed 15:09] => 4:00
|
|
|
|
|
* Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 1 :formula %"))))
|
2016-12-29 00:19:00 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"| Headline | Time | % |
|
|
|
|
|
|--------------+---------+-------|
|
|
|
|
|
| *Total time* | *28:00* | 100.0 |
|
|
|
|
|
|--------------+---------+-------|
|
|
|
|
|
| Foo | 26:00 | 92.9 |
|
|
|
|
|
| Bar | 2:00 | 7.1 |"
|
2016-12-29 00:19:00 +00:00
|
|
|
|
(org-test-with-temp-text
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"* Foo
|
2016-12-29 00:19:00 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00
|
|
|
|
|
* Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
|
2017-03-19 09:59:52 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 1 :formula %"))))
|
|
|
|
|
;; Properly align column with different depths.
|
|
|
|
|
(should
|
|
|
|
|
(equal "| Headline | Time | | | % |
|
|
|
|
|
|---------------+--------+------+------+-------|
|
|
|
|
|
| *Total time* | *1:00* | | | 100.0 |
|
|
|
|
|
|---------------+--------+------+------+-------|
|
|
|
|
|
| foo | 1:00 | | | 100.0 |
|
|
|
|
|
| \\_ sub | | 0:15 | | 25.0 |
|
|
|
|
|
| \\_ sub2 | | 0:15 | | 25.0 |
|
|
|
|
|
| \\_ sub3 | | 0:30 | | 50.0 |
|
|
|
|
|
| \\_ subsub1 | | | 0:15 | 25.0 |
|
|
|
|
|
| \\_ subsub1 | | | 0:15 | 25.0 |"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* foo
|
2017-03-19 09:59:52 +00:00
|
|
|
|
** sub
|
|
|
|
|
:LOGBOOK:
|
|
|
|
|
CLOCK: [2017-03-18 Sat 15:00]--[2017-03-18 Sat 15:15] => 0:15
|
|
|
|
|
:END:
|
|
|
|
|
** sub2
|
|
|
|
|
:LOGBOOK:
|
|
|
|
|
CLOCK: [2017-03-18 Sat 15:15]--[2017-03-18 Sat 15:30] => 0:15
|
|
|
|
|
:END:
|
|
|
|
|
** sub3
|
|
|
|
|
*** subsub1
|
|
|
|
|
:LOGBOOK:
|
|
|
|
|
CLOCK: [2017-03-18 Sat 13:00]--[2017-03-18 Sat 13:15] => 0:15
|
|
|
|
|
:END:
|
|
|
|
|
*** subsub1
|
|
|
|
|
:LOGBOOK:
|
|
|
|
|
CLOCK: [2017-03-18 Sat 14:00]--[2017-03-18 Sat 14:15] => 0:15
|
|
|
|
|
:END:"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 3 :formula %")))))
|
2012-11-30 15:28:00 +00:00
|
|
|
|
|
2017-02-17 14:00:07 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/lang ()
|
|
|
|
|
"Test \":lang\" parameter in Clock table."
|
|
|
|
|
;; Test foreign translation
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| *Total time* | *26:00* |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| Foo | 26:00 |"
|
2017-02-17 14:00:07 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 1 :lang en"))))
|
2017-02-17 14:00:07 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"| En-tête | Durée |
|
|
|
|
|
|----------------+---------|
|
|
|
|
|
| *Durée totale* | *26:00* |
|
|
|
|
|
|----------------+---------|
|
|
|
|
|
| Foo | 26:00 |"
|
2017-02-17 14:00:07 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 1 :lang fr"))))
|
2017-02-17 14:00:07 +00:00
|
|
|
|
;; No :lang parameter is equivalent to "en".
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 1 :lang en"))
|
2017-02-17 14:00:07 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 1"))))
|
2017-02-17 14:00:07 +00:00
|
|
|
|
;; Unknown translation fall backs to "en".
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| *Total time* | *26:00* |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| Foo | 26:00 |"
|
2017-02-17 14:00:07 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":maxlevel 1 :lang foo")))))
|
2017-02-17 14:00:07 +00:00
|
|
|
|
|
2017-04-17 08:03:23 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/link ()
|
|
|
|
|
"Test \":link\" parameter in Clock table."
|
|
|
|
|
;; If there is no file attached to the document, link directly to
|
|
|
|
|
;; the headline.
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(should
|
2020-02-19 17:03:53 +00:00
|
|
|
|
(string-match-p "| +\\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":link t"))))
|
|
|
|
|
;; Otherwise, link to the headline in the current file.
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
2020-02-19 17:03:53 +00:00
|
|
|
|
"| \\[\\[file:filename::\\*Foo]\\[Foo]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(org-test-with-temp-text-in-file
|
|
|
|
|
"* Foo
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(let ((file (buffer-file-name)))
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
(regexp-quote file) "filename"
|
|
|
|
|
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
|
|
|
|
(org-table-align)
|
|
|
|
|
(buffer-substring-no-properties (point-min) (point-max)))))
|
|
|
|
|
;; Ignore TODO keyword, priority cookie, COMMENT and tags in
|
|
|
|
|
;; headline.
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
2020-02-19 17:03:53 +00:00
|
|
|
|
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* TODO Foo
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
2020-02-19 17:03:53 +00:00
|
|
|
|
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* [#A] Foo
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
2020-02-19 17:03:53 +00:00
|
|
|
|
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* COMMENT Foo
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":link t"))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
2020-02-19 17:03:53 +00:00
|
|
|
|
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo :tag:
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
|
|
|
|
;; Remove statistics cookie from headline description.
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
2020-02-19 17:03:53 +00:00
|
|
|
|
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo [50%]
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
2020-02-19 17:03:53 +00:00
|
|
|
|
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo [1/2]
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
|
|
|
|
;; Replace links with their description, or turn them into plain
|
|
|
|
|
;; links if there is no description.
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
2020-02-19 17:03:53 +00:00
|
|
|
|
"| \\[\\[\\*Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\\\[Org mode\\\\]\\\\]]\\[Foo Org mode]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo [[https://orgmode.org][Org mode]]
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
2020-02-19 17:03:53 +00:00
|
|
|
|
"| \\[\\[\\*Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\]]\\[Foo https://orgmode\\.org]] +| 26:00 +|"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo [[https://orgmode.org]]
|
2017-04-17 08:03:23 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
2019-12-22 13:51:31 +00:00
|
|
|
|
(test-org-clock-clocktable-contents ":link t :lang en")))))
|
2017-04-17 08:03:23 +00:00
|
|
|
|
|
2017-02-18 13:54:43 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/compact ()
|
|
|
|
|
"Test \":compact\" parameter in Clock table."
|
|
|
|
|
;; With :compact, all headlines are in the same column.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| *Total time* | *26:00* |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| Foo | 26:00 |"
|
2017-02-18 13:54:43 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":compact t"))))
|
2017-02-18 13:54:43 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| *Total time* | *52:00* |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| Foo | 52:00 |
|
|
|
|
|
| \\_ Bar | 26:00 |"
|
2017-02-18 13:54:43 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00
|
|
|
|
|
** Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":compact t"))))
|
2017-02-18 13:54:43 +00:00
|
|
|
|
;; :maxlevel does not affect :compact parameter.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| *Total time* | *52:00* |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| Foo | 52:00 |
|
|
|
|
|
| \\_ Bar | 26:00 |"
|
2017-02-18 13:54:43 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00
|
|
|
|
|
** Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":compact t :maxlevel 2"))))
|
2017-02-18 13:54:43 +00:00
|
|
|
|
;; :compact implies a non-nil :indent parameter.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| *Total time* | *52:00* |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| Foo | 52:00 |
|
|
|
|
|
| \\_ Bar | 26:00 |"
|
2017-02-18 13:54:43 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00
|
|
|
|
|
** Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":compact t :indent nil"))))
|
2017-02-18 13:54:43 +00:00
|
|
|
|
;; :compact implies a nil :level parameter.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-02-18 19:55:40 +00:00
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| *Total time* | *52:00* |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| Foo | 52:00 |
|
|
|
|
|
| \\_ Bar | 26:00 |"
|
2017-02-18 13:54:43 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00
|
|
|
|
|
** Bar
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":compact t :level t")))))
|
2017-02-18 13:54:43 +00:00
|
|
|
|
|
2017-02-18 19:22:30 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/properties ()
|
|
|
|
|
"Test \":properties\" parameter in Clock table."
|
|
|
|
|
;; Include a new column with list properties.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-05-27 16:15:05 +00:00
|
|
|
|
"| A | Headline | Time |
|
|
|
|
|
|---+--------------+---------|
|
|
|
|
|
| | *Total time* | *26:00* |
|
|
|
|
|
|---+--------------+---------|
|
|
|
|
|
| 1 | Foo | 26:00 |"
|
2017-02-18 19:22:30 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":properties (\"A\")"))))
|
2017-02-18 19:22:30 +00:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"| A | Headline | Time | |
|
|
|
|
|
|---+--------------+---------+-------|
|
|
|
|
|
| | *Total time* | *52:00* | |
|
|
|
|
|
|---+--------------+---------+-------|
|
|
|
|
|
| | Foo | 52:00 | |
|
2017-02-18 19:55:40 +00:00
|
|
|
|
| 1 | \\_ Bar | | 26:00 |"
|
2017-02-18 19:22:30 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00
|
|
|
|
|
** Bar
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":properties (\"A\")"))))
|
2017-02-18 19:22:30 +00:00
|
|
|
|
;; Handle missing properties.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-05-27 16:15:05 +00:00
|
|
|
|
"| A | Headline | Time |
|
|
|
|
|
|---+--------------+---------|
|
|
|
|
|
| | *Total time* | *26:00* |
|
|
|
|
|
|---+--------------+---------|
|
|
|
|
|
| 1 | Foo | 26:00 |"
|
2017-02-18 19:22:30 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
2017-02-18 19:55:40 +00:00
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":properties (\"A\")")))))
|
2017-02-17 14:00:07 +00:00
|
|
|
|
|
2017-05-27 16:15:05 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/tcolumns ()
|
|
|
|
|
"Test \":tcolumns\" parameter in Clock table."
|
|
|
|
|
;; When :tcolumns is smaller than the deepest headline level, lump
|
|
|
|
|
;; lower levels in the last column.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| *Total time* | *52:00* |
|
|
|
|
|
|--------------+---------|
|
|
|
|
|
| Foo | 52:00 |
|
|
|
|
|
| \\_ Bar | 26:00 |"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00
|
|
|
|
|
** Bar
|
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":tcolumns 1"))))
|
|
|
|
|
;; :tcolumns cannot create more columns than the deepest headline
|
|
|
|
|
;; level.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"| Headline | Time | |
|
|
|
|
|
|--------------+---------+-------|
|
|
|
|
|
| *Total time* | *52:00* | |
|
|
|
|
|
|--------------+---------+-------|
|
|
|
|
|
| Foo | 52:00 | |
|
|
|
|
|
| \\_ Bar | | 26:00 |"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00
|
|
|
|
|
** Bar
|
|
|
|
|
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":tcolumns 3"))))
|
|
|
|
|
;; Pathological case: when no headline contributes to the total
|
|
|
|
|
;; time, there is only one time column.
|
|
|
|
|
(should
|
|
|
|
|
(equal "| Headline | Time |
|
|
|
|
|
|--------------+--------|
|
|
|
|
|
| *Total time* | *0:00* |"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2016-12-28 Wed 11:09]--[2016-12-28 Wed 11:09] => 0:00
|
|
|
|
|
** Bar
|
|
|
|
|
CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 13:09] => 0:00"
|
|
|
|
|
(test-org-clock-clocktable-contents ":tcolumns 2")))))
|
|
|
|
|
|
2018-04-28 22:22:53 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/step ()
|
|
|
|
|
"Test \":step\" parameter in Clock table."
|
|
|
|
|
;; Regression test: week crossing month boundary before :wstart
|
|
|
|
|
;; day-of-week.
|
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2017-09-25 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*1:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 1:00 +|"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-04-28 22:22:53 +00:00
|
|
|
|
CLOCK: [2017-09-30 Sat 12:00]--[2017-09-30 Sat 13:00] => 1:00
|
|
|
|
|
CLOCK: [2017-10-01 Sun 11:00]--[2017-10-01 Sun 13:00] => 2:00
|
|
|
|
|
CLOCK: [2017-10-02 Mon 11:00]--[2017-10-02 Mon 14:00] => 3:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step week :block 2017-09 :stepskip0 t")))))
|
2018-04-28 22:22:53 +00:00
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2017-10-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*2:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 2:00 |
|
2018-04-28 22:22:53 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2017-10-02 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*7:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 7:00 +|
|
2018-04-28 22:22:53 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2017-10-09 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*5:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 5:00 +|
|
2018-04-28 22:22:53 +00:00
|
|
|
|
"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-04-28 22:22:53 +00:00
|
|
|
|
CLOCK: [2017-09-30 Sat 12:00]--[2017-09-30 Sat 13:00] => 1:00
|
|
|
|
|
CLOCK: [2017-10-01 Sun 11:00]--[2017-10-01 Sun 13:00] => 2:00
|
|
|
|
|
CLOCK: [2017-10-02 Mon 11:00]--[2017-10-02 Mon 14:00] => 3:00
|
|
|
|
|
CLOCK: [2017-10-08 Sun 09:00]--[2017-10-08 Sun 13:00] => 4:00
|
|
|
|
|
CLOCK: [2017-10-09 Mon 09:00]--[2017-10-09 Mon 14:00] => 5:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step week :block 2017-10 :stepskip0 t")))))
|
2018-04-28 22:22:53 +00:00
|
|
|
|
;; :step day
|
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2017-10-02 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*3:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 3:00 +|
|
2018-04-28 22:22:53 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2017-10-03 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*0:00\\* |
|
2018-04-28 22:22:53 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2017-10-04 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*0:00\\* |
|
2018-04-28 22:22:53 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2017-10-05 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*0:00\\* |
|
2018-04-28 22:22:53 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2017-10-06 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*0:00\\* |
|
2018-04-28 22:22:53 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2017-10-07 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*0:00\\* |
|
2018-04-28 22:22:53 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2017-10-08 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*4:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 4:00 +|"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-04-28 22:22:53 +00:00
|
|
|
|
CLOCK: [2017-09-30 Sat 12:00]--[2017-09-30 Sat 13:00] => 1:00
|
|
|
|
|
CLOCK: [2017-10-01 Sun 11:00]--[2017-10-01 Sun 13:00] => 2:00
|
|
|
|
|
CLOCK: [2017-10-02 Mon 11:00]--[2017-10-02 Mon 14:00] => 3:00
|
|
|
|
|
CLOCK: [2017-10-08 Sun 09:00]--[2017-10-08 Sun 13:00] => 4:00
|
|
|
|
|
CLOCK: [2017-10-09 Mon 09:00]--[2017-10-09 Mon 14:00] => 5:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step day :block 2017-W40")))))
|
2018-04-28 22:22:53 +00:00
|
|
|
|
;; Regression test: take :tstart and :tend hours into consideration.
|
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2017-12-25 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-04-28 22:22:53 +00:00
|
|
|
|
CLOCK: [2017-12-27 Wed 08:00]--[2017-12-27 Wed 16:00] => 8:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
(concat ":step week :tstart \"<2017-12-25 Mon>\" "
|
|
|
|
|
":tend \"<2017-12-27 Wed 23:59>\""))))))
|
2018-04-28 22:22:53 +00:00
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2017-12-27 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-04-28 22:22:53 +00:00
|
|
|
|
CLOCK: [2017-12-27 Wed 08:00]--[2017-12-27 Wed 16:00] => 8:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
(concat ":step day :tstart \"<2017-12-25 Mon>\" "
|
|
|
|
|
":tend \"<2017-12-27 Wed 23:59>\" :stepskip0 t"))))))
|
2018-10-13 14:22:43 +00:00
|
|
|
|
;; Test :step week", without or with ":wstart" parameter.
|
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2012-03-26 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
2018-10-13 14:22:43 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2012-04-02 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
2018-10-13 14:22:43 +00:00
|
|
|
|
"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-10-13 14:22:43 +00:00
|
|
|
|
CLOCK: [2012-03-29 Thu 08:00]--[2012-03-29 Thu 16:00] => 8:00
|
|
|
|
|
CLOCK: [2012-04-03 Thu 08:00]--[2012-04-03 Thu 16:00] => 8:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step week :block 2012 :stepskip0 t")))))
|
2018-10-13 14:22:43 +00:00
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2012-03-29 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*16:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 16:00 +|
|
2018-10-13 14:22:43 +00:00
|
|
|
|
"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-10-13 14:22:43 +00:00
|
|
|
|
CLOCK: [2012-03-29 Thu 08:00]--[2012-03-29 Thu 16:00] => 8:00
|
|
|
|
|
CLOCK: [2012-04-03 Thu 08:00]--[2012-04-03 Thu 16:00] => 8:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step week :wstart 4 :block 2012 :stepskip0 t")))))
|
2018-10-13 14:22:43 +00:00
|
|
|
|
;; Test ":step month" without and with ":mstart".
|
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2014-03-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
2018-10-13 14:22:43 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2014-04-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
2018-10-13 14:22:43 +00:00
|
|
|
|
"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-10-13 14:22:43 +00:00
|
|
|
|
CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] => 8:00
|
|
|
|
|
CLOCK: [2014-04-03 Thu 08:00]--[2014-04-03 Thu 16:00] => 8:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step month :block 2014 :stepskip0 t")))))
|
2018-10-13 14:22:43 +00:00
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2014-03-04 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*16:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 16:00 +|
|
2018-10-13 14:22:43 +00:00
|
|
|
|
"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-10-13 14:22:43 +00:00
|
|
|
|
CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] => 8:00
|
|
|
|
|
CLOCK: [2014-04-03 Thu 08:00]--[2014-04-03 Thu 16:00] => 8:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step month :mstart 4 :block 2014 :stepskip0 t")))))
|
2022-09-09 13:16:46 +00:00
|
|
|
|
;; Test ":step quarter".
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
Quarterly report starting on:.*?\\[2014-01-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
|
|
|
|
|
|
|
|
|
.*?\\[2014-04-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*16:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 16:00 +|
|
|
|
|
|
|
|
|
|
|
.*?\\[2014-07-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] => 8:00
|
|
|
|
|
CLOCK: [2014-04-03 Thu 08:00]--[2014-04-03 Thu 16:00] => 8:00
|
|
|
|
|
CLOCK: [2014-06-04 Wed 08:00]--[2014-06-04 Wed 16:00] => 8:00
|
|
|
|
|
CLOCK: [2014-07-03 Thu 08:00]--[2014-07-03 Thu 16:00] => 8:00"
|
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step quarter :block 2014 :stepskip0 t")))))
|
2020-03-27 01:04:00 +00:00
|
|
|
|
;; Test ":step semimonth".
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2014-03-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
|
|
|
|
|
|
|
|
|
.*?\\[2014-03-16 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*2:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 2:00 +|
|
|
|
|
|
|
|
|
|
|
.*?\\[2014-04-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*7:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 7:00 +|
|
|
|
|
|
"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
|
|
|
|
CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] => 8:00
|
|
|
|
|
CLOCK: [2014-03-24 Mon 08:00]--[2014-03-24 Mon 10:00] => 2:00
|
|
|
|
|
CLOCK: [2014-04-03 Thu 08:00]--[2014-04-03 Thu 15:00] => 7:00"
|
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step semimonth :block 2014 :stepskip0 t")))))
|
2018-10-13 14:22:43 +00:00
|
|
|
|
;; Test ":step year".
|
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2012-01-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
2018-10-13 14:22:43 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*?\\[2014-01-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
2018-10-13 14:22:43 +00:00
|
|
|
|
"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-10-13 14:22:43 +00:00
|
|
|
|
CLOCK: [2012-03-29 Thu 08:00]--[2012-03-29 Thu 16:00] => 8:00
|
|
|
|
|
CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] => 8:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step year :block untilnow :stepskip0 t")))))
|
2018-11-01 12:59:09 +00:00
|
|
|
|
;; Regression test: Respect DST
|
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p
|
|
|
|
|
"
|
|
|
|
|
.*?\\[2018-10-29 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*8:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 8:00 +|
|
2018-11-01 12:59:09 +00:00
|
|
|
|
"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-11-01 12:59:09 +00:00
|
|
|
|
CLOCK: [2018-10-29 Mon 08:00]--[2018-10-29 Mon 16:00] => 8:00"
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
(concat ":step day "
|
|
|
|
|
":stepskip0 t "
|
|
|
|
|
":tstart \"2018-10-01\" "
|
|
|
|
|
":tend \"2018-11-01\"")))))))
|
2017-10-08 08:42:21 +00:00
|
|
|
|
|
2018-06-27 01:33:39 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/extend-today-until ()
|
|
|
|
|
"Test assignment of clock time to days in presence of \"org-extend-today-until\"."
|
|
|
|
|
;; Basic test of :block with org-extend-today-until - the report for
|
|
|
|
|
;; 2017-09-30 should include the time clocked on 2017-10-01 before
|
|
|
|
|
;; 04:00.
|
|
|
|
|
(should
|
|
|
|
|
(equal "| Headline | Time |
|
|
|
|
|
|--------------+--------|
|
|
|
|
|
| *Total time* | *2:00* |
|
|
|
|
|
|--------------+--------|
|
|
|
|
|
| Foo | 2:00 |"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-06-27 01:33:39 +00:00
|
|
|
|
CLOCK: [2017-09-30 Sat 12:00]--[2017-09-30 Sat 13:00] => 1:00
|
|
|
|
|
CLOCK: [2017-10-01 Sun 02:00]--[2017-10-01 Sun 03:00] => 1:00
|
|
|
|
|
CLOCK: [2017-10-01 Sun 11:00]--[2017-10-01 Sun 13:00] => 2:00"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(setq-local org-extend-today-until 4)
|
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":block 2017-09-30")))))
|
2018-06-27 01:33:39 +00:00
|
|
|
|
|
|
|
|
|
;; Week-length block - time on Monday before 04:00 should be
|
|
|
|
|
;; assigned to previous week.
|
|
|
|
|
(should
|
2019-11-24 16:27:53 +00:00
|
|
|
|
(string-match-p "
|
|
|
|
|
.*? \\[2017-10-01 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*2:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 2:00 |
|
2018-06-27 01:33:39 +00:00
|
|
|
|
|
2019-11-24 16:27:53 +00:00
|
|
|
|
.*? \\[2017-10-02 .*
|
|
|
|
|
.*
|
|
|
|
|
.*
|
|
|
|
|
|.*?| \\*2:00\\* |
|
|
|
|
|
.*
|
|
|
|
|
| Foo +| 2:00 |
|
2018-06-27 01:33:39 +00:00
|
|
|
|
"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Foo
|
2018-06-27 01:33:39 +00:00
|
|
|
|
CLOCK: [2017-10-01 Sun 12:00]--[2017-10-01 Sun 13:00] => 1:00
|
|
|
|
|
CLOCK: [2017-10-02 Mon 02:00]--[2017-10-02 Mon 03:00] => 1:00
|
|
|
|
|
CLOCK: [2017-10-02 Mon 11:00]--[2017-10-02 Mon 13:00] => 2:00"
|
2018-11-01 18:05:22 +00:00
|
|
|
|
(setq-local org-extend-today-until 4)
|
|
|
|
|
(let ((system-time-locale "en_US"))
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
":step week :block 2017-10 :stepskip0 t"))))))
|
2018-06-27 01:33:39 +00:00
|
|
|
|
|
2019-08-28 23:15:40 +00:00
|
|
|
|
(ert-deftest test-org-clock/clocktable/hidefiles ()
|
|
|
|
|
"Test \":hidefiles\" parameter in Clock table."
|
|
|
|
|
;; Test that hidefiles removes the file column.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"| Headline | Time |
|
|
|
|
|
|--------------+--------|
|
|
|
|
|
| *Total time* | *1:00* |
|
|
|
|
|
|--------------+--------|
|
|
|
|
|
| Test | 1:00 |"
|
|
|
|
|
(org-test-with-temp-text-in-file
|
|
|
|
|
"* Test
|
|
|
|
|
CLOCK: [2012-03-29 Thu 16:00]--[2012-03-29 Thu 17:00] => 1:00"
|
|
|
|
|
(let ((the-file (buffer-file-name)))
|
|
|
|
|
(org-test-with-temp-text-in-file ""
|
|
|
|
|
(test-org-clock-clocktable-contents
|
|
|
|
|
(format ":hidefiles t :scope (lambda () (list %S))" the-file))))))))
|
2018-06-27 01:33:39 +00:00
|
|
|
|
|
2012-11-30 15:28:00 +00:00
|
|
|
|
(provide 'test-org-clock)
|
|
|
|
|
;;; test-org-clock.el end here
|