Procházet zdrojové kódy

Merge branch 'master' into next

Nicolas Goaziou před 6 roky
rodič
revize
813ab7d56f
1 změnil soubory, kde provedl 110 přidání a 91 odebrání
  1. 110 91
      testing/lisp/test-org-clock.el

+ 110 - 91
testing/lisp/test-org-clock.el

@@ -49,8 +49,8 @@ Return the clock line as a string."
   (let* ((beg (org-test-clock-create-timestamp input1 t t))
          (end (and input2 (org-test-clock-create-timestamp input2 t t)))
          (sec-diff (and input2
-			(floor (- (org-time-string-to-seconds end)
-				  (org-time-string-to-seconds beg))))))
+                        (floor (- (org-time-string-to-seconds end)
+                                  (org-time-string-to-seconds beg))))))
     (concat org-clock-string " " beg
             (when end
               (concat "--" end " => "
@@ -82,7 +82,7 @@ the buffer."
         ;; Skip caption.
         (when (looking-at "#\\+CAPTION:") (forward-line))
         (buffer-substring-no-properties
-	 (point) (progn (search-forward "#+END:") (line-end-position 0))))
+         (point) (progn (search-forward "#+END:") (line-end-position 0))))
     ;; Remove clocktable.
     (delete-region (point) (search-forward "#+END:\n"))))
 
@@ -369,18 +369,18 @@ the buffer."
         "* Test
 CLOCK: [2012-03-29 Thu 8:00]--[2012-03-29 Thu 16:40] => 8:40"
       (test-org-clock-clocktable-contents ":scope file-with-archives"
-	  "#+TBLFM: $3=string(\"foo\")"))))
+                                          "#+TBLFM: $3=string(\"foo\")"))))
   ;; Test "function" scope.
   (should
    (string-match-p
     (regexp-quote "| ALL *Total time* | *1:00* |")
     (org-test-with-temp-text-in-file
-	"* Test
+        "* 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 ":scope (lambda () (list %S))" the-file))))))))
+        (org-test-with-temp-text-in-file ""
+          (test-org-clock-clocktable-contents
+           (format ":scope (lambda () (list %S))" the-file))))))))
 
 (ert-deftest test-org-clock/clocktable/maxlevel ()
   "Test \":maxlevel\" parameter in Clock table."
@@ -409,7 +409,7 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
 CLOCK: [2016-12-28 Wed 11:09]--[2016-12-28 Wed 15:09] =>  4:00
 ** Bar
 CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
-	    (test-org-clock-clocktable-contents ":maxlevel 2"))))
+            (test-org-clock-clocktable-contents ":maxlevel 2"))))
   (should
    (equal "| Headline     | Time   |
 |--------------+--------|
@@ -421,7 +421,7 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
 CLOCK: [2016-12-28 Wed 11:09]--[2016-12-28 Wed 15:09] =>  4:00
 ** Bar
 CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
-	    (test-org-clock-clocktable-contents ":maxlevel 1"))))
+            (test-org-clock-clocktable-contents ":maxlevel 1"))))
   ;; Special ":maxlevel 0" case: only report total file time.
   (should
    (equal "| Headline     | Time   |
@@ -433,7 +433,7 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
 CLOCK: [2016-12-28 Wed 11:09]--[2016-12-28 Wed 15:09] =>  4:00
 ** Bar
 CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
-	    (test-org-clock-clocktable-contents ":maxlevel 0")))))
+            (test-org-clock-clocktable-contents ":maxlevel 0")))))
 
 (ert-deftest test-org-clock/clocktable/formula ()
   "Test \":formula\" parameter in Clock table."
@@ -478,8 +478,8 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
 | \\_  sub3      |        | 0:30 |      |  50.0 |
 | \\_    subsub1 |        |      | 0:15 |  25.0 |
 | \\_    subsub1 |        |      | 0:15 |  25.0 |"
-	  (org-test-with-temp-text
-	      "* foo
+          (org-test-with-temp-text
+              "* foo
 ** sub
    :LOGBOOK:
    CLOCK: [2017-03-18 Sat 15:00]--[2017-03-18 Sat 15:15] =>  0:15
@@ -497,7 +497,7 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
     :LOGBOOK:
     CLOCK: [2017-03-18 Sat 14:00]--[2017-03-18 Sat 14:15] =>  0:15
     :END:"
-	    (test-org-clock-clocktable-contents ":maxlevel 3 :formula %")))))
+            (test-org-clock-clocktable-contents ":maxlevel 3 :formula %")))))
 
 (ert-deftest test-org-clock/clocktable/lang ()
   "Test \":lang\" parameter in Clock table."
@@ -560,7 +560,7 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
 |--------------+---------|
 | [[Foo][Foo]]          | 26:00   |"
     (org-test-with-temp-text
-	"* Foo
+        "* Foo
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (test-org-clock-clocktable-contents ":link t"))))
   ;; Otherwise, link to the headline in the current file.
@@ -572,12 +572,12 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
 |--------------+---------|
 | [[file:filename::Foo][Foo]]          | 26:00   |"
     (org-test-with-temp-text-in-file
-	"* Foo
+        "* Foo
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (let ((file (buffer-file-name)))
-	(replace-regexp-in-string
-	 (regexp-quote file) "filename"
-	 (test-org-clock-clocktable-contents ":link t"))))))
+        (replace-regexp-in-string
+         (regexp-quote file) "filename"
+         (test-org-clock-clocktable-contents ":link t"))))))
   ;; Ignore TODO keyword, priority cookie, COMMENT and tags in
   ;; headline.
   (should
@@ -588,7 +588,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
 |--------------+---------|
 | [[Foo][Foo]]          | 26:00   |"
     (org-test-with-temp-text
-	"* TODO Foo
+        "* TODO Foo
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (test-org-clock-clocktable-contents ":link t"))))
   (should
@@ -599,7 +599,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
 |--------------+---------|
 | [[Foo][Foo]]          | 26:00   |"
     (org-test-with-temp-text
-	"* [#A] Foo
+        "* [#A] Foo
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (test-org-clock-clocktable-contents ":link t"))))
   (should
@@ -610,7 +610,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
 |--------------+---------|
 | [[Foo][Foo]]          | 26:00   |"
     (org-test-with-temp-text
-	"* COMMENT Foo
+        "* COMMENT Foo
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (test-org-clock-clocktable-contents ":link t"))))
   (should
@@ -621,7 +621,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
 |--------------+---------|
 | [[Foo][Foo]]          | 26:00   |"
     (org-test-with-temp-text
-	"* Foo :tag:
+        "* Foo :tag:
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (test-org-clock-clocktable-contents ":link t"))))
   ;; Remove statistics cookie from headline description.
@@ -633,7 +633,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
 |--------------+---------|
 | [[Foo][Foo]]          | 26:00   |"
     (org-test-with-temp-text
-	"* Foo [50%]
+        "* Foo [50%]
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (test-org-clock-clocktable-contents ":link t"))))
   (should
@@ -644,7 +644,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
 |--------------+---------|
 | [[Foo][Foo]]          | 26:00   |"
     (org-test-with-temp-text
-	"* Foo [1/2]
+        "* Foo [1/2]
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (test-org-clock-clocktable-contents ":link t"))))
   ;; Replace links with their description, or turn them into plain
@@ -657,7 +657,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
 |--------------+---------|
 | [[Foo %5B%5Bhttps://orgmode.org%5D%5BOrg mode%5D%5D][Foo Org mode]] | 26:00   |"
     (org-test-with-temp-text
-	"* Foo [[https://orgmode.org][Org mode]]
+        "* Foo [[https://orgmode.org][Org mode]]
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (test-org-clock-clocktable-contents ":link t"))))
   (should
@@ -668,7 +668,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
 |-------------------------+---------|
 | [[Foo %5B%5Bhttps://orgmode.org%5D%5D][Foo https://orgmode.org]] | 26:00   |"
     (org-test-with-temp-text
-	"* Foo [[https://orgmode.org]]
+        "* Foo [[https://orgmode.org]]
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
       (test-org-clock-clocktable-contents ":link t")))))
 
@@ -855,14 +855,14 @@ Weekly report starting on: [2017-09-25 Mon]
 | *Total time* | *1:00* |
 |--------------+--------|
 | Foo          | 1:00   |"
-	  (org-test-with-temp-text
-	      "* Foo
+          (org-test-with-temp-text
+              "* Foo
 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"
-	    (let ((system-time-locale "en_US"))
-	      (test-org-clock-clocktable-contents
-		  ":step week :block 2017-09 :stepskip0 t")))))
+            (let ((system-time-locale "en_US"))
+              (test-org-clock-clocktable-contents
+               ":step week :block 2017-09 :stepskip0 t")))))
   (should
    (equal "
 Weekly report starting on: [2017-10-01 Sun]
@@ -886,16 +886,16 @@ Weekly report starting on: [2017-10-09 Mon]
 |--------------+--------|
 | Foo          | 5:00   |
 "
-	  (org-test-with-temp-text
-	      "* Foo
+          (org-test-with-temp-text
+              "* Foo
 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"
-	    (let ((system-time-locale "en_US"))
-	      (test-org-clock-clocktable-contents
-		  ":step week :block 2017-10 :stepskip0 t")))))
+            (let ((system-time-locale "en_US"))
+              (test-org-clock-clocktable-contents
+               ":step week :block 2017-10 :stepskip0 t")))))
   ;; :step day
   (should
    (equal "
@@ -937,16 +937,16 @@ Daily report: [2017-10-08 Sun]
 | *Total time* | *4:00* |
 |--------------+--------|
 | Foo          | 4:00   |"
-	  (org-test-with-temp-text
-	      "* Foo
+          (org-test-with-temp-text
+              "* Foo
 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"
-	    (let ((system-time-locale "en_US"))
-	      (test-org-clock-clocktable-contents
-		  ":step day :block 2017-W40")))))
+            (let ((system-time-locale "en_US"))
+              (test-org-clock-clocktable-contents
+               ":step day :block 2017-W40")))))
   ;; Regression test: take :tstart and :tend hours into consideration.
   (should
    (equal "
@@ -956,13 +956,13 @@ Weekly report starting on: [2017-12-25 Mon]
 | *Total time* | *8:00* |
 |--------------+--------|
 | Foo          | 8:00   |"
-	  (org-test-with-temp-text
-	      "* Foo
+          (org-test-with-temp-text
+              "* Foo
 CLOCK: [2017-12-27 Wed 08:00]--[2017-12-27 Wed 16:00] =>  8: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>\""))))))
+            (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>\""))))))
   (should
    (equal "
 Daily report: [2017-12-27 Wed]
@@ -971,13 +971,13 @@ Daily report: [2017-12-27 Wed]
 | *Total time* | *8:00* |
 |--------------+--------|
 | Foo          | 8:00   |"
-	  (org-test-with-temp-text
-	      "* Foo
+          (org-test-with-temp-text
+              "* Foo
 CLOCK: [2017-12-27 Wed 08:00]--[2017-12-27 Wed 16:00] =>  8: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"))))))
+            (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"))))))
   ;; Test :step week", without or with ":wstart" parameter.
   (should
    (equal "
@@ -995,13 +995,13 @@ Weekly report starting on: [2012-04-02 Mon]
 |--------------+--------|
 | Foo          | 8:00   |
 "
-	  (org-test-with-temp-text
-	      "* Foo
+          (org-test-with-temp-text
+              "* Foo
 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"
-	    (let ((system-time-locale "en_US"))
-	      (test-org-clock-clocktable-contents
-		  ":step week :block 2012 :stepskip0 t")))))
+            (let ((system-time-locale "en_US"))
+              (test-org-clock-clocktable-contents
+               ":step week :block 2012 :stepskip0 t")))))
   (should
    (equal "
 Weekly report starting on: [2012-03-29 Thu]
@@ -1011,13 +1011,13 @@ Weekly report starting on: [2012-03-29 Thu]
 |--------------+---------|
 | Foo          | 16:00   |
 "
-	  (org-test-with-temp-text
-	      "* Foo
+          (org-test-with-temp-text
+              "* Foo
 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"
-	    (let ((system-time-locale "en_US"))
-	      (test-org-clock-clocktable-contents
-		  ":step week :wstart 4 :block 2012 :stepskip0 t")))))
+            (let ((system-time-locale "en_US"))
+              (test-org-clock-clocktable-contents
+               ":step week :wstart 4 :block 2012 :stepskip0 t")))))
   ;; Test ":step month" without and with ":mstart".
   (should
    (equal "
@@ -1035,13 +1035,13 @@ Monthly report starting on: [2014-04-01 Tue]
 |--------------+--------|
 | Foo          | 8:00   |
 "
-	  (org-test-with-temp-text
-	      "* Foo
+          (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"
-	    (let ((system-time-locale "en_US"))
-	      (test-org-clock-clocktable-contents
-		  ":step month :block 2014 :stepskip0 t")))))
+            (let ((system-time-locale "en_US"))
+              (test-org-clock-clocktable-contents
+               ":step month :block 2014 :stepskip0 t")))))
   (should
    (equal "
 Monthly report starting on: [2014-03-04 Tue]
@@ -1051,13 +1051,13 @@ Monthly report starting on: [2014-03-04 Tue]
 |--------------+---------|
 | Foo          | 16:00   |
 "
-	  (org-test-with-temp-text
-	      "* Foo
+          (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"
-	    (let ((system-time-locale "en_US"))
-	      (test-org-clock-clocktable-contents
-		  ":step month :mstart 4 :block 2014 :stepskip0 t")))))
+            (let ((system-time-locale "en_US"))
+              (test-org-clock-clocktable-contents
+               ":step month :mstart 4 :block 2014 :stepskip0 t")))))
   ;; Test ":step year".
   (should
    (equal "
@@ -1075,13 +1075,32 @@ Annual report starting on: [2014-01-01 Wed]
 |--------------+--------|
 | Foo          | 8:00   |
 "
-	  (org-test-with-temp-text
-	      "* Foo
+          (org-test-with-temp-text
+              "* Foo
 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"
-	    (let ((system-time-locale "en_US"))
-	      (test-org-clock-clocktable-contents
-		  ":step year :block untilnow :stepskip0 t"))))))
+            (let ((system-time-locale "en_US"))
+              (test-org-clock-clocktable-contents
+               ":step year :block untilnow :stepskip0 t")))))
+  ;; Regression test: Respect DST
+  (should
+   (equal "
+Daily report: [2018-10-29 Mon]
+| Headline     | Time   |
+|--------------+--------|
+| *Total time* | *8:00* |
+|--------------+--------|
+| Foo          | 8:00   |
+"
+          (org-test-with-temp-text
+              "* Foo
+CLOCK: [2018-10-29 Mon 08:00]--[2018-10-29 Mon 16:00] =>  8: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\"")))))))
 
 (ert-deftest test-org-clock/clocktable/extend-today-until ()
   "Test assignment of clock time to days in presence of \"org-extend-today-until\"."
@@ -1094,15 +1113,15 @@ CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] =>  8:00"
 | *Total time* | *2:00* |
 |--------------+--------|
 | Foo          | 2:00   |"
-	  (org-test-with-temp-text
-	   "* Foo
+          (org-test-with-temp-text
+              "* Foo
 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"
-	   (setq-local org-extend-today-until 4)
-	   (let ((system-time-locale "en_US"))
-	     (test-org-clock-clocktable-contents
-	      ":block 2017-09-30")))))
+            (setq-local org-extend-today-until 4)
+            (let ((system-time-locale "en_US"))
+              (test-org-clock-clocktable-contents
+               ":block 2017-09-30")))))
 
   ;; Week-length block - time on Monday before 04:00 should be
   ;; assigned to previous week.
@@ -1122,15 +1141,15 @@ Weekly report starting on: [2017-10-02 Mon]
 |--------------+--------|
 | Foo          | 2:00   |
 "
-	  (org-test-with-temp-text
-	   "* Foo
+          (org-test-with-temp-text
+              "* Foo
 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"
-	   (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"))))))
+            (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"))))))
 
 
 (provide 'test-org-clock)