emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [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

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).