Browse Source

org-clock: Fix tests

* testing/lisp/test-org-clock.el (test-org-clock/clocktable/link): Fix
tests.
Nicolas Goaziou 5 years ago
parent
commit
72708b33e3
1 changed files with 71 additions and 113 deletions
  1. 71 113
      testing/lisp/test-org-clock.el

+ 71 - 113
testing/lisp/test-org-clock.el

@@ -576,129 +576,87 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] =>  2:00"
   "Test \":link\" parameter in Clock table."
   ;; If there is no file attached to the document, link directly to
   ;; the headline.
-  (let (org-link-descriptive)
-    (should
-     (equal
-      "| Headline     | Time    |
-|--------------+---------|
-| *Total time* | *26:00* |
-|--------------+---------|
-| [[Foo][Foo]] | 26:00   |"
-      (org-test-with-temp-text
-          "* Foo
+  (should
+   (string-match-p "| +\\[\\[Foo]\\[Foo]] +| 26:00 +|"
+		   (org-test-with-temp-text
+		       "* 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.
-    (should
-     (equal
-      "| Headline                    | Time    |
-|-----------------------------+---------|
-| *Total time*                | *26:00* |
-|-----------------------------+---------|
-| [[file:filename::Foo][Foo]] | 26:00   |"
-      (org-test-with-temp-text
-	  (org-test-with-temp-text-in-file
-              "* Foo
+		     (test-org-clock-clocktable-contents ":link t"))))
+  ;; Otherwise, link to the headline in the current file.
+  (should
+   (string-match-p
+    "| \\[\\[file:filename::Foo]\\[Foo]] +| 26:00 +|"
+    (org-test-with-temp-text
+	(org-test-with-temp-text-in-file
+	    "* 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 :lang en"))))
-	(org-table-align)
-	(buffer-substring-no-properties (point-min) (point-max)))))
-    ;; Ignore TODO keyword, priority cookie, COMMENT and tags in
-    ;; headline.
-    (should
-     (equal
-      "| Headline     | Time    |
-|--------------+---------|
-| *Total time* | *26:00* |
-|--------------+---------|
-| [[Foo][Foo]] | 26:00   |"
-      (org-test-with-temp-text
-          "* TODO Foo
+	  (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
+    "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
+    (org-test-with-temp-text
+	"* TODO Foo
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
-	(test-org-clock-clocktable-contents ":link t :lang en"))))
-    (should
-     (equal
-      "| Headline     | Time    |
-|--------------+---------|
-| *Total time* | *26:00* |
-|--------------+---------|
-| [[Foo][Foo]] | 26:00   |"
-      (org-test-with-temp-text
-          "* [#A] Foo
+      (test-org-clock-clocktable-contents ":link t :lang en"))))
+  (should
+   (string-match-p
+    "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
+    (org-test-with-temp-text
+	"* [#A] Foo
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
-	(test-org-clock-clocktable-contents ":link t :lang en"))))
-    (should
-     (equal
-      "| Headline     | Time    |
-|--------------+---------|
-| *Total time* | *26:00* |
-|--------------+---------|
-| [[Foo][Foo]] | 26:00   |"
-      (org-test-with-temp-text
-          "* COMMENT Foo
+      (test-org-clock-clocktable-contents ":link t :lang en"))))
+  (should
+   (string-match-p
+    "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
+    (org-test-with-temp-text
+	"* 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
-     (equal
-      "| Headline     | Time    |
-|--------------+---------|
-| *Total time* | *26:00* |
-|--------------+---------|
-| [[Foo][Foo]] | 26:00   |"
-      (org-test-with-temp-text
-          "* Foo :tag:
+      (test-org-clock-clocktable-contents ":link t"))))
+  (should
+   (string-match-p
+    "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
+    (org-test-with-temp-text
+	"* Foo :tag:
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
-	(test-org-clock-clocktable-contents ":link t :lang en"))))
-    ;; Remove statistics cookie from headline description.
-    (should
-     (equal
-      "| Headline     | Time    |
-|--------------+---------|
-| *Total time* | *26:00* |
-|--------------+---------|
-| [[Foo][Foo]] | 26:00   |"
-      (org-test-with-temp-text
-          "* Foo [50%]
+      (test-org-clock-clocktable-contents ":link t :lang en"))))
+  ;; Remove statistics cookie from headline description.
+  (should
+   (string-match-p
+    "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
+    (org-test-with-temp-text
+	"* Foo [50%]
 CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
-	(test-org-clock-clocktable-contents ":link t :lang en"))))
-    (should
-     (equal
-      "| Headline     | Time    |
-|--------------+---------|
-| *Total time* | *26:00* |
-|--------------+---------|
-| [[Foo][Foo]] | 26:00   |"
-      (org-test-with-temp-text
-          "* Foo [1/2]
+      (test-org-clock-clocktable-contents ":link t :lang en"))))
+  (should
+   (string-match-p
+    "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
+    (org-test-with-temp-text
+	"* 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 :lang en"))))
-    ;; Replace links with their description, or turn them into plain
-    ;; links if there is no description.
-    (should
-     (equal
-      "| Headline                                                  | Time    |
-|-----------------------------------------------------------+---------|
-| *Total time*                                              | *26:00* |
-|-----------------------------------------------------------+---------|
-| [[Foo [[https://orgmode.org\\][Org mode]\\]][Foo Org mode]] | 26:00   |"
-      (org-test-with-temp-text
-          "* Foo [[https://orgmode.org][Org mode]]
+      (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
+    "| \\[\\[Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\\\[Org mode\\\\]\\\\]]\\[Foo Org mode]] +| 26:00 +|"
+    (org-test-with-temp-text
+	"* 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 :lang en"))))
-    (should
-     (equal
-      "| Headline                                                  | Time    |
-|-----------------------------------------------------------+---------|
-| *Total time*                                              | *26:00* |
-|-----------------------------------------------------------+---------|
-| [[Foo [[https://orgmode.org]\\]][Foo https://orgmode.org]] | 26:00   |"
-      (org-test-with-temp-text
-          "* Foo [[https://orgmode.org]]
+      (test-org-clock-clocktable-contents ":link t :lang en"))))
+  (should
+   (string-match-p
+    "| \\[\\[Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\]]\\[Foo https://orgmode\\.org]] +| 26:00 +|"
+    (org-test-with-temp-text
+	"* 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 :lang en"))))))
+      (test-org-clock-clocktable-contents ":link t :lang en")))))
 
 (ert-deftest test-org-clock/clocktable/compact ()
   "Test \":compact\" parameter in Clock table."