* [PATCH] testing: Delete duplicate tests @ 2023-07-12 19:22 Ilya Chernyshov 2023-07-13 9:51 ` Ihor Radchenko 2023-07-14 11:50 ` Max Nikulin 0 siblings, 2 replies; 17+ messages in thread From: Ilya Chernyshov @ 2023-07-12 19:22 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1102 bytes --] Hello. In my last patch, I found a duplicate test, so I decided to find all of the duplicate tests inside testing/lisp/ folder via this function: (defun count-duplicate-tests (&optional directory) (let (files) (dolist (file (directory-files (or directory default-directory) t (rx ".el" string-end) t)) (with-current-buffer (find-file-noselect file) (save-excursion (goto-char (point-min)) (while (search-forward "(ert-deftest" nil t) (ignore-errors (while-let((form (or (read (current-buffer)) t))) (when (eq (car-safe form) 'should) (setf (alist-get form (alist-get file files nil nil #'equal) 0 nil #'equal) (1+ (alist-get form (alist-get file files nil nil #'equal) 0 nil #'equal)))))))))) (seq-remove (lambda(file) (null (cdr file))) (mapcar (lambda(file) (cons (car file) (seq-filter (lambda(form) (/= (cdr form) 1)) (cdr file)))) files)))) (setq dups (count-duplicate-tests "~/org-mode/testing/lisp/")) Then I checked the result manually and deleted some of them. Here is the patch I wrote: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-testing-Delete-duplicate-tests.patch --] [-- Type: text/x-patch, Size: 4978 bytes --] From 21ba128bd648c6737ed088abdd2a1824cfe01759 Mon Sep 17 00:00:00 2001 From: Ilya Chernyshov <ichernyshovvv@gmail.com> Date: Thu, 13 Jul 2023 01:36:33 +0700 Subject: [PATCH] testing: Delete duplicate tests * testing/lisp/test-ol.el (test-org-link/store-link): Delete a duplicate test. * testing/lisp/test-org-clock.el (test-org-clock/clocktable/properties): Delete a duplicate test. * testing/lisp/test-org-element.el (test-org-element/link-parser, test-org-element/timestamp-parser): Delete duplicate tests. * testing/lisp/test-org-table.el (test-org-table/get-field): Delete a duplicate test. * testing/lisp/test-org.el (test-org/auto-fill-function): Delete a duplicate test. --- testing/lisp/test-ol.el | 8 -------- testing/lisp/test-org-clock.el | 15 --------------- testing/lisp/test-org-element.el | 10 ---------- testing/lisp/test-org-table.el | 4 ---- testing/lisp/test-org.el | 8 -------- 5 files changed, 45 deletions(-) diff --git a/testing/lisp/test-ol.el b/testing/lisp/test-ol.el index a38d9f979..70be03818 100644 --- a/testing/lisp/test-ol.el +++ b/testing/lisp/test-ol.el @@ -301,14 +301,6 @@ See https://github.com/yantar92/org/issues/4." (let ((file (buffer-file-name))) (equal (format "[[file:%s::two]]" file file) (org-store-link nil)))))) - (should - (let ((org-stored-links nil) - (org-context-in-file-links t)) - (org-test-with-temp-text-in-file "# two" - (fundamental-mode) - (let ((file (buffer-file-name))) - (equal (format "[[file:%s::two]]" file file) - (org-store-link nil)))))) (should (let ((org-stored-links nil) (org-context-in-file-links t)) diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index d40939eb6..16cfc63a5 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -821,21 +821,6 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00 :PROPERTIES: :A: 1 :END: -CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" - (test-org-clock-clocktable-contents ":properties (\"A\")")))) - ;; Handle missing properties. - (should - (equal - "| A | Headline | Time | -|---+--------------+---------| -| | *Total time* | *26:00* | -|---+--------------+---------| -| 1 | Foo | 26:00 |" - (org-test-with-temp-text - "* Foo -:PROPERTIES: -:A: 1 -:END: CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" (test-org-clock-clocktable-contents ":properties (\"A\")"))))) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 2e3a249ab..d95195f0d 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -2436,11 +2436,6 @@ e^{i\\pi}+1=0 (let ((file (expand-file-name (buffer-file-name)))) (insert (format "[[file:%s]]" file)) (equal (org-element-property :path (org-element-context)) file)))) - (should - (org-test-with-temp-text-in-file "" - (let ((file (expand-file-name (buffer-file-name)))) - (insert (format "[[file:%s]]" file)) - (equal (org-element-property :path (org-element-context)) file)))) ;; ... multi-line link. (should (equal "ls *.org" @@ -3195,11 +3190,6 @@ Outside list" (org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-02 Sun 13:00>" (org-element-property :range-type (org-element-timestamp-parser))) 'daterange)) - (should - (eq - (org-test-with-temp-text "<2023-07-02 Sun 12:00>--<2023-07-02 Sun>" - (org-element-property :range-type (org-element-timestamp-parser))) - 'daterange)) (should (eq (org-test-with-temp-text "<2023-07-02 Sun 12:00 +5d>--<2023-07-02 Sun 13:00>" diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 27aeb5ab3..ce78d4488 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -3368,10 +3368,6 @@ See also `test-org-table/copy-field'." (org-test-with-temp-text "| 1 | 2 | 3 |" (org-table-get-field 3 " foo ") (buffer-string)))) - (should - (equal " 4 " - (org-test-with-temp-text "| 1 | 2 |\n<point>| 3 | 4 |" - (org-table-get-field 2)))) ;; An empty REPLACE string clears the field. (should (equal "| |" diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 08cda543a..47dd9b876 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -994,14 +994,6 @@ (org-auto-fill-function) (buffer-string))))) ;; Comment block: auto fill contents. - (should - (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT" - (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT" - (let ((fill-column 5)) - (forward-line) - (end-of-line) - (org-auto-fill-function) - (buffer-string))))) (should (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT" (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT" -- 2.40.1 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-07-12 19:22 [PATCH] testing: Delete duplicate tests Ilya Chernyshov @ 2023-07-13 9:51 ` Ihor Radchenko 2023-08-08 12:44 ` Ihor Radchenko 2023-07-14 11:50 ` Max Nikulin 1 sibling, 1 reply; 17+ messages in thread From: Ihor Radchenko @ 2023-07-13 9:51 UTC (permalink / raw) To: Ilya Chernyshov; +Cc: emacs-orgmode Ilya Chernyshov <ichernyshovvv@gmail.com> writes: > In my last patch, I found a duplicate test, so I decided to find all of > the duplicate tests inside testing/lisp/ folder via this function: Thanks! > --- a/testing/lisp/test-org-table.el > +++ b/testing/lisp/test-org-table.el > @@ -3368,10 +3368,6 @@ See also `test-org-table/copy-field'." > (org-test-with-temp-text "| 1 | 2 | 3 |" > (org-table-get-field 3 " foo ") > (buffer-string)))) > - (should > - (equal " 4 " > - (org-test-with-temp-text "| 1 | 2 |\n<point>| 3 | 4 |" > - (org-table-get-field 2)))) It looks like the real test is supposed to be (equal " foo " ... (org-table-get-field 2 " foo ") (buffer-string) > --- a/testing/lisp/test-org.el > +++ b/testing/lisp/test-org.el > @@ -994,14 +994,6 @@ > (org-auto-fill-function) > (buffer-string))))) > ;; Comment block: auto fill contents. > - (should > - (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT" > - (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT" > - (let ((fill-column 5)) > - (forward-line) > - (end-of-line) > - (org-auto-fill-function) > - (buffer-string))))) > (should > (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT" > (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT" And this is the result of 8a97c60 Do not fill verse blocks contents * lisp/org.el (org-fill-context-prefix, org-fill-paragraph): Do not fill verse blocks contents. Verse blocks can be used to format free-form poetry, so filling has to be done manually. * testing/lisp/test-org.el: Remove unnecessary tests. The test was changed from testing verse block into a duplicate. I think the right thing to do here would be `should-not' + old version of the test with VERSE block. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-07-13 9:51 ` Ihor Radchenko @ 2023-08-08 12:44 ` Ihor Radchenko 2023-08-31 6:17 ` Ilya Chernyshov 0 siblings, 1 reply; 17+ messages in thread From: Ihor Radchenko @ 2023-08-08 12:44 UTC (permalink / raw) To: Ilya Chernyshov; +Cc: emacs-orgmode Ihor Radchenko <yantar92@posteo.net> writes: > It looks like the real test is supposed to be > > (equal " foo " > ... > (org-table-get-field 2 " foo ") > (buffer-string) > ... I have re-introduced the new tests in place of the removed ones, according to my and Max's findings. On top of the patch. Applied, onto main. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fe85d61a9 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=173b5de0e -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-08-08 12:44 ` Ihor Radchenko @ 2023-08-31 6:17 ` Ilya Chernyshov 2023-08-31 6:29 ` Ihor Radchenko 0 siblings, 1 reply; 17+ messages in thread From: Ilya Chernyshov @ 2023-08-31 6:17 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode Ihor Radchenko <yantar92@posteo.net> writes: > I have re-introduced the new tests in place of the removed ones, > according to my and Max's findings. On top of the patch. > > Applied, onto main. > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fe85d61a9 > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=173b5de0e Thank you! If a function that checks for duplicate tests is a welcome addition to org tests, I'll send is as a patch. What do you think? ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-08-31 6:17 ` Ilya Chernyshov @ 2023-08-31 6:29 ` Ihor Radchenko 2023-11-08 9:59 ` Ihor Radchenko 0 siblings, 1 reply; 17+ messages in thread From: Ihor Radchenko @ 2023-08-31 6:29 UTC (permalink / raw) To: Ilya Chernyshov; +Cc: emacs-orgmode Ilya Chernyshov <ichernyshovvv@gmail.com> writes: > Thank you! If a function that checks for duplicate tests is a welcome > addition to org tests, I'll send is as a patch. What do you think? It would be great. Thanks in advance! -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-08-31 6:29 ` Ihor Radchenko @ 2023-11-08 9:59 ` Ihor Radchenko 2023-11-11 8:55 ` Ilya Chernyshov 0 siblings, 1 reply; 17+ messages in thread From: Ihor Radchenko @ 2023-11-08 9:59 UTC (permalink / raw) To: Ilya Chernyshov; +Cc: emacs-orgmode Ihor Radchenko <yantar92@posteo.net> writes: > Ilya Chernyshov <ichernyshovvv@gmail.com> writes: > >> Thank you! If a function that checks for duplicate tests is a welcome >> addition to org tests, I'll send is as a patch. What do you think? > > It would be great. Thanks in advance! I saw you using your function to detect the existing duplicate tests. However, it would also be nice to add it as a test of its own to detect duplicates in future. WDYT? -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-11-08 9:59 ` Ihor Radchenko @ 2023-11-11 8:55 ` Ilya Chernyshov 2023-11-16 12:27 ` Ilya Chernyshov 2024-01-16 13:44 ` Ihor Radchenko 0 siblings, 2 replies; 17+ messages in thread From: Ilya Chernyshov @ 2023-11-11 8:55 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 713 bytes --] Ihor Radchenko <yantar92@posteo.net> writes: > I saw you using your function to detect the existing duplicate tests. > However, it would also be nice to add it as a test of its own to detect > duplicates in future. WDYT? Sure, here it is. In the patch, I added a new file (testing/lisp/test-deduplicator.el) with a test that checks for duplicate forms (not just should, should-not, should-error macros) in all test files. Changes in other files serve as an example of how to use `org-test-ignore-duplicate' to make sure that the test deduplicator skips certain duplicate forms. There's a lot of tests to change before merging. I'll handle them and submit a new patch if you have no questions about the code. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-testing-Add-testing-lisp-test-deduplicator.el.patch --] [-- Type: text/x-patch, Size: 15636 bytes --] From 3b38450f7de8bd168d8795728454d9f4db720843 Mon Sep 17 00:00:00 2001 From: Ilya Chernyshov <ichernyshovvv@gmail.com> Date: Tue, 5 Sep 2023 22:40:59 +0700 Subject: [PATCH] testing: Add testing/lisp/test-deduplicator.el * testing/lisp/test-deduplicator.el: Add test unit that checks for duplicate forms in ert tests. * testing/lisp/test-ob-lob.el (test-ob-lob/caching-call-line, test-ob-lob/named-caching-call-line, test-ob/just-one-results-block): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-ob.el (test-ob/just-one-results-block): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org.el (test-org/goto-sibling, test-org/backward-element, test-org/up-element): Ignore duplicate forms via `org-test-ignore-duplicate' --- testing/lisp/test-deduplicator.el | 224 ++++++++++++++++++++++++++++++ testing/lisp/test-ob-lob.el | 10 +- testing/lisp/test-ob.el | 3 +- testing/lisp/test-org.el | 81 ++++++----- 4 files changed, 275 insertions(+), 43 deletions(-) create mode 100644 testing/lisp/test-deduplicator.el diff --git a/testing/lisp/test-deduplicator.el b/testing/lisp/test-deduplicator.el new file mode 100644 index 000000000..28b5d66f0 --- /dev/null +++ b/testing/lisp/test-deduplicator.el @@ -0,0 +1,224 @@ +;;; test-deduplicator.el --- Tests for finding duplicates in Org tests -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Ilya Chernyshov +;; Authors: Ilya Chernyshov <ichernyshovvv@gmail.com> + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. +;; +;;; Commentary: + +;; Unit tests that check for duplicate forms (including `should', +;; `should-not', `should-error') in all Org test files. Forms are +;; considered duplicate if they are `equal-including-properties' and +;; nested at the same level. To ignore a form or a group of forms, +;; wrap them in `org-test-ignore-duplicate'. + +;;; Code: + +(require 'org-test "../testing/org-test") + +(defvar test-deduplicator-files + (directory-files (expand-file-name "lisp" org-test-dir) t "\\.el$")) + +(defvar test-deduplicator-duplicate-forms nil + "A nested list of the form: + + (((file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) + (dup-form-1 . (numerical-order [numerical-order ...])) + [ (dup-form-2 . (numerical-order [numerical-order ...])) + (dup-form-3 . (numerical-order [numerical-order ...])) + ...]) + + ((file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) + (dup-form-1 . (numerical-order [numerical-order ...])) + [ (dup-form-2 . (numerical-order [numerical-order ...])) + (dup-form-3 . (numerical-order [numerical-order ...])) + ...]) + + ... + ) + +Where + + (file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) + +is a path to duplicates. For example, the path for the +duplicates in the following test: + + test-ob-haskell-ghci.el + + (ertdeftest ob-haskell/session-named-none-means-one-shot-sessions () + \"When no session, use a new session. + \"none\" is a special name that means `no session'.\" + (let ((var-1 \"value\")) + (when var-1 + (should-not (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) + (test-ob-haskell-ghci \":session none\" \"x=2\") + (should-not (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) + (test-ob-haskell-ghci \":session none\" \"x=2\")))) + +would look like this: + + (\"test-ob-haskell-ghci.el\" + ob-haskell/session-named-none-means-one-shot-sessions + (let . 4) (when . 2)) + +And the records about the duplicates would look like this: + + ((test-ob-haskell-ghci \":session none\" \"x=2\") 5 3) + ((should-not (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) 4 2)") + +(defvar test-deduplicator-forms nil + "Nested alist of found forms and paths to them (not filtered).") + +(defmacro org-test-ignore-duplicate (&rest body) + "Eval BODY forms sequentially and return value of last one. + +The macro's body will be ignored by +`test-deduplicator/detect-duplicate-tests' test to ignore +duplicate forms inside the body." + (declare (indent 0)) + `(progn ,@body)) + +(ert-deftest test-org-tests/detect-duplicate-tests () + "Try to find duplicate forms." + + (should-not (test-deduplicator-find-duplicates test-deduplicator-files))) + +(defun test-deduplicator-find-duplicates (files) + "Try to find duplicate forms in FILES. + +If duplicates are found, record them into +`test-deduplicator-duplicate-forms', `message' paths to them in a +human-readable format and return the value. + +Forms are considered duplicate if they are nested at the same +level." + (setq test-deduplicator-forms nil) + (dolist (file files) + (with-current-buffer (find-file-noselect file) + (save-excursion + (goto-char (point-min)) + (while (search-forward "(ert-deftest" nil t) + (goto-char (match-beginning 0)) + (ignore-errors + (while-let ((form (or (read (current-buffer)) t))) + (test-deduplicator-search-forms-recursively + form (list file (cadr form))))))))) + (setq test-deduplicator-duplicate-forms + (seq-filter + #'cdr (mapcar + (lambda (file) + (cons + (car file) + (seq-filter #'caddr (cdr file)))) + test-deduplicator-forms))) + (when test-deduplicator-duplicate-forms + (let ((res (concat "Found duplicates (To ignore duplicate forms,\n" + "wrap them in `org-test-ignore-duplicate'):\n"))) + (dolist (path test-deduplicator-duplicate-forms) + (let* ((file (file-relative-name (caar path))) + (test-name (symbol-name (cadar path))) + (path-inside-test (cddar path)) + (result "") + (string-path (append (list file test-name) + (mapcar (lambda (x) + (symbol-name (car x))) + path-inside-test))) + (iter 0) + (print-level 3)) + (dolist (x string-path) + (cl-callf concat result + (format "%s%s\n" (make-string (* iter 2) ? ) x)) + (cl-incf iter)) + (cl-callf concat result + (mapconcat + (lambda (x) (format "%s%S: %d times\n" + (make-string (* iter 2) ? ) + (car x) + (length (cdr x)))) + (cdr path))) + (cl-callf concat res result))) + (message "%s" res))) + test-deduplicator-duplicate-forms) + +(defun test-deduplicator-search-forms-recursively (form form-path) + "Search for forms recursively in FORM. + +FORM-PATH is list of the form: + (\"file-path\" ert-test-symbol + (symbol-1 . sexp-order-1) (symbol-2 . sexp-order-2)) + +Write each form to `test-deduplicator-forms'" + (dotimes (iter (length form)) + (pcase (car-safe (nth iter form)) + ((or `skip-unless `org-test-ignore-duplicate)) + ((pred (not null)) + (push iter (alist-get (nth iter form) + (alist-get form-path test-deduplicator-forms + nil nil #'equal) + nil nil #'equal-including-properties)) + (unless (member (car-safe (nth iter form)) + '(should-not should should-error)) + (test-deduplicator-search-forms-recursively + (nth iter form) + (append form-path (list (cons (car (nth iter form)) iter))))))))) + +;;; Tests + +(defvar test-deduplicator-file-path + (expand-file-name "test-deduplicator.el" + (expand-file-name "lisp" org-test-dir))) + +(ert-deftest test-org-tests/testing-test-deduplicator () + "" + (should + (equal + (test-deduplicator-find-duplicates + (list test-deduplicator-file-path)) + `(((,(expand-file-name "lisp/test-deduplicator.el" org-test-dir) + test-org-tests/test-with-nested-duplicates) + ((format "%s" "string") 7 5) + ((let ((var "string")) (should (message "123 %s" var))) 6 4)) + (((expand-file-name "lisp/test-deduplicator.el" org-test-dir) + test-org-tests/test-with-duplicates-at-root) + ((should (message "123")) 6 4)))))) + +;;; Tests with duplicate forms to check the deduplicator + +(ert-deftest test-org-tests/test-with-duplicates-at-root () + "Test with duplicates at the root." + (should (message "123")) + (format "%s" "string") + (should + (message "123"))) + +(ert-deftest test-org-tests/test-with-nested-duplicates () + "Test with nested duplicates." + (let ((var "string")) + (should + (message "123 %s" var))) + (format "%s" "string") + (let ((var "string")) + (should (message "123 %s" var))) + (format "%s" "string")) + +(provide 'test-deduplicator) + +;;; test-deduplicator.el ends here diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el index 188fee4c0..66dfd0eab 100644 --- a/testing/lisp/test-ob-lob.el +++ b/testing/lisp/test-ob-lob.el @@ -152,8 +152,9 @@ for export (should (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)) ;; if cached, second evaluation will retain the t value - (should - (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))))) + (org-test-ignore-duplicate + (should + (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)))))) (ert-deftest test-ob-lob/named-caching-call-line () (let ((temporary-value-for-test 0)) @@ -170,8 +171,9 @@ for export (should (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)) ;; if cached, second evaluation will retain the t value - (should - (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))))) + (org-test-ignore-duplicate + (should + (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)))))) (ert-deftest test-ob-lob/assignment-with-newline () "Test call lines with an argument containing a newline character." diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 42c77ca56..0153de889 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -645,7 +645,8 @@ duplicate results block." (org-babel-execute-src-block) (org-babel-execute-src-block) ; second code block execution (should (search-forward "Hello")) ; the string inside the source code block - (should (search-forward "Hello")) ; the same string in the results block + (org-test-ignore-duplicate + (should (search-forward "Hello"))) ; the same string in the results block (should-error (search-forward "Hello")))) (ert-deftest test-ob/nested-code-block () diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 612bfa1e5..4e23488be 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2490,7 +2490,8 @@ Text. (should-not (org-goto-sibling)) (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 2")) - (should (org-goto-sibling 'previous)) + (org-test-ignore-duplicate + (should (org-goto-sibling 'previous))) (should (looking-at-p "^\\*\\* Heading 1")) (should-not (org-goto-sibling 'previous))) ;; Inside heading. @@ -2533,7 +2534,8 @@ test <point> (should-not (org-goto-sibling)) (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 2")) - (should (org-goto-sibling 'previous)) + (org-test-ignore-duplicate + (should (org-goto-sibling 'previous))) (should (looking-at-p "^\\*\\* Heading 1")) (should-not (org-goto-sibling 'previous))))) @@ -5223,27 +5225,28 @@ Outside." ;; 7.1. At beginning of sub-list: expected to move to the ;; paragraph before it. (goto-line 4) - (org-backward-element) - (should (looking-at "item1")) - ;; 7.2. At an item in a list: expected to move at previous item. - (goto-line 8) - (org-backward-element) - (should (looking-at " - sub2")) - (goto-line 12) - (org-backward-element) - (should (looking-at "- item1")) - ;; 7.3. At end of list/sub-list: expected to move to list/sub-list - ;; beginning. - (goto-line 10) - (org-backward-element) - (should (looking-at " - sub1")) - (goto-line 15) - (org-backward-element) - (should (looking-at "- item1")) - ;; 7.4. At blank-lines before list end: expected to move to top - ;; item. - (goto-line 14) - (org-backward-element) + (org-test-ignore-duplicate + (org-backward-element) + (should (looking-at "item1")) + ;; 7.2. At an item in a list: expected to move at previous item. + (goto-line 8) + (org-backward-element) + (should (looking-at " - sub2")) + (goto-line 12) + (org-backward-element) + (should (looking-at "- item1")) + ;; 7.3. At end of list/sub-list: expected to move to list/sub-list + ;; beginning. + (goto-line 10) + (org-backward-element) + (should (looking-at " - sub1")) + (goto-line 15) + (org-backward-element) + (should (looking-at "- item1")) + ;; 7.4. At blank-lines before list end: expected to move to top + ;; item. + (goto-line 14) + (org-backward-element)) (should (looking-at "- item1")))) (ert-deftest test-org/up-element () @@ -5281,21 +5284,23 @@ Outside." - item2" ;; 4.1. Within an item: move to the item beginning. (goto-line 8) - (org-up-element) - (should (looking-at " - sub2")) - ;; 4.2. At an item in a sub-list: move to parent item. - (goto-line 4) - (org-up-element) - (should (looking-at "- item1")) - ;; 4.3. At an item in top list: move to beginning of whole list. - (goto-line 10) - (org-up-element) - (should (looking-at "- item1")) - ;; 4.4. Special case. At very top point: should move to parent of - ;; list. - (goto-line 2) - (org-up-element) - (should (looking-at "\\* Top")))) + (org-test-ignore-duplicate + (org-up-element) + (should (looking-at " - sub2")) + ;; 4.2. At an item in a sub-list: move to parent item. + (goto-line 4) + (org-up-element) + (should (looking-at "- item1")) + ;; 4.3. At an item in top list: move to beginning of whole list. + (goto-line 10) + (org-up-element) + (org-test-ignore-duplicate + (should (looking-at "- item1"))) + ;; 4.4. Special case. At very top point: should move to parent of + ;; list. + (goto-line 2) + (org-up-element) + (should (looking-at "\\* Top"))))) (ert-deftest test-org/down-element () "Test `org-down-element' specifications." -- 2.41.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-11-11 8:55 ` Ilya Chernyshov @ 2023-11-16 12:27 ` Ilya Chernyshov 2024-01-16 13:44 ` Ihor Radchenko 1 sibling, 0 replies; 17+ messages in thread From: Ilya Chernyshov @ 2023-11-16 12:27 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode Ilya Chernyshov <ichernyshovvv@gmail.com> writes: > Sure, here it is. In the patch, I added a new file > (testing/lisp/test-deduplicator.el) with a test that checks for > duplicate forms (not just should, should-not, should-error macros) in > all test files. It also makes sense to add a test that searches for completely equal `ert-deftest' definitions and tests with equal bodies, but different names, as you already advised on Matrix. Any other thoughts? ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-11-11 8:55 ` Ilya Chernyshov 2023-11-16 12:27 ` Ilya Chernyshov @ 2024-01-16 13:44 ` Ihor Radchenko 2024-01-23 12:03 ` Ilya Chernyshov 1 sibling, 1 reply; 17+ messages in thread From: Ihor Radchenko @ 2024-01-16 13:44 UTC (permalink / raw) To: Ilya Chernyshov; +Cc: emacs-orgmode Ilya Chernyshov <ichernyshovvv@gmail.com> writes: > There's a lot of tests to change before merging. I'll handle them and > submit a new patch if you have no questions about the code. It has been a while since the last update in this thread. Ilya, do you need any help with the patch? -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2024-01-16 13:44 ` Ihor Radchenko @ 2024-01-23 12:03 ` Ilya Chernyshov 2024-01-26 13:24 ` Ihor Radchenko 0 siblings, 1 reply; 17+ messages in thread From: Ilya Chernyshov @ 2024-01-23 12:03 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 184 bytes --] Ihor Radchenko <yantar92@posteo.net> writes: > It has been a while since the last update in this thread. > Ilya, do you need any help with the patch? Hi, here is the updated patch. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Add-testing-lisp-test-duplicates-detector.el.patch --] [-- Type: text/x-patch, Size: 45973 bytes --] From 2385ba08a89f2966a6d71f92e8693e7def33e3fe Mon Sep 17 00:00:00 2001 From: Ilya Chernyshov <ichernyshovvv@gmail.com> Date: Mon, 22 Jan 2024 01:33:56 +0600 Subject: [PATCH] Add testing/lisp/test-duplicates-detector.el * testing/lisp/test-duplicates-detector.el: Add test unit that checks for duplicate ert-deftests and forms inside of them. * testing/lisp/test-org.el (test-org/file-contents): Delete duplicate `should-' form. * testing/lisp/test-ob-lob.el (test-ob-lob/call-with-header-arguments, test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export, test-ob-lob/caching-call-line, test-ob-lob/named-caching-call-line, test-ob/just-one-results-block): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-ob.el (test-ob/just-one-results-block): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-ob-R.el (test-ob-R/results-file): Ignore duplicate forms via `org-test-ignore-duplicate'. * testing/lisp/test-ob-haskell-ghci.el (ob-haskell/session-named-none-means-one-shot-sessions): Ignore duplicate forms via `org-test-ignore-duplicate'. * testing/lisp/test-ob.el (test-ob/inline-src_blk-default-results-replace-line-1, test-ob/inline-src_blk-default-results-replace-line-2, test-ob/inline-src_blk-manual-results-replace, test-ob/inline-src_blk-results-silent, test-ob/just-one-results-block, test-ob/remove-inline-result, test-ob/goto-named-src-block): Ignore duplicate forms via `org-test-ignore-duplicate'. * testing/lisp/test-org-agenda.el (test-org-agenda/property-timestamp, test-org-agenda/sticky-agenda-filter-preset): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-element.el (test-org-element/cache-headline): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-fold.el (test-org-fold/set-visibility-according-to-property): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-list.el (test-org-list/list-navigation, test-org-list/move-item-down, test-org-list/move-item-up): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-src.el (test-org-src/basic): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-table.el (test-org-table/org-at-TBLFM-p, test-org-table/org-table-TBLFM-begin, test-org-table/org-table-TBLFM-begin-for-multiple-TBLFM-lines, test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-blocks): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org.el (test-org/goto-sibling, test-org/backward-element, test-org/up-element, test-org/org-ctrl-c-ctrl-c, test-org/forward-element): Ignore duplicate forms via `org-test-ignore-duplicate' --- testing/lisp/test-duplicates-detector.el | 316 +++++++++++++++++++++++ testing/lisp/test-ob-R.el | 5 +- testing/lisp/test-ob-haskell-ghci.el | 3 +- testing/lisp/test-ob-lob.el | 87 ++++--- testing/lisp/test-ob.el | 113 ++++---- testing/lisp/test-ol.el | 35 +-- testing/lisp/test-org-agenda.el | 9 +- testing/lisp/test-org-element.el | 18 +- testing/lisp/test-org-fold.el | 29 ++- testing/lisp/test-org-list.el | 31 ++- testing/lisp/test-org-src.el | 3 +- testing/lisp/test-org-table.el | 117 ++++----- testing/lisp/test-org.el | 38 ++- 13 files changed, 568 insertions(+), 236 deletions(-) create mode 100644 testing/lisp/test-duplicates-detector.el diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el new file mode 100644 index 000000000..d39092a9e --- /dev/null +++ b/testing/lisp/test-duplicates-detector.el @@ -0,0 +1,316 @@ +;;; test-duplicates-detector.el --- Tests for finding duplicates in Org tests -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Ilya Chernyshov +;; Authors: Ilya Chernyshov <ichernyshovvv@gmail.com> + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. +;; +;;; Commentary: + +;; Unit tests that check for duplicate forms and tests in all Org test files. + +;; Forms are considered duplicate if they: + +;; 1. are `equal-including-properties', +;; 2. have the same nesting path, +;; 3. either are `should-' macros or have `should-' macros inside. + +;; To ignore a form or a group of forms, wrap them in +;; `org-test-ignore-duplicate'. + +;; `ert-deftest' are considered duplicate if their body are +;; `equal-including-properties.' When comparing, the docstrings are not taken +;; into account. + +;;; Code: + +(require 'org-test "../testing/org-test") + +;;;; Variables + +(defvar test-duplicates-detector-file-path + (expand-file-name "test-duplicates-detector.el" + (expand-file-name "lisp" org-test-dir))) + +(defvar test-duplicates-detector-files + (remove + test-duplicates-detector-file-path + (directory-files + (expand-file-name "lisp" org-test-dir) t "\\.el$"))) + +(defvar test-duplicates-detector-duplicate-forms nil + "A nested list of the form: + + (((file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) + (dup-form-1 . (numerical-order [numerical-order ...])) + [ (dup-form-2 . (numerical-order [numerical-order ...])) + (dup-form-3 . (numerical-order [numerical-order ...])) + ...]) + + ((file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) + (dup-form-1 . (numerical-order [numerical-order ...])) + [ (dup-form-2 . (numerical-order [numerical-order ...])) + (dup-form-3 . (numerical-order [numerical-order ...])) + ...]) + + ... + ) + +Where + + (file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) + +is a path to duplicates. For example, the path for the +duplicates in the following test: + + test-ob-haskell-ghci.el + + (ertdeftest ob-haskell/session-named-none-means-one-shot-sessions () + \"When no session, use a new session. + \"none\" is a special name that means `no session'.\" + (let ((var-1 \"value\")) + (when var-1 + (should-not + (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) + (test-ob-haskell-ghci \":session none\" \"x=2\") + (should-not + (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) + (test-ob-haskell-ghci \":session none\" \"x=2\")))) + +would look like this: + + (\"test-ob-haskell-ghci.el\" + ob-haskell/session-named-none-means-one-shot-sessions + (let . 4) (when . 2)) + +And the records about the duplicates would look like this: + + ((test-ob-haskell-ghci \":session none\" \"x=2\") 5 3) + ((should-not + (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) 4 2)") + +(defvar test-duplicates-detector-forms nil + "Nested alist of found forms and paths to them (not filtered).") + +;;;; Macros + +(defmacro org-test-ignore-duplicate (&rest body) + "Eval BODY forms sequentially and return value of last one. + +The macro's body will be ignored by `test-duplicates-detector.el' +tests to skip duplicate forms inside the body." + (declare (indent 0)) + `(progn ,@body)) + +;;;; ERT tests + +(ert-deftest test-org-tests/find-duplicates () + "Try to find duplicate forms and ert-deftests in FILES." + (should-not + (test-duplicates-detector--find-duplicates + test-duplicates-detector-files))) + +;;;; Auxiliary functions + +(defun test-duplicates-detector--find-duplicates (files) + "Try to find duplicate forms and ert-deftests in FILES. + +Duplicate forms will be written to +`test-duplicates-detector-duplicate-forms'. + +`message' paths to them in a human-readable format." + (setq test-duplicates-detector-forms nil) + (let (found-deftests duplicate-tests) + (dolist (file files) + (with-current-buffer (find-file-noselect file) + (save-excursion + (goto-char (point-min)) + (while (search-forward "(ert-deftest" nil t) + (goto-char (match-beginning 0)) + (ignore-errors + (while-let ((deftest (or (read (current-buffer)) t)) + ((eq (car deftest) 'ert-deftest)) + (test-name (cadr deftest))) + (if-let ((f (seq-find + (lambda (x) + (equal-including-properties + ;; if cadddr is a docstring + (if (stringp (cadddr deftest)) + (cddddr deftest) + (cdddr deftest)) + (if (stringp (cadddr x)) + (cddddr x) + (cdddr x)))) + found-deftests))) + (push (cons test-name (cadr f)) duplicate-tests) + (push deftest found-deftests)) + (test-duplicates-detector--search-forms-recursively + deftest (list file (cadr deftest))))))))) + (setq test-duplicates-detector-duplicate-forms + (seq-filter + #'cdr + (mapcar + (lambda (file) + (cons + (car file) + (seq-filter + (lambda (x) + (and (caddr x) + (seq-intersection + '(should-not should should-error) + (flatten-list (car x))))) + (cdr file)))) + test-duplicates-detector-forms))) + (when test-duplicates-detector-duplicate-forms + (message + "Found duplicates (To ignore the duplicate forms, +wrap them in `org-test-ignore-duplicate'): +%s" + (mapconcat + (lambda (path) + (let* ((file (file-relative-name (caar path))) + (test-name (symbol-name (cadar path))) + (string-path (append (list file test-name) + (mapcar (lambda (x) + (symbol-name (car x))) + (cddar path)))) + (indent -1) + (print-level 3)) + (concat + (mapconcat + (lambda (x) + (concat (make-string (* (setq indent (1+ indent)) 2) ? ) + x "\n")) + string-path) + (mapconcat + (lambda (x) + (format "%s%S: %d times\n" + (make-string (* indent 2) ? ) + (car x) + (length (cdr x)))) + (cdr path))))) + test-duplicates-detector-duplicate-forms))) + (when duplicate-tests + (message "Duplicate ERT tests found:\n%s\n" + (mapconcat (lambda (x) (format "%S" x)) + duplicate-tests "\n"))) + (append test-duplicates-detector-duplicate-forms + duplicate-tests))) + +(defun test-duplicates-detector--search-forms-recursively (form form-path) + "Search for forms recursively in FORM. + +FORM-PATH is list of the form: + (\"file-path\" ert-test-symbol + (symbol-1 . sexp-order-1) (symbol-2 . sexp-order-2)) + +Write each form to `test-duplicates-detector-forms'" + (dotimes (iter (length form)) + (when (and + (car-safe (nth iter form)) + (not + (eq (car-safe (nth iter form)) + 'org-test-ignore-duplicate))) + (push iter (alist-get + (nth iter form) + (alist-get form-path test-duplicates-detector-forms + nil nil #'equal) + nil nil #'equal-including-properties)) + (unless (memq (car-safe (nth iter form)) + '(should-not should should-error)) + (test-duplicates-detector--search-forms-recursively + (nth iter form) + (append form-path (list (cons (car (nth iter form)) iter)))))))) + +;;;; Testing the detector itself + +(ert-deftest test-duplicates-detector-testing-find-duplicates () + "Test `test-duplicates-detector--find-duplicates'." + (should + (equal + (test-duplicates-detector--find-duplicates + (list test-duplicates-detector-file-path)) + `((((,test-duplicates-detector-file-path + test-org-tests/test-with-nested-duplicates) + ((let ((var "string")) (should (message "123 %s" var))) 6 4)) + ((,test-duplicates-detector-file-path + test-org-tests/test-with-duplicates-at-root) + ((should (message "123")) 6 4))) + ((test-org-tests/duplicate-test-2 . test-org-tests/duplicate-test-1)))))) + +;;;;; Tests with duplicate forms + +(ert-deftest test-org-tests/test-with-duplicates-at-root () + "Test with duplicates at the root." + (should (message "123")) + (format "%s" "string") + (should + (message "123"))) + +(ert-deftest test-org-tests/test-with-nested-duplicates () + "Test with nested duplicates." + (let ((var "string")) + (should + (message "123 %s" var))) + (format "%s" "string") + (let ((var "string")) + (should (message "123 %s" var))) + (format "%s" "string")) + +;;;;; Tests without duplicates + +(ert-deftest test-org-tests/test-without-duplicates-1 () + "Test without duplicates." + (let ((var-1 "asd")) + (concat "string" var-1)) + (should + (let ((var-1 "asd")) + (concat "string" var-1)))) + +(ert-deftest test-org-tests/test-without-duplicates-2 () + "Test without duplicates. +Equal `should' macros, but different nesting paths." + (let ((var "string")) + (should (format "123 %s" "asd"))) + (+ 5 6 9) + (should (format "123 %s" "asd"))) + +;;;;; Duplicate deftests (maybe different names, but same body) + +(ert-deftest test-org-tests/duplicate-test-1 () + "Docstring of duplicate-test-1." + (let ((var 99)) + (+ 5 6 9 var) + (should (format "123 %s" "asd"))) + (should (format "123 %s" "asd"))) + +(ert-deftest test-org-tests/duplicate-test-2 () + "Docstring of duplicate-test-2." + (let ((var 99)) + (+ 5 6 9 var) + (should (format "123 %s" "asd"))) + (should (format "123 %s" "asd"))) + +(provide 'test-duplicates-detector) + +;; Local Variables: +;; outline-regexp: "\\(;\\{3,\\} \\)" +;; End: + +;;; test-duplicates-detector.el ends here diff --git a/testing/lisp/test-ob-R.el b/testing/lisp/test-ob-R.el index 9ffbf3afd..52e093edd 100644 --- a/testing/lisp/test-ob-R.el +++ b/testing/lisp/test-ob-R.el @@ -98,8 +98,9 @@ x #+END_SRC" (goto-char (point-min)) (org-babel-execute-maybe) (org-babel-goto-named-result "TESTSRC") (forward-line 1) - (should (string= "[[file:junk/test.org]]" - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= "[[file:junk/test.org]]" + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (goto-char (point-min)) (forward-line 1) (insert "#+header: :session\n") (goto-char (point-min)) (org-babel-execute-maybe) diff --git a/testing/lisp/test-ob-haskell-ghci.el b/testing/lisp/test-ob-haskell-ghci.el index cbd5f6f9a..55c0eb2b8 100644 --- a/testing/lisp/test-ob-haskell-ghci.el +++ b/testing/lisp/test-ob-haskell-ghci.el @@ -118,7 +118,8 @@ main "When no session, use a new session. \"none\" is a special name that means `no session'." (test-ob-haskell-ghci ":session none" "x=2" nil) - (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil))) + (org-test-ignore-duplicate + (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil)))) (test-ob-haskell-ghci ":session none" "x=2" nil) (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil)))) diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el index 188fee4c0..1a3fdff16 100644 --- a/testing/lisp/test-ob-lob.el +++ b/testing/lisp/test-ob-lob.el @@ -62,44 +62,45 @@ (move-beginning-of-line 1) (forward-line 6) (message (buffer-substring (point-at-bol) (point-at-eol))) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) (beginning-of-line) (forward-char 27) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) (beginning-of-line) (forward-char 27) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) (beginning-of-line) - (should - (= 4 (org-babel-execute-src-block nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) + (org-test-ignore-duplicate + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) (beginning-of-line) (forward-char 27) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) (beginning-of-line) (forward-char 27) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) (beginning-of-line) + (should + (= 4 (org-babel-execute-src-block nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) (forward-line 1) (should (string= "123" (org-babel-execute-src-block nil (org-babel-lob-get-info)))))))) @@ -149,8 +150,9 @@ for export <point>#+call: call-line-caching-example(\"qux\") :cache yes " ;; first execution should flip value to t - (should - (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)) + (org-test-ignore-duplicate + (should + (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))) ;; if cached, second evaluation will retain the t value (should (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))))) @@ -167,8 +169,9 @@ for export <point>#+call: call-line-caching-example(\"qux\") :cache yes " ;; first execution should flip value to t - (should - (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)) + (org-test-ignore-duplicate + (should + (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))) ;; if cached, second evaluation will retain the t value (should (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 42c77ca56..c16b47954 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -362,13 +362,15 @@ at the beginning of a line." (org-test-with-temp-text test-line (goto-char (point-min)) (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=1=)}}}") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=1=)}}}") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (forward-char) (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=1=)}}}") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=1=)}}}") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (re-search-forward "{{{") ;;(should-error (org-ctrl-c-ctrl-c)) (backward-char 4) ;; last char of block body @@ -380,11 +382,13 @@ at the beginning of a line." (let ((test-line " src_emacs-lisp{ 1 }")) (org-test-with-temp-text test-line - (should-error (org-ctrl-c-ctrl-c)) + (org-test-ignore-duplicate + (should-error (org-ctrl-c-ctrl-c))) (forward-char) (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=1=)}}}") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=1=)}}}") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (re-search-forward "{ 1 ") (org-babel-execute-maybe) (should (string= (concat test-line " {{{results(=1=)}}}") @@ -426,9 +430,11 @@ at the beginning of a line." (org-babel-inline-result-wrap "=%s=")) (org-test-with-temp-text (concat "\n" test-line) - (should-error (org-ctrl-c-ctrl-c)) + (org-test-ignore-duplicate + (should-error (org-ctrl-c-ctrl-c))) (goto-char (point-min)) - (should-error (org-ctrl-c-ctrl-c)) + (org-test-ignore-duplicate + (should-error (org-ctrl-c-ctrl-c))) (forward-line) (should-error (org-ctrl-c-ctrl-c)) (forward-char) (org-babel-execute-maybe) @@ -443,9 +449,10 @@ at the beginning of a line." (goto-char (point-max)) (insert (concat "\n" test-line " end")) (re-search-backward "src") (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=y=)}}} end") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=y=)}}} end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (re-search-forward "\" ") (org-babel-execute-maybe) (should (string= (concat test-line " {{{results(=y=)}}} end") @@ -458,7 +465,8 @@ at the beginning of a line." (org-babel-inline-result-wrap "=%s=")) (org-test-with-temp-text (concat "\n" test-line) - (should-error (org-ctrl-c-ctrl-c)) + (org-test-ignore-duplicate + (should-error (org-ctrl-c-ctrl-c))) (goto-char (point-max)) (org-babel-execute-maybe) (beginning-of-line) @@ -475,9 +483,10 @@ at the beginning of a line." (goto-char (point-max)) (insert (concat "\n" test-line " end")) (re-search-backward "src") (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=y=)}}} end") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=y=)}}} end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (re-search-forward "\" ") (org-babel-execute-maybe) (should (string= (concat test-line " {{{results(=y=)}}} end") @@ -499,9 +508,10 @@ at the beginning of a line." (goto-char (point-max)) (insert (concat "\n" test-line " end")) (re-search-backward "src_") (org-babel-execute-maybe) - (should (string= (concat test-line " end") - (buffer-substring-no-properties - (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= (concat test-line " end") + (buffer-substring-no-properties + (point-at-bol) (point-at-eol))))) (re-search-forward "\" ") (org-babel-execute-maybe) (should (string= (concat test-line " end") (buffer-substring-no-properties @@ -644,7 +654,8 @@ duplicate results block." (org-test-with-temp-text "#+begin_src sh :results output\necho Hello\n#+end_src\n" (org-babel-execute-src-block) (org-babel-execute-src-block) ; second code block execution - (should (search-forward "Hello")) ; the string inside the source code block + (org-test-ignore-duplicate + (should (search-forward "Hello"))) ; the string inside the source code block (should (search-forward "Hello")) ; the same string in the results block (should-error (search-forward "Hello")))) @@ -1159,9 +1170,10 @@ x (point-at-bol) (point-at-eol)))) ;; Delete whitespace and result. (org-babel-remove-inline-result) - (should (string= inline-sb-dot - (buffer-substring-no-properties - (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= inline-sb-dot + (buffer-substring-no-properties + (point-at-bol) (point-at-eol))))) ;; Add whitespace and result before dot. (search-forward inline-sb) (insert " " inline-res) @@ -2466,31 +2478,32 @@ abc #+RESULTS: abc : 2 " - ;; non-existent name - (should-not + (org-test-ignore-duplicate + ;; non-existent name + (should-not (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nno-name\n")) - ;; correct name - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nabc\n") - (should (= 14 (point))) - ;; call line - autocompletion - (forward-line 3) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - ;; noweb reference - autocompletion - (forward-line 5) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - ;; at symbol - autocompletion - (forward-line 7) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - ;; in results - autocompletion - (forward-line 8) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - (forward-line 9) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))))) + ;; correct name + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nabc\n") + (should (= 14 (point))) + ;; call line - autocompletion + (forward-line 3) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + ;; noweb reference - autocompletion + (forward-line 5) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + ;; at symbol - autocompletion + (forward-line 7) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + ;; in results - autocompletion + (forward-line 8) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + (forward-line 9) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point)))))) (ert-deftest test-ob/evaluate-body-with-coderefs () (should diff --git a/testing/lisp/test-ol.el b/testing/lisp/test-ol.el index e0cec0854..6a44e5bdc 100644 --- a/testing/lisp/test-ol.el +++ b/testing/lisp/test-ol.el @@ -60,23 +60,24 @@ See https://github.com/yantar92/org/issues/4." (dolist (org-link-descriptive '(nil t)) (org-test-with-temp-text "* Org link test [[https://example.com][A link to a site]]" - (dotimes (_ 2) - (goto-char 1) - (re-search-forward "\\[") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "example") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "com") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "]") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "\\[") - (should-not (org-invisible-p)) - (re-search-forward "link") - (should-not (org-invisible-p)) - (re-search-forward "]") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (org-toggle-link-display))))) + (org-test-ignore-duplicate + (dotimes (_ 2) + (goto-char 1) + (re-search-forward "\\[") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "example") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "com") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "]") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "\\[") + (should-not (org-invisible-p)) + (re-search-forward "link") + (should-not (org-invisible-p)) + (re-search-forward "]") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (org-toggle-link-display)))))) \f ;;; Escape and Unescape Links diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el index 976d88a9e..ce7ae3c63 100644 --- a/testing/lisp/test-org-agenda.el +++ b/testing/lisp/test-org-agenda.el @@ -346,7 +346,8 @@ See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com" ;; `org-today' or not. (org-agenda-list nil "<2022-03-22 Tue>") (set-buffer org-agenda-buffer-name) - (should (= 3 (count-lines (point-min) (point-max)))) + (org-test-ignore-duplicate + (should (= 3 (count-lines (point-min) (point-max))))) ;; NOTE: Be aware that `org-agenda-list' may or may not display ;; past scheduled items depending whether the date is today ;; `org-today' or not. @@ -443,14 +444,16 @@ See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com" (set-buffer "*Org Agenda(f)*") (org-agenda-redo) (goto-char (point-min)) - (should (not (invisible-p (1- (search-forward "TODO Foo"))))) + (org-test-ignore-duplicate + (should (not (invisible-p (1- (search-forward "TODO Foo")))))) (org-test-agenda--kill-all-agendas) (org-agenda nil "f1") (org-agenda nil "b1") (set-buffer "*Org Agenda(f1:+CATEGORY=\"foo\")*") (org-agenda-redo) (goto-char (point-min)) - (should (not (invisible-p (1- (search-forward "TODO Foo"))))) + (org-test-ignore-duplicate + (should (not (invisible-p (1- (search-forward "TODO Foo")))))) (org-test-agenda--kill-all-agendas) (org-agenda nil "f2") (org-agenda nil "b2") diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index ca7d77e28..6e0e5c5ec 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -5203,11 +5203,12 @@ Aliquam erat volutpat. (org-element-at-point)) (insert ":CATEOGORY: cat\n") (search-backward "* Heading") - (should - (eq (org-element-property :end (org-element-at-point)) - (save-excursion - (search-forward "* Heading 2") - (line-beginning-position)))) + (org-test-ignore-duplicate + (should + (eq (org-element-property :end (org-element-at-point)) + (save-excursion + (search-forward "* Heading 2") + (line-beginning-position))))) (search-forward "* Heading 2") (beginning-of-line) (insert "\n\n") @@ -5247,9 +5248,10 @@ Aliquam erat volutpat. (org-element-at-point (point-max)) (insert "* heading 2") (beginning-of-line) - (should - (eq (point-max) - (org-element-property :end (org-element-at-point)))) + (org-test-ignore-duplicate + (should + (eq (point-max) + (org-element-property :end (org-element-at-point))))) (delete-char 1) (search-backward "* Heading") (should diff --git a/testing/lisp/test-org-fold.el b/testing/lisp/test-org-fold.el index 9f15f0a38..7fd4b015c 100644 --- a/testing/lisp/test-org-fold.el +++ b/testing/lisp/test-org-fold.el @@ -329,20 +329,21 @@ Some text here ** AC * B " - (org-set-regexps-and-options) - (org-cycle-set-startup-visibility) - (search-forward "A") - (should-not (invisible-p (point))) - (search-forward "AB") - (should (invisible-p (point))) - (search-forward "ABA") - (should (invisible-p (point))) - (search-forward "ABAB") - (should (invisible-p (point))) - (search-forward "AC") - (should (invisible-p (point))) - (search-forward "B") - (should-not (invisible-p (point)))) + (org-test-ignore-duplicate + (org-set-regexps-and-options) + (org-cycle-set-startup-visibility) + (search-forward "A") + (should-not (invisible-p (point))) + (search-forward "AB") + (should (invisible-p (point))) + (search-forward "ABA") + (should (invisible-p (point))) + (search-forward "ABAB") + (should (invisible-p (point))) + (search-forward "AC") + (should (invisible-p (point))) + (search-forward "B") + (should-not (invisible-p (point))))) ;; "children" state. (should (org-test-with-temp-text diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index 0ee3a14c2..89c42b400 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -61,11 +61,14 @@ ;; a list/sub-list, unless `org-list-use-circular-motion' ;; is non-nil. (goto-line 9) - (should-error (org-next-item)) - (let ((org-list-use-circular-motion t)) - (should (progn (org-next-item) t))) + (org-test-ignore-duplicate + (should-error (org-next-item))) + (org-test-ignore-duplicate + (let ((org-list-use-circular-motion t)) + (should (progn (org-next-item) t)))) (goto-line 14) - (should-error (org-next-item)) + (org-test-ignore-duplicate + (should-error (org-next-item))) (let ((org-list-use-circular-motion t)) (should (progn (org-next-item) t))) ;; 1.2. Should jump over sub-lists. @@ -91,11 +94,14 @@ ;; a list/sub-list, unless `org-list-use-circular-motion is ;; non-nil. (goto-line 7) - (should-error (org-previous-item)) - (let ((org-list-use-circular-motion t)) - (should (progn (org-previous-item) t))) + (org-test-ignore-duplicate + (should-error (org-previous-item))) + (org-test-ignore-duplicate + (let ((org-list-use-circular-motion t)) + (should (progn (org-previous-item) t)))) (goto-line 13) - (should-error (org-previous-item)) + (org-test-ignore-duplicate + (should-error (org-previous-item))) (let ((org-list-use-circular-motion t)) (should (progn (org-previous-item) t))) ;; 2.2. Should ignore sub-lists. @@ -705,7 +711,8 @@ b. Item 2<point>" (search-backward "- item 1") (org-move-item-down) (search-forward "sub-body 1") - (should (org-invisible-p2)) + (org-test-ignore-duplicate + (should (org-invisible-p2))) (search-backward "sub-body 2") (should (org-invisible-p2)))) @@ -784,7 +791,8 @@ b. Item 2<point>" (org-cycle)) (org-move-item-up) (forward-line) - (should (org-invisible-p2)) + (org-test-ignore-duplicate + (should (org-invisible-p2))) (search-forward " body 1") (should (org-invisible-p2))) ;; Preserve children visibility. @@ -803,7 +811,8 @@ b. Item 2<point>" (search-backward "- item 2") (org-move-item-up) (search-forward "sub-body 2") - (should (org-invisible-p2)) + (org-test-ignore-duplicate + (should (org-invisible-p2))) (search-forward "sub-body 1") (should (org-invisible-p2)))) diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el index ebf8d8569..c079cc464 100644 --- a/testing/lisp/test-org-src.el +++ b/testing/lisp/test-org-src.el @@ -54,7 +54,8 @@ #+end_src " (goto-line 1) - (should-error (org-edit-special)) + (org-test-ignore-duplicate + (should-error (org-edit-special))) (goto-char (point-max)) (should-error (org-edit-special)))) diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 92ccd2a05..8eda95f3e 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1120,7 +1120,8 @@ See also `test-org-table/copy-field'." " (goto-char (point-min)) (forward-line 2) - (should (equal (org-at-TBLFM-p) nil)) + (org-test-ignore-duplicate + (should (equal (org-at-TBLFM-p) nil))) (goto-char (point-min)) (forward-line 3) @@ -1139,25 +1140,21 @@ See also `test-org-table/copy-field'." " (goto-char (point-min)) - (should (equal (org-table-TBLFM-begin) - nil)) + (org-test-ignore-duplicate + (should (equal (org-table-TBLFM-begin) nil))) (goto-char (point-min)) (forward-line 1) - (should (equal (org-table-TBLFM-begin) - nil)) + (should (equal (org-table-TBLFM-begin) nil)) (goto-char (point-min)) (forward-line 3) - (should (= (org-table-TBLFM-begin) - 14)) + (org-test-ignore-duplicate + (should (= (org-table-TBLFM-begin) 14))) (goto-char (point-min)) (forward-line 4) - (should (= (org-table-TBLFM-begin) - 14)) - - )) + (should (= (org-table-TBLFM-begin) 14)))) (ert-deftest test-org-table/org-table-TBLFM-begin-for-multiple-TBLFM-lines () "For multiple #+TBLFM lines." @@ -1169,31 +1166,25 @@ See also `test-org-table/copy-field'." #+TBLFM: $2=$1*2 " - (goto-char (point-min)) - (should (equal (org-table-TBLFM-begin) - nil)) - - (goto-char (point-min)) - (forward-line 1) - (should (equal (org-table-TBLFM-begin) - nil)) + (org-test-ignore-duplicate + (goto-char (point-min)) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 3) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 1) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 4) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 3) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 5) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 4) + (should (= (org-table-TBLFM-begin) 14)) - )) + (goto-char (point-min)) + (forward-line 5) + (should (= (org-table-TBLFM-begin) 14))))) (ert-deftest test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-blocks () (org-test-with-temp-text-in-file @@ -1209,49 +1200,41 @@ See also `test-org-table/copy-field'." #+TBLFM: $2=$1*2 " - (goto-char (point-min)) - (should (equal (org-table-TBLFM-begin) - nil)) + (org-test-ignore-duplicate + (goto-char (point-min)) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 1) - (should (equal (org-table-TBLFM-begin) - nil)) + (goto-char (point-min)) + (forward-line 1) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 3) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 3) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 4) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 4) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 5) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 5) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 6) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 6) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 8) - (should (= (org-table-TBLFM-begin) - 61)) + (goto-char (point-min)) + (forward-line 8) + (should (= (org-table-TBLFM-begin) 61)) - (goto-char (point-min)) - (forward-line 9) - (should (= (org-table-TBLFM-begin) - 61)) + (goto-char (point-min)) + (forward-line 9) + (should (= (org-table-TBLFM-begin) 61)) - (goto-char (point-min)) - (forward-line 10) - (should (= (org-table-TBLFM-begin) - 61)))) + (goto-char (point-min)) + (forward-line 10) + (should (= (org-table-TBLFM-begin) 61))))) (ert-deftest test-org-table/org-table-calc-current-TBLFM () (org-test-with-temp-text-in-file diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 822cbc67a..d379ee3bf 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2488,7 +2488,8 @@ Text. (should (org-goto-sibling)) (should (looking-at-p "^\\*\\* Heading 3")) (should-not (org-goto-sibling)) - (should (org-goto-sibling 'previous)) + (org-test-ignore-duplicate + (should (org-goto-sibling 'previous))) (should (looking-at-p "^\\*\\* Heading 2")) (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 1")) @@ -2531,7 +2532,8 @@ test <point> (should (org-goto-sibling)) (should (looking-at-p "^\\*\\* Heading 3")) (should-not (org-goto-sibling)) - (should (org-goto-sibling 'previous)) + (org-test-ignore-duplicate + (should (org-goto-sibling 'previous))) (should (looking-at-p "^\\*\\* Heading 2")) (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 1")) @@ -3994,17 +3996,6 @@ SCHEDULED: <2017-05-06 Sat> (org-file-contents "http://this-url-must-not-exist")) (kill-buffer buffer)))) ;; Try to access an invalid URL, but do not throw an error. - (should-error - (let ((buffer (generate-new-buffer "url-retrieve-output"))) - (unwind-protect - ;; Simulate unsuccessful retrieval of a URL. - (cl-letf (((symbol-function 'url-retrieve-synchronously) - (lambda (&rest_) - (with-current-buffer buffer - (insert "HTTP/1.1 404 Not found\n\ndoes not matter")) - buffer))) - (org-file-contents "http://this-url-must-not-exist")) - (kill-buffer buffer)))) (should (let ((buffer (generate-new-buffer "url-retrieve-output"))) (unwind-protect @@ -4027,7 +4018,8 @@ SCHEDULED: <2017-05-06 Sat> * Heading<point> text" (org-overview) - (should (org-fold-folded-p (point) 'outline)) + (org-test-ignore-duplicate + (should (org-fold-folded-p (point) 'outline))) (save-excursion (goto-char (point-min)) (org-ctrl-c-ctrl-c)) @@ -5127,7 +5119,8 @@ asd ;; same level. (goto-line 3) (org-forward-element) - (should (looking-at (regexp-quote "** Head 1.2"))) + (org-test-ignore-duplicate + (should (looking-at (regexp-quote "** Head 1.2")))) ;; 3.2. At an headline beginning: move to parent headline if no ;; headline at the same level. (goto-line 3) @@ -5138,7 +5131,8 @@ asd "#+BEGIN_CENTER\nInside.\n#+END_CENTER\n\nOutside." ;; 4.1. At a greater element: expected to skip contents. (org-forward-element) - (should (looking-at (regexp-quote "Outside."))) + (org-test-ignore-duplicate + (should (looking-at (regexp-quote "Outside.")))) ;; 4.2. At the end of greater element contents: expected to skip ;; to the end of the greater element. (goto-line 2) @@ -5177,7 +5171,8 @@ Outside." ;; 5.3 At sub-list beginning: expected to move after the sub-list. (goto-line 4) (org-forward-element) - (should (looking-at (regexp-quote " Inner paragraph."))) + (org-test-ignore-duplicate + (should (looking-at (regexp-quote " Inner paragraph.")))) ;; 5.4. At sub-list end: expected to move outside the sub-list. (goto-line 8) (org-forward-element) @@ -5264,7 +5259,8 @@ Outside." (should (looking-at " - sub2")) (goto-line 12) (org-backward-element) - (should (looking-at "- item1")) + (org-test-ignore-duplicate + (should (looking-at "- item1"))) ;; 7.3. At end of list/sub-list: expected to move to list/sub-list ;; beginning. (goto-line 10) @@ -5272,7 +5268,8 @@ Outside." (should (looking-at " - sub1")) (goto-line 15) (org-backward-element) - (should (looking-at "- item1")) + (org-test-ignore-duplicate + (should (looking-at "- item1"))) ;; 7.4. At blank-lines before list end: expected to move to top ;; item. (goto-line 14) @@ -5319,7 +5316,8 @@ Outside." ;; 4.2. At an item in a sub-list: move to parent item. (goto-line 4) (org-up-element) - (should (looking-at "- item1")) + (org-test-ignore-duplicate + (should (looking-at "- item1"))) ;; 4.3. At an item in top list: move to beginning of whole list. (goto-line 10) (org-up-element) -- 2.41.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2024-01-23 12:03 ` Ilya Chernyshov @ 2024-01-26 13:24 ` Ihor Radchenko 2024-01-27 5:04 ` Ilya Chernyshov 0 siblings, 1 reply; 17+ messages in thread From: Ihor Radchenko @ 2024-01-26 13:24 UTC (permalink / raw) To: Ilya Chernyshov; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 329 bytes --] Ilya Chernyshov <ichernyshovvv@gmail.com> writes: > Ihor Radchenko <yantar92@posteo.net> writes: > >> It has been a while since the last update in this thread. >> Ilya, do you need any help with the patch? > > Hi, here is the updated patch. Thanks! What about the attached amendment? It should simplify things significantly. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-test-duplicates-detector.el-Do-not-search-duplicates.patch --] [-- Type: text/x-patch, Size: 38166 bytes --] From b14840aa81784547a6dd03aec510e23c898d97ec Mon Sep 17 00:00:00 2001 Message-ID: <b14840aa81784547a6dd03aec510e23c898d97ec.1706275424.git.yantar92@posteo.net> From: Ihor Radchenko <yantar92@posteo.net> Date: Fri, 26 Jan 2024 14:21:55 +0100 Subject: [PATCH] test-duplicates-detector.el: Do not search duplicates inside progn-like forms * testing/lisp/test-duplicates-detector.el (test-duplicates-progn-forms): New variable holding a list of forms equivalent to `progn'. * testing/lisp/test-duplicates-detector.el (test-duplicates-detector--search-forms-recursively): Refactor. Skip duplicate checks inside immediate children of `progn'-like constructs. * testing/lisp/test-ob-R.el (test-ob-R/results-file): * testing/lisp/test-ob-haskell-ghci.el (ob-haskell/session-named-none-means-one-shot-sessions): * testing/lisp/test-ob-lob.el (test-ob-lob/call-with-header-arguments): (test-ob-lob/caching-call-line): (test-ob-lob/named-caching-call-line): * testing/lisp/test-ob.el (test-ob/inline-src_blk-default-results-replace-line-1): (test-ob/inline-src_blk-default-results-replace-line-2): (test-ob/inline-src_blk-manual-results-replace): (test-ob/inline-src_blk-results-silent): (test-ob/just-one-results-block): (test-ob/remove-inline-result): (test-ob/goto-named-src-block): * testing/lisp/test-ol.el (test-org-link/toggle-link-display): * testing/lisp/test-org-agenda.el (test-org-agenda/property-timestamp): (test-org-agenda/sticky-agenda-filter-preset): * testing/lisp/test-org-element.el: (test-org-element/cache-headline): * testing/lisp/test-org-fold.el: (test-org-fold/set-visibility-according-to-property): * testing/lisp/test-org-list.el: (test-org-list/list-navigation): (test-org-list/move-item-down): (test-org-list/move-item-up): * testing/lisp/test-org-src.el: (test-org-src/point-outside-block): * testing/lisp/test-org-table.el: (test-org-table/org-at-TBLFM-p): (test-org-table/org-table-TBLFM-begin): (test-org-table/org-table-TBLFM-begin-for-multiple-TBLFM-lines): (test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-blocks): * testing/lisp/test-org.el: (test-org/goto-sibling): (test-org/org-ctrl-c-ctrl-c): (test-org/forward-element): (test-org/backward-element): (test-org/up-element): Remove unnecessary `org-test-ignore-duplicate'. --- testing/lisp/test-duplicates-detector.el | 34 ++++--- testing/lisp/test-ob-R.el | 21 ++-- testing/lisp/test-ob-haskell-ghci.el | 3 +- testing/lisp/test-ob-lob.el | 87 ++++++++--------- testing/lisp/test-ob.el | 117 ++++++++++------------- testing/lisp/test-ol.el | 35 ++++--- testing/lisp/test-org-agenda.el | 9 +- testing/lisp/test-org-element.el | 18 ++-- testing/lisp/test-org-fold.el | 29 +++--- testing/lisp/test-org-list.el | 31 +++--- testing/lisp/test-org-src.el | 3 +- testing/lisp/test-org-table.el | 93 +++++++++--------- testing/lisp/test-org.el | 27 ++---- 13 files changed, 232 insertions(+), 275 deletions(-) diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el index d39092a9e..d6f8aca5a 100644 --- a/testing/lisp/test-duplicates-detector.el +++ b/testing/lisp/test-duplicates-detector.el @@ -41,6 +41,14 @@ (require 'org-test "../testing/org-test") ;;;; Variables +(defvar test-duplicates-progn-forms + '( progn + org-test-with-temp-text + org-test-with-temp-text-in-file + org-test-ignore-duplicate) + "List of forms equivalent to `progn'. +Immediate children inside these are not checked for duplicates.") + (defvar test-duplicates-detector-file-path (expand-file-name "test-duplicates-detector.el" (expand-file-name "lisp" org-test-dir))) @@ -221,22 +229,20 @@ (defun test-duplicates-detector--search-forms-recursively (form form-path) (symbol-1 . sexp-order-1) (symbol-2 . sexp-order-2)) Write each form to `test-duplicates-detector-forms'" - (dotimes (iter (length form)) - (when (and - (car-safe (nth iter form)) - (not - (eq (car-safe (nth iter form)) - 'org-test-ignore-duplicate))) - (push iter (alist-get - (nth iter form) - (alist-get form-path test-duplicates-detector-forms - nil nil #'equal) - nil nil #'equal-including-properties)) - (unless (memq (car-safe (nth iter form)) + (let ((idx 0)) + (dolist (sub-form form) + (unless (memq (car-safe sub-form) test-duplicates-progn-forms) + (push idx (alist-get + sub-form + (alist-get form-path test-duplicates-detector-forms + nil nil #'equal) + nil nil #'equal-including-properties))) + (unless (memq (car-safe sub-form) '(should-not should should-error)) (test-duplicates-detector--search-forms-recursively - (nth iter form) - (append form-path (list (cons (car (nth iter form)) iter)))))))) + sub-form + (append form-path (list (cons (car sub-form) idx))))) + (cl-incf idx)))) ;;;; Testing the detector itself diff --git a/testing/lisp/test-ob-R.el b/testing/lisp/test-ob-R.el index 52e093edd..47211a1a9 100644 --- a/testing/lisp/test-ob-R.el +++ b/testing/lisp/test-ob-R.el @@ -96,17 +96,16 @@ (ert-deftest test-ob-R/results-file () a <- file.path(\"junk\", \"test.org\") a #+END_SRC" - (goto-char (point-min)) (org-babel-execute-maybe) - (org-babel-goto-named-result "TESTSRC") (forward-line 1) - (org-test-ignore-duplicate - (should (string= "[[file:junk/test.org]]" - (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) - (goto-char (point-min)) (forward-line 1) - (insert "#+header: :session\n") - (goto-char (point-min)) (org-babel-execute-maybe) - (org-babel-goto-named-result "TESTSRC") (forward-line 1) - (should (string= "[[file:junk/test.org]]" - (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))) + (goto-char (point-min)) (org-babel-execute-maybe) + (org-babel-goto-named-result "TESTSRC") (forward-line 1) + (should (string= "[[file:junk/test.org]]" + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (goto-char (point-min)) (forward-line 1) + (insert "#+header: :session\n") + (goto-char (point-min)) (org-babel-execute-maybe) + (org-babel-goto-named-result "TESTSRC") (forward-line 1) + (should (string= "[[file:junk/test.org]]" + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))) diff --git a/testing/lisp/test-ob-haskell-ghci.el b/testing/lisp/test-ob-haskell-ghci.el index 55c0eb2b8..cbd5f6f9a 100644 --- a/testing/lisp/test-ob-haskell-ghci.el +++ b/testing/lisp/test-ob-haskell-ghci.el @@ -118,8 +118,7 @@ (ert-deftest ob-haskell/session-named-none-means-one-shot-sessions () "When no session, use a new session. \"none\" is a special name that means `no session'." (test-ob-haskell-ghci ":session none" "x=2" nil) - (org-test-ignore-duplicate - (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil)))) + (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil))) (test-ob-haskell-ghci ":session none" "x=2" nil) (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil)))) diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el index 1a3fdff16..4d159fdb0 100644 --- a/testing/lisp/test-ob-lob.el +++ b/testing/lisp/test-ob-lob.el @@ -62,45 +62,44 @@ (ert-deftest test-ob-lob/call-with-header-arguments () (move-beginning-of-line 1) (forward-line 6) (message (buffer-substring (point-at-bol) (point-at-eol))) - (org-test-ignore-duplicate - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) (beginning-of-line) (forward-char 27) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) (beginning-of-line) (forward-char 27) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) (beginning-of-line) - (should - (= 4 (org-babel-execute-src-block nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) (beginning-of-line) (forward-char 27) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) (beginning-of-line) (forward-char 27) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) (beginning-of-line) + (should + (= 4 (org-babel-execute-src-block nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) (forward-line 1) (should (string= "123" (org-babel-execute-src-block nil (org-babel-lob-get-info)))))))) @@ -150,9 +149,8 @@ (ert-deftest test-ob-lob/caching-call-line () <point>#+call: call-line-caching-example(\"qux\") :cache yes " ;; first execution should flip value to t - (org-test-ignore-duplicate - (should - (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))) + (should + (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)) ;; if cached, second evaluation will retain the t value (should (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))))) @@ -169,9 +167,8 @@ (ert-deftest test-ob-lob/named-caching-call-line () <point>#+call: call-line-caching-example(\"qux\") :cache yes " ;; first execution should flip value to t - (org-test-ignore-duplicate - (should - (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))) + (should + (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)) ;; if cached, second evaluation will retain the t value (should (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index c16b47954..afa414294 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -362,15 +362,13 @@ (ert-deftest test-ob/inline-src_blk-default-results-replace-line-1 () (org-test-with-temp-text test-line (goto-char (point-min)) (org-babel-execute-maybe) - (org-test-ignore-duplicate - (should (string= - (concat test-line " {{{results(=1=)}}}") - (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + (should (string= + (concat test-line " {{{results(=1=)}}}") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) (forward-char) (org-babel-execute-maybe) - (org-test-ignore-duplicate - (should (string= - (concat test-line " {{{results(=1=)}}}") - (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + (should (string= + (concat test-line " {{{results(=1=)}}}") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) (re-search-forward "{{{") ;;(should-error (org-ctrl-c-ctrl-c)) (backward-char 4) ;; last char of block body @@ -382,13 +380,11 @@ (ert-deftest test-ob/inline-src_blk-default-results-replace-line-1 () (let ((test-line " src_emacs-lisp{ 1 }")) (org-test-with-temp-text test-line - (org-test-ignore-duplicate - (should-error (org-ctrl-c-ctrl-c))) + (should-error (org-ctrl-c-ctrl-c)) (forward-char) (org-babel-execute-maybe) - (org-test-ignore-duplicate - (should (string= - (concat test-line " {{{results(=1=)}}}") - (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + (should (string= + (concat test-line " {{{results(=1=)}}}") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) (re-search-forward "{ 1 ") (org-babel-execute-maybe) (should (string= (concat test-line " {{{results(=1=)}}}") @@ -430,11 +426,9 @@ (ert-deftest test-ob/inline-src_blk-default-results-replace-line-2 () (org-babel-inline-result-wrap "=%s=")) (org-test-with-temp-text (concat "\n" test-line) - (org-test-ignore-duplicate - (should-error (org-ctrl-c-ctrl-c))) + (should-error (org-ctrl-c-ctrl-c)) (goto-char (point-min)) - (org-test-ignore-duplicate - (should-error (org-ctrl-c-ctrl-c))) + (should-error (org-ctrl-c-ctrl-c)) (forward-line) (should-error (org-ctrl-c-ctrl-c)) (forward-char) (org-babel-execute-maybe) @@ -449,10 +443,9 @@ (ert-deftest test-ob/inline-src_blk-default-results-replace-line-2 () (goto-char (point-max)) (insert (concat "\n" test-line " end")) (re-search-backward "src") (org-babel-execute-maybe) - (org-test-ignore-duplicate - (should (string= - (concat test-line " {{{results(=y=)}}} end") - (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + (should (string= + (concat test-line " {{{results(=y=)}}} end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) (re-search-forward "\" ") (org-babel-execute-maybe) (should (string= (concat test-line " {{{results(=y=)}}} end") @@ -465,8 +458,7 @@ (ert-deftest test-ob/inline-src_blk-manual-results-replace () (org-babel-inline-result-wrap "=%s=")) (org-test-with-temp-text (concat "\n" test-line) - (org-test-ignore-duplicate - (should-error (org-ctrl-c-ctrl-c))) + (should-error (org-ctrl-c-ctrl-c)) (goto-char (point-max)) (org-babel-execute-maybe) (beginning-of-line) @@ -483,13 +475,12 @@ (ert-deftest test-ob/inline-src_blk-manual-results-replace () (goto-char (point-max)) (insert (concat "\n" test-line " end")) (re-search-backward "src") (org-babel-execute-maybe) - (org-test-ignore-duplicate - (should (string= - (concat test-line " {{{results(=y=)}}} end") - (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + (should (string= + (concat test-line " {{{results(=y=)}}} end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) (re-search-forward "\" ") (org-babel-execute-maybe) (should (string= - (concat test-line " {{{results(=y=)}}} end") + (concat test-line " {{{results(=y=)}}} end") (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) (forward-char 3) (should-error (org-ctrl-c-ctrl-c))))) @@ -508,10 +499,9 @@ (ert-deftest test-ob/inline-src_blk-results-silent () (goto-char (point-max)) (insert (concat "\n" test-line " end")) (re-search-backward "src_") (org-babel-execute-maybe) - (org-test-ignore-duplicate - (should (string= (concat test-line " end") - (buffer-substring-no-properties - (point-at-bol) (point-at-eol))))) + (should (string= (concat test-line " end") + (buffer-substring-no-properties + (point-at-bol) (point-at-eol)))) (re-search-forward "\" ") (org-babel-execute-maybe) (should (string= (concat test-line " end") (buffer-substring-no-properties @@ -654,8 +644,7 @@ (ert-deftest test-ob/just-one-results-block () (org-test-with-temp-text "#+begin_src sh :results output\necho Hello\n#+end_src\n" (org-babel-execute-src-block) (org-babel-execute-src-block) ; second code block execution - (org-test-ignore-duplicate - (should (search-forward "Hello"))) ; the string inside the source code block + (should (search-forward "Hello")) ; the string inside the source code block (should (search-forward "Hello")) ; the same string in the results block (should-error (search-forward "Hello")))) @@ -1170,10 +1159,9 @@ (ert-deftest test-ob/remove-inline-result () (point-at-bol) (point-at-eol)))) ;; Delete whitespace and result. (org-babel-remove-inline-result) - (org-test-ignore-duplicate - (should (string= inline-sb-dot - (buffer-substring-no-properties - (point-at-bol) (point-at-eol))))) + (should (string= inline-sb-dot + (buffer-substring-no-properties + (point-at-bol) (point-at-eol)))) ;; Add whitespace and result before dot. (search-forward inline-sb) (insert " " inline-res) @@ -2478,32 +2466,31 @@ (1+ 1) #+RESULTS: abc : 2 " - (org-test-ignore-duplicate - ;; non-existent name - (should-not - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nno-name\n")) - ;; correct name - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nabc\n") - (should (= 14 (point))) - ;; call line - autocompletion - (forward-line 3) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - ;; noweb reference - autocompletion - (forward-line 5) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - ;; at symbol - autocompletion - (forward-line 7) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - ;; in results - autocompletion - (forward-line 8) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - (forward-line 9) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point)))))) + ;; non-existent name + (should-not + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nno-name\n")) + ;; correct name + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nabc\n") + (should (= 14 (point))) + ;; call line - autocompletion + (forward-line 3) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + ;; noweb reference - autocompletion + (forward-line 5) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + ;; at symbol - autocompletion + (forward-line 7) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + ;; in results - autocompletion + (forward-line 8) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + (forward-line 9) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))))) (ert-deftest test-ob/evaluate-body-with-coderefs () (should diff --git a/testing/lisp/test-ol.el b/testing/lisp/test-ol.el index 6a44e5bdc..e0cec0854 100644 --- a/testing/lisp/test-ol.el +++ b/testing/lisp/test-ol.el @@ -60,24 +60,23 @@ (ert-deftest test-org-link/toggle-link-display () (dolist (org-link-descriptive '(nil t)) (org-test-with-temp-text "* Org link test [[https://example.com][A link to a site]]" - (org-test-ignore-duplicate - (dotimes (_ 2) - (goto-char 1) - (re-search-forward "\\[") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "example") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "com") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "]") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "\\[") - (should-not (org-invisible-p)) - (re-search-forward "link") - (should-not (org-invisible-p)) - (re-search-forward "]") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (org-toggle-link-display)))))) + (dotimes (_ 2) + (goto-char 1) + (re-search-forward "\\[") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "example") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "com") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "]") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "\\[") + (should-not (org-invisible-p)) + (re-search-forward "link") + (should-not (org-invisible-p)) + (re-search-forward "]") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (org-toggle-link-display))))) \f ;;; Escape and Unescape Links diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el index ce7ae3c63..976d88a9e 100644 --- a/testing/lisp/test-org-agenda.el +++ b/testing/lisp/test-org-agenda.el @@ -346,8 +346,7 @@ (ert-deftest test-org-agenda/property-timestamp () ;; `org-today' or not. (org-agenda-list nil "<2022-03-22 Tue>") (set-buffer org-agenda-buffer-name) - (org-test-ignore-duplicate - (should (= 3 (count-lines (point-min) (point-max))))) + (should (= 3 (count-lines (point-min) (point-max)))) ;; NOTE: Be aware that `org-agenda-list' may or may not display ;; past scheduled items depending whether the date is today ;; `org-today' or not. @@ -444,16 +443,14 @@ (ert-deftest test-org-agenda/sticky-agenda-filter-preset () (set-buffer "*Org Agenda(f)*") (org-agenda-redo) (goto-char (point-min)) - (org-test-ignore-duplicate - (should (not (invisible-p (1- (search-forward "TODO Foo")))))) + (should (not (invisible-p (1- (search-forward "TODO Foo"))))) (org-test-agenda--kill-all-agendas) (org-agenda nil "f1") (org-agenda nil "b1") (set-buffer "*Org Agenda(f1:+CATEGORY=\"foo\")*") (org-agenda-redo) (goto-char (point-min)) - (org-test-ignore-duplicate - (should (not (invisible-p (1- (search-forward "TODO Foo")))))) + (should (not (invisible-p (1- (search-forward "TODO Foo"))))) (org-test-agenda--kill-all-agendas) (org-agenda nil "f2") (org-agenda nil "b2") diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 6e0e5c5ec..ca7d77e28 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -5203,12 +5203,11 @@ (ert-deftest test-org-element/cache-headline () (org-element-at-point)) (insert ":CATEOGORY: cat\n") (search-backward "* Heading") - (org-test-ignore-duplicate - (should - (eq (org-element-property :end (org-element-at-point)) - (save-excursion - (search-forward "* Heading 2") - (line-beginning-position))))) + (should + (eq (org-element-property :end (org-element-at-point)) + (save-excursion + (search-forward "* Heading 2") + (line-beginning-position)))) (search-forward "* Heading 2") (beginning-of-line) (insert "\n\n") @@ -5248,10 +5247,9 @@ (ert-deftest test-org-element/cache-headline () (org-element-at-point (point-max)) (insert "* heading 2") (beginning-of-line) - (org-test-ignore-duplicate - (should - (eq (point-max) - (org-element-property :end (org-element-at-point))))) + (should + (eq (point-max) + (org-element-property :end (org-element-at-point)))) (delete-char 1) (search-backward "* Heading") (should diff --git a/testing/lisp/test-org-fold.el b/testing/lisp/test-org-fold.el index 7fd4b015c..9f15f0a38 100644 --- a/testing/lisp/test-org-fold.el +++ b/testing/lisp/test-org-fold.el @@ -329,21 +329,20 @@ (ert-deftest test-org-fold/set-visibility-according-to-property () ** AC * B " - (org-test-ignore-duplicate - (org-set-regexps-and-options) - (org-cycle-set-startup-visibility) - (search-forward "A") - (should-not (invisible-p (point))) - (search-forward "AB") - (should (invisible-p (point))) - (search-forward "ABA") - (should (invisible-p (point))) - (search-forward "ABAB") - (should (invisible-p (point))) - (search-forward "AC") - (should (invisible-p (point))) - (search-forward "B") - (should-not (invisible-p (point))))) + (org-set-regexps-and-options) + (org-cycle-set-startup-visibility) + (search-forward "A") + (should-not (invisible-p (point))) + (search-forward "AB") + (should (invisible-p (point))) + (search-forward "ABA") + (should (invisible-p (point))) + (search-forward "ABAB") + (should (invisible-p (point))) + (search-forward "AC") + (should (invisible-p (point))) + (search-forward "B") + (should-not (invisible-p (point)))) ;; "children" state. (should (org-test-with-temp-text diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index 89c42b400..0ee3a14c2 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -61,14 +61,11 @@ (ert-deftest test-org-list/list-navigation () ;; a list/sub-list, unless `org-list-use-circular-motion' ;; is non-nil. (goto-line 9) - (org-test-ignore-duplicate - (should-error (org-next-item))) - (org-test-ignore-duplicate - (let ((org-list-use-circular-motion t)) - (should (progn (org-next-item) t)))) + (should-error (org-next-item)) + (let ((org-list-use-circular-motion t)) + (should (progn (org-next-item) t))) (goto-line 14) - (org-test-ignore-duplicate - (should-error (org-next-item))) + (should-error (org-next-item)) (let ((org-list-use-circular-motion t)) (should (progn (org-next-item) t))) ;; 1.2. Should jump over sub-lists. @@ -94,14 +91,11 @@ (ert-deftest test-org-list/list-navigation () ;; a list/sub-list, unless `org-list-use-circular-motion is ;; non-nil. (goto-line 7) - (org-test-ignore-duplicate - (should-error (org-previous-item))) - (org-test-ignore-duplicate - (let ((org-list-use-circular-motion t)) - (should (progn (org-previous-item) t)))) + (should-error (org-previous-item)) + (let ((org-list-use-circular-motion t)) + (should (progn (org-previous-item) t))) (goto-line 13) - (org-test-ignore-duplicate - (should-error (org-previous-item))) + (should-error (org-previous-item)) (let ((org-list-use-circular-motion t)) (should (progn (org-previous-item) t))) ;; 2.2. Should ignore sub-lists. @@ -711,8 +705,7 @@ (ert-deftest test-org-list/move-item-down () (search-backward "- item 1") (org-move-item-down) (search-forward "sub-body 1") - (org-test-ignore-duplicate - (should (org-invisible-p2))) + (should (org-invisible-p2)) (search-backward "sub-body 2") (should (org-invisible-p2)))) @@ -791,8 +784,7 @@ (ert-deftest test-org-list/move-item-up () (org-cycle)) (org-move-item-up) (forward-line) - (org-test-ignore-duplicate - (should (org-invisible-p2))) + (should (org-invisible-p2)) (search-forward " body 1") (should (org-invisible-p2))) ;; Preserve children visibility. @@ -811,8 +803,7 @@ (ert-deftest test-org-list/move-item-up () (search-backward "- item 2") (org-move-item-up) (search-forward "sub-body 2") - (org-test-ignore-duplicate - (should (org-invisible-p2))) + (should (org-invisible-p2)) (search-forward "sub-body 1") (should (org-invisible-p2)))) diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el index c079cc464..ebf8d8569 100644 --- a/testing/lisp/test-org-src.el +++ b/testing/lisp/test-org-src.el @@ -54,8 +54,7 @@ (ert-deftest test-org-src/point-outside-block () #+end_src " (goto-line 1) - (org-test-ignore-duplicate - (should-error (org-edit-special))) + (should-error (org-edit-special)) (goto-char (point-max)) (should-error (org-edit-special)))) diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 8eda95f3e..68b8efaea 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1120,8 +1120,7 @@ (ert-deftest test-org-table/org-at-TBLFM-p () " (goto-char (point-min)) (forward-line 2) - (org-test-ignore-duplicate - (should (equal (org-at-TBLFM-p) nil))) + (should (equal (org-at-TBLFM-p) nil)) (goto-char (point-min)) (forward-line 3) @@ -1140,8 +1139,7 @@ (ert-deftest test-org-table/org-table-TBLFM-begin () " (goto-char (point-min)) - (org-test-ignore-duplicate - (should (equal (org-table-TBLFM-begin) nil))) + (should (equal (org-table-TBLFM-begin) nil)) (goto-char (point-min)) (forward-line 1) @@ -1149,8 +1147,7 @@ (ert-deftest test-org-table/org-table-TBLFM-begin () (goto-char (point-min)) (forward-line 3) - (org-test-ignore-duplicate - (should (= (org-table-TBLFM-begin) 14))) + (should (= (org-table-TBLFM-begin) 14)) (goto-char (point-min)) (forward-line 4) @@ -1166,25 +1163,24 @@ (ert-deftest test-org-table/org-table-TBLFM-begin-for-multiple-TBLFM-lines () #+TBLFM: $2=$1*2 " - (org-test-ignore-duplicate - (goto-char (point-min)) - (should (equal (org-table-TBLFM-begin) nil)) + (goto-char (point-min)) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 1) - (should (equal (org-table-TBLFM-begin) nil)) + (goto-char (point-min)) + (forward-line 1) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 3) - (should (= (org-table-TBLFM-begin) 14)) + (goto-char (point-min)) + (forward-line 3) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 4) - (should (= (org-table-TBLFM-begin) 14)) + (goto-char (point-min)) + (forward-line 4) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 5) - (should (= (org-table-TBLFM-begin) 14))))) + (goto-char (point-min)) + (forward-line 5) + (should (= (org-table-TBLFM-begin) 14)))) (ert-deftest test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-blocks () (org-test-with-temp-text-in-file @@ -1200,44 +1196,43 @@ (ert-deftest test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-block #+TBLFM: $2=$1*2 " - (org-test-ignore-duplicate - (goto-char (point-min)) - (should (equal (org-table-TBLFM-begin) nil)) + (goto-char (point-min)) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 1) - (should (equal (org-table-TBLFM-begin) nil)) + (goto-char (point-min)) + (forward-line 1) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 3) - (should (= (org-table-TBLFM-begin) 14)) + (goto-char (point-min)) + (forward-line 3) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 4) - (should (= (org-table-TBLFM-begin) 14)) + (goto-char (point-min)) + (forward-line 4) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 5) - (should (= (org-table-TBLFM-begin) 14)) + (goto-char (point-min)) + (forward-line 5) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 6) - (should (= (org-table-TBLFM-begin) 14)) + (goto-char (point-min)) + (forward-line 6) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 8) - (should (= (org-table-TBLFM-begin) 61)) + (goto-char (point-min)) + (forward-line 8) + (should (= (org-table-TBLFM-begin) 61)) - (goto-char (point-min)) - (forward-line 9) - (should (= (org-table-TBLFM-begin) 61)) + (goto-char (point-min)) + (forward-line 9) + (should (= (org-table-TBLFM-begin) 61)) - (goto-char (point-min)) - (forward-line 10) - (should (= (org-table-TBLFM-begin) 61))))) + (goto-char (point-min)) + (forward-line 10) + (should (= (org-table-TBLFM-begin) 61)))) (ert-deftest test-org-table/org-table-calc-current-TBLFM () - (org-test-with-temp-text-in-file + (org-test-with-temp-text-in-file " | 1 | | | 2 | | diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index d379ee3bf..38f31cc91 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2488,8 +2488,7 @@ (ert-deftest test-org/goto-sibling () (should (org-goto-sibling)) (should (looking-at-p "^\\*\\* Heading 3")) (should-not (org-goto-sibling)) - (org-test-ignore-duplicate - (should (org-goto-sibling 'previous))) + (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 2")) (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 1")) @@ -2532,8 +2531,7 @@ (ert-deftest test-org/goto-sibling () (should (org-goto-sibling)) (should (looking-at-p "^\\*\\* Heading 3")) (should-not (org-goto-sibling)) - (org-test-ignore-duplicate - (should (org-goto-sibling 'previous))) + (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 2")) (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 1")) @@ -4018,8 +4016,7 @@ (ert-deftest test-org/org-ctrl-c-ctrl-c () * Heading<point> text" (org-overview) - (org-test-ignore-duplicate - (should (org-fold-folded-p (point) 'outline))) + (should (org-fold-folded-p (point) 'outline)) (save-excursion (goto-char (point-min)) (org-ctrl-c-ctrl-c)) @@ -5119,8 +5116,7 @@ (ert-deftest test-org/forward-element () ;; same level. (goto-line 3) (org-forward-element) - (org-test-ignore-duplicate - (should (looking-at (regexp-quote "** Head 1.2")))) + (should (looking-at (regexp-quote "** Head 1.2"))) ;; 3.2. At an headline beginning: move to parent headline if no ;; headline at the same level. (goto-line 3) @@ -5131,8 +5127,7 @@ (ert-deftest test-org/forward-element () "#+BEGIN_CENTER\nInside.\n#+END_CENTER\n\nOutside." ;; 4.1. At a greater element: expected to skip contents. (org-forward-element) - (org-test-ignore-duplicate - (should (looking-at (regexp-quote "Outside.")))) + (should (looking-at (regexp-quote "Outside."))) ;; 4.2. At the end of greater element contents: expected to skip ;; to the end of the greater element. (goto-line 2) @@ -5171,8 +5166,7 @@ (ert-deftest test-org/forward-element () ;; 5.3 At sub-list beginning: expected to move after the sub-list. (goto-line 4) (org-forward-element) - (org-test-ignore-duplicate - (should (looking-at (regexp-quote " Inner paragraph.")))) + (should (looking-at (regexp-quote " Inner paragraph."))) ;; 5.4. At sub-list end: expected to move outside the sub-list. (goto-line 8) (org-forward-element) @@ -5259,8 +5253,7 @@ (ert-deftest test-org/backward-element () (should (looking-at " - sub2")) (goto-line 12) (org-backward-element) - (org-test-ignore-duplicate - (should (looking-at "- item1"))) + (should (looking-at "- item1")) ;; 7.3. At end of list/sub-list: expected to move to list/sub-list ;; beginning. (goto-line 10) @@ -5268,8 +5261,7 @@ (ert-deftest test-org/backward-element () (should (looking-at " - sub1")) (goto-line 15) (org-backward-element) - (org-test-ignore-duplicate - (should (looking-at "- item1"))) + (should (looking-at "- item1")) ;; 7.4. At blank-lines before list end: expected to move to top ;; item. (goto-line 14) @@ -5316,8 +5308,7 @@ (ert-deftest test-org/up-element () ;; 4.2. At an item in a sub-list: move to parent item. (goto-line 4) (org-up-element) - (org-test-ignore-duplicate - (should (looking-at "- item1"))) + (should (looking-at "- item1")) ;; 4.3. At an item in top list: move to beginning of whole list. (goto-line 10) (org-up-element) -- 2.43.0 [-- Attachment #3: Type: text/plain, Size: 224 bytes --] -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2024-01-26 13:24 ` Ihor Radchenko @ 2024-01-27 5:04 ` Ilya Chernyshov 2024-01-31 12:17 ` Ihor Radchenko 0 siblings, 1 reply; 17+ messages in thread From: Ilya Chernyshov @ 2024-01-27 5:04 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 332 bytes --] Ihor Radchenko <yantar92@posteo.net> writes: > What about the attached amendment? > It should simplify things significantly. Sorry, in my previous patch the test that checks the detector itself was not even run in 'make test' because of incorrect test prefix. Your patch does not work as you expect. Could you please revise it? [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-test-duplicates-detector.el-Add-correct-prefix-to-th.patch --] [-- Type: text/x-patch, Size: 2405 bytes --] From 6eb03414ac4eb8b64160b24dc7fcb805bf782310 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko <yantar92@posteo.net> Date: Fri, 26 Jan 2024 14:21:55 +0100 Subject: [PATCH] test-duplicates-detector.el: Add correct prefix to the deftest, check if consp * testing/lisp/test-duplicates-detector.el (test-duplicates-detector--search-forms-recursively): * testing/lisp/test-duplicates-detector.el (test-org-tests/test-duplicates-detector-testing-find-duplicates): Add correct prefix so that the test could be executed --- testing/lisp/test-duplicates-detector.el | 25 ++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el index d6f8aca5a..aed8034ee 100644 --- a/testing/lisp/test-duplicates-detector.el +++ b/testing/lisp/test-duplicates-detector.el @@ -231,22 +231,23 @@ FORM-PATH is list of the form: Write each form to `test-duplicates-detector-forms'" (let ((idx 0)) (dolist (sub-form form) - (unless (memq (car-safe sub-form) test-duplicates-progn-forms) - (push idx (alist-get - sub-form - (alist-get form-path test-duplicates-detector-forms - nil nil #'equal) - nil nil #'equal-including-properties))) - (unless (memq (car-safe sub-form) - '(should-not should should-error)) - (test-duplicates-detector--search-forms-recursively - sub-form - (append form-path (list (cons (car sub-form) idx))))) + (when (consp sub-form) + (unless (memq (car-safe sub-form) test-duplicates-progn-forms) + (push idx (alist-get + sub-form + (alist-get form-path test-duplicates-detector-forms + nil nil #'equal) + nil nil #'equal-including-properties))) + (unless (memq (car-safe sub-form) + '(should-not should should-error)) + (test-duplicates-detector--search-forms-recursively + sub-form + (append form-path (list (cons (car-safe sub-form) idx)))))) (cl-incf idx)))) ;;;; Testing the detector itself -(ert-deftest test-duplicates-detector-testing-find-duplicates () +(ert-deftest test-org-tests/test-duplicates-detector-testing-find-duplicates () "Test `test-duplicates-detector--find-duplicates'." (should (equal -- 2.41.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2024-01-27 5:04 ` Ilya Chernyshov @ 2024-01-31 12:17 ` Ihor Radchenko 2024-02-09 12:22 ` Ilya Chernyshov 0 siblings, 1 reply; 17+ messages in thread From: Ihor Radchenko @ 2024-01-31 12:17 UTC (permalink / raw) To: Ilya Chernyshov; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 854 bytes --] Ilya Chernyshov <ichernyshovvv@gmail.com> writes: > Ihor Radchenko <yantar92@posteo.net> writes: > >> What about the attached amendment? >> It should simplify things significantly. > > Sorry, in my previous patch the test that checks the detector itself was not > even run in 'make test' because of incorrect test prefix. > > Your patch does not work as you expect. Could you please revise it? Sure. I erroneously checked car of sub-form when testing whether to ignore testing duplicates in children. See the attached series of patches to be applied on top the previous 3. Note that your `test-org-tests/test-duplicates-detector-testing-find-duplicates' does not look right. I had to adjust the `equal' condition in order to make it pass. May you please check if the return value of `test-duplicates-detector--find-duplicates' is what you intended? [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-testing-lisp-test-duplicates-detector.el-Fix-recursi.patch --] [-- Type: text/x-patch, Size: 1788 bytes --] From 316c36d2b388a81e43fabf392a75af85532f56ba Mon Sep 17 00:00:00 2001 Message-ID: <316c36d2b388a81e43fabf392a75af85532f56ba.1706703212.git.yantar92@posteo.net> From: Ihor Radchenko <yantar92@posteo.net> Date: Wed, 31 Jan 2024 13:11:31 +0100 Subject: [PATCH 1/3] testing/lisp/test-duplicates-detector.el: Fix recursion, add more ignored forms * testing/lisp/test-duplicates-detector.el (test-duplicates-detector--search-forms-recursively): Do not test for duplicates according to parent form, not current form. * testing/lisp/test-duplicates-detector.el (test-duplicates-progn-forms): Add more progn-like forms. --- testing/lisp/test-duplicates-detector.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el index aed8034ee..b23fbce1e 100644 --- a/testing/lisp/test-duplicates-detector.el +++ b/testing/lisp/test-duplicates-detector.el @@ -42,9 +42,10 @@ (require 'org-test "../testing/org-test") ;;;; Variables (defvar test-duplicates-progn-forms - '( progn + '( progn prog1 let dolist dotimes org-test-with-temp-text org-test-with-temp-text-in-file + org-test-at-id org-test-ignore-duplicate) "List of forms equivalent to `progn'. Immediate children inside these are not checked for duplicates.") @@ -232,7 +233,7 @@ (defun test-duplicates-detector--search-forms-recursively (form form-path) (let ((idx 0)) (dolist (sub-form form) (when (consp sub-form) - (unless (memq (car-safe sub-form) test-duplicates-progn-forms) + (unless (memq (car-safe form) test-duplicates-progn-forms) (push idx (alist-get sub-form (alist-get form-path test-duplicates-detector-forms -- 2.43.0 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-ob-haskell-session-named-none-means-one-shot-session.patch --] [-- Type: text/x-patch, Size: 1456 bytes --] From 77ec5f6e3834253a3ba872140f32b148b1135887 Mon Sep 17 00:00:00 2001 Message-ID: <77ec5f6e3834253a3ba872140f32b148b1135887.1706703212.git.yantar92@posteo.net> In-Reply-To: <316c36d2b388a81e43fabf392a75af85532f56ba.1706703212.git.yantar92@posteo.net> References: <316c36d2b388a81e43fabf392a75af85532f56ba.1706703212.git.yantar92@posteo.net> From: Ihor Radchenko <yantar92@posteo.net> Date: Wed, 31 Jan 2024 13:12:49 +0100 Subject: [PATCH 2/3] ob-haskell/session-named-none-means-one-shot-sessions: Remove duplicate * testing/lisp/test-ob-haskell-ghci.el (ob-haskell/session-named-none-means-one-shot-sessions): Remove duplicate from the test. --- testing/lisp/test-ob-haskell-ghci.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/testing/lisp/test-ob-haskell-ghci.el b/testing/lisp/test-ob-haskell-ghci.el index cbd5f6f9a..990addcd4 100644 --- a/testing/lisp/test-ob-haskell-ghci.el +++ b/testing/lisp/test-ob-haskell-ghci.el @@ -117,8 +117,6 @@ (ert-deftest ob-haskell/sessions-must-not-share-variables () (ert-deftest ob-haskell/session-named-none-means-one-shot-sessions () "When no session, use a new session. \"none\" is a special name that means `no session'." - (test-ob-haskell-ghci ":session none" "x=2" nil) - (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil))) (test-ob-haskell-ghci ":session none" "x=2" nil) (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil)))) -- 2.43.0 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 0003-test-org-tests-test-duplicates-detector-testing-find.patch --] [-- Type: text/x-patch, Size: 1991 bytes --] From 1f1c576cf5934e1c590faa7b0cad488aa8ffb9eb Mon Sep 17 00:00:00 2001 Message-ID: <1f1c576cf5934e1c590faa7b0cad488aa8ffb9eb.1706703212.git.yantar92@posteo.net> In-Reply-To: <316c36d2b388a81e43fabf392a75af85532f56ba.1706703212.git.yantar92@posteo.net> References: <316c36d2b388a81e43fabf392a75af85532f56ba.1706703212.git.yantar92@posteo.net> From: Ihor Radchenko <yantar92@posteo.net> Date: Wed, 31 Jan 2024 13:13:11 +0100 Subject: [PATCH 3/3] test-org-tests/test-duplicates-detector-testing-find-duplicates: Fix test * testing/lisp/test-duplicates-detector.el (test-org-tests/test-duplicates-detector-testing-find-duplicates): Fix test condition. --- testing/lisp/test-duplicates-detector.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el index b23fbce1e..25293f185 100644 --- a/testing/lisp/test-duplicates-detector.el +++ b/testing/lisp/test-duplicates-detector.el @@ -254,13 +254,13 @@ (ert-deftest test-org-tests/test-duplicates-detector-testing-find-duplicates () (equal (test-duplicates-detector--find-duplicates (list test-duplicates-detector-file-path)) - `((((,test-duplicates-detector-file-path - test-org-tests/test-with-nested-duplicates) - ((let ((var "string")) (should (message "123 %s" var))) 6 4)) - ((,test-duplicates-detector-file-path - test-org-tests/test-with-duplicates-at-root) - ((should (message "123")) 6 4))) - ((test-org-tests/duplicate-test-2 . test-org-tests/duplicate-test-1)))))) + `(((,test-duplicates-detector-file-path + test-org-tests/test-with-nested-duplicates) + ((let ((var "string")) (should (message "123 %s" var))) 6 4)) + ((,test-duplicates-detector-file-path + test-org-tests/test-with-duplicates-at-root) + ((should (message "123")) 6 4)) + (test-org-tests/duplicate-test-2 . test-org-tests/duplicate-test-1))))) ;;;;; Tests with duplicate forms -- 2.43.0 [-- Attachment #5: Type: text/plain, Size: 224 bytes --] -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2024-01-31 12:17 ` Ihor Radchenko @ 2024-02-09 12:22 ` Ilya Chernyshov 2024-02-09 14:11 ` Ihor Radchenko 0 siblings, 1 reply; 17+ messages in thread From: Ilya Chernyshov @ 2024-02-09 12:22 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 442 bytes --] Ihor Radchenko <yantar92@posteo.net> writes: > Note that your > `test-org-tests/test-duplicates-detector-testing-find-duplicates' does > not look right. I had to adjust the `equal' condition in order to make > it pass. May you please check if the return value of > `test-duplicates-detector--find-duplicates' is what you intended? Yeah, now it works as it should. Thanks. I've made some minor changes I've described in the attached patch. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-test-duplicates-detector.el-Simplify-the-docs-refact.patch --] [-- Type: text/x-patch, Size: 4970 bytes --] From 8bcd02bac32d3a4442814c2a42b097d642964372 Mon Sep 17 00:00:00 2001 From: Ilya Chernyshov <ichernyshovvv@gmail.com> Date: Fri, 9 Feb 2024 17:32:58 +0600 Subject: [PATCH] test-duplicates-detector.el: Simplify the docs, refactor, optimize the search * test-duplicates-detector.el (test-duplicates-detector-duplicate-forms): Simplify the docstring. Add that the list also may have information about duplicate ert test definitions. * test-duplicates-detector.el (test-duplicates-detector--find-duplicates): Don't go through a duplicate ert test definition. * test-duplicates-detector.el (test-duplicates-detector--search-forms-recursively): Replace (car-safe sub-form) with (car sub-form) because we already checked that sub-form is a cons. --- testing/lisp/test-duplicates-detector.el | 51 ++++++++++-------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el index 25293f185..58da27c07 100644 --- a/testing/lisp/test-duplicates-detector.el +++ b/testing/lisp/test-duplicates-detector.el @@ -61,24 +61,19 @@ Immediate children inside these are not checked for duplicates.") (expand-file-name "lisp" org-test-dir) t "\\.el$"))) (defvar test-duplicates-detector-duplicate-forms nil - "A nested list of the form: + "A list where each element is either: - (((file test-name [(form-1 . numerical-order) - (form-2 . numerical-order) ...]) - (dup-form-1 . (numerical-order [numerical-order ...])) - [ (dup-form-2 . (numerical-order [numerical-order ...])) - (dup-form-3 . (numerical-order [numerical-order ...])) - ...]) - - ((file test-name [(form-1 . numerical-order) - (form-2 . numerical-order) ...]) + ((file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) (dup-form-1 . (numerical-order [numerical-order ...])) [ (dup-form-2 . (numerical-order [numerical-order ...])) (dup-form-3 . (numerical-order [numerical-order ...])) ...]) - ... - ) +or + + (test-1-symbol . duplicate-of-test-1-symbol) + Where @@ -88,31 +83,29 @@ Where is a path to duplicates. For example, the path for the duplicates in the following test: - test-ob-haskell-ghci.el + test-file.el - (ertdeftest ob-haskell/session-named-none-means-one-shot-sessions () - \"When no session, use a new session. - \"none\" is a special name that means `no session'.\" + (ertdeftest test-name () + \"Docstring.\" (let ((var-1 \"value\")) (when var-1 (should-not - (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) - (test-ob-haskell-ghci \":session none\" \"x=2\") + (equal 2 (some-func \"string\" \"x\" nil))) + (some-func \"string\" \"x=2\") (should-not - (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) - (test-ob-haskell-ghci \":session none\" \"x=2\")))) + (equal 2 (some-func \"string\" \"x\" nil))) + (some-func \"string\" \"x=2\")))) would look like this: - (\"test-ob-haskell-ghci.el\" - ob-haskell/session-named-none-means-one-shot-sessions + (\"/absolute/path/to/test-file.el\" + test-name (let . 4) (when . 2)) And the records about the duplicates would look like this: - ((test-ob-haskell-ghci \":session none\" \"x=2\") 5 3) ((should-not - (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) 4 2)") + (equal 2 (some-func \"string\" \"x\" nil))) 4 2)") (defvar test-duplicates-detector-forms nil "Nested alist of found forms and paths to them (not filtered).") @@ -168,9 +161,9 @@ Duplicate forms will be written to (cdddr x)))) found-deftests))) (push (cons test-name (cadr f)) duplicate-tests) - (push deftest found-deftests)) - (test-duplicates-detector--search-forms-recursively - deftest (list file (cadr deftest))))))))) + (push deftest found-deftests) + (test-duplicates-detector--search-forms-recursively + deftest (list file test-name))))))))) (setq test-duplicates-detector-duplicate-forms (seq-filter #'cdr @@ -239,11 +232,11 @@ Write each form to `test-duplicates-detector-forms'" (alist-get form-path test-duplicates-detector-forms nil nil #'equal) nil nil #'equal-including-properties))) - (unless (memq (car-safe sub-form) + (unless (memq (car sub-form) '(should-not should should-error)) (test-duplicates-detector--search-forms-recursively sub-form - (append form-path (list (cons (car-safe sub-form) idx)))))) + (append form-path (list (cons (car sub-form) idx)))))) (cl-incf idx)))) ;;;; Testing the detector itself -- 2.41.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2024-02-09 12:22 ` Ilya Chernyshov @ 2024-02-09 14:11 ` Ihor Radchenko 0 siblings, 0 replies; 17+ messages in thread From: Ihor Radchenko @ 2024-02-09 14:11 UTC (permalink / raw) To: Ilya Chernyshov; +Cc: emacs-orgmode Ilya Chernyshov <ichernyshovvv@gmail.com> writes: > Yeah, now it works as it should. Thanks. I've made some minor changes > I've described in the attached patch. Thanks! I squashed all the patches modifying the new test library into a single commit and changed the duplicate in test-org/file-contents to achieve its intended goal as stated in the commentary. Applied, onto main. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=8d2fcfea9 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e3f327d1e https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=8e2ed45bb -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-07-12 19:22 [PATCH] testing: Delete duplicate tests Ilya Chernyshov 2023-07-13 9:51 ` Ihor Radchenko @ 2023-07-14 11:50 ` Max Nikulin 2023-07-15 7:56 ` Ihor Radchenko 1 sibling, 1 reply; 17+ messages in thread From: Max Nikulin @ 2023-07-14 11:50 UTC (permalink / raw) To: Ilya Chernyshov, emacs-orgmode On 13/07/2023 02:22, Ilya Chernyshov wrote: > +++ b/testing/lisp/test-ol.el > @@ -301,14 +301,6 @@ Seehttps://github.com/yantar92/org/issues/4." > (let ((file (buffer-file-name))) > (equal (format "[[file:%s::two]]" file file) > (org-store-link nil)))))) > - (should > - (let ((org-stored-links nil) > - (org-context-in-file-links t)) > - (org-test-with-temp-text-in-file "# two" > - (fundamental-mode) > - (let ((file (buffer-file-name))) > - (equal (format "[[file:%s::two]]" file file) > - (org-store-link nil)))))) The test was added by 7a78eb1be 2020-03-26 22:57:16 +0100 Nicolas Goaziou: ol: Fix some corner cases when normalizing context in links The intention may be to test "#two" besides "# two". Maybe somebody has a better guess what case related to the change is not covered. The idea to find duplicated tests is bright. The code may be transformed in a dedicated unit test. I would not drop existing tests blindly though. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] testing: Delete duplicate tests 2023-07-14 11:50 ` Max Nikulin @ 2023-07-15 7:56 ` Ihor Radchenko 0 siblings, 0 replies; 17+ messages in thread From: Ihor Radchenko @ 2023-07-15 7:56 UTC (permalink / raw) To: Max Nikulin; +Cc: Ilya Chernyshov, emacs-orgmode Max Nikulin <manikulin@gmail.com> writes: > The idea to find duplicated tests is bright. The code may be transformed > in a dedicated unit test. I would not drop existing tests blindly though. Very good idea indeed. One gotcha is that not every should form is next level after ert-deftest. And there are also "should-not" and "should-error" forms. So, we may compare only forms at the same sexp depth for equality, without restricting to "should". -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2024-02-09 14:09 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-07-12 19:22 [PATCH] testing: Delete duplicate tests Ilya Chernyshov 2023-07-13 9:51 ` Ihor Radchenko 2023-08-08 12:44 ` Ihor Radchenko 2023-08-31 6:17 ` Ilya Chernyshov 2023-08-31 6:29 ` Ihor Radchenko 2023-11-08 9:59 ` Ihor Radchenko 2023-11-11 8:55 ` Ilya Chernyshov 2023-11-16 12:27 ` Ilya Chernyshov 2024-01-16 13:44 ` Ihor Radchenko 2024-01-23 12:03 ` Ilya Chernyshov 2024-01-26 13:24 ` Ihor Radchenko 2024-01-27 5:04 ` Ilya Chernyshov 2024-01-31 12:17 ` Ihor Radchenko 2024-02-09 12:22 ` Ilya Chernyshov 2024-02-09 14:11 ` Ihor Radchenko 2023-07-14 11:50 ` Max Nikulin 2023-07-15 7:56 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).