emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ilya Chernyshov <ichernyshovvv@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] testing: Delete duplicate tests
Date: Fri, 09 Feb 2024 18:22:28 +0600	[thread overview]
Message-ID: <871q9laku3.fsf@gmail.com> (raw)
In-Reply-To: <87wmrpu27p.fsf@localhost>

[-- 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


  reply	other threads:[~2024-02-09 12:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2024-02-09 14:11                         ` Ihor Radchenko
2023-07-14 11:50 ` Max Nikulin
2023-07-15  7:56   ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871q9laku3.fsf@gmail.com \
    --to=ichernyshovvv@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).