all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#72574: [PATCH 0/3] debbugs improvements.  Add tests
@ 2024-08-11 12:15 Morgan Smith
  2024-08-11 12:18 ` bug#72574: [PATCH 1/3] * debbugs-gnu.el (debbugs-gnu-find-contributor): Make regex more specific Morgan Smith
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Morgan Smith @ 2024-08-11 12:15 UTC (permalink / raw)
  To: 72574; +Cc: Morgan Smith, Michael Albinus

Hello!

I would like to start contributing some improvements to debbugs.  However, when
changing things I found it difficult to avoid regressions.  So I figured I'd
try to add a test suite to debbugs first.

The first two patches are not that interesting.  I was hoping to get feedback
on the "Add tests" patch.  Obviously more tests are needed but I would like to
know if I'm on the right path.

Thanks,

Morgan

Morgan Smith (3):
  * debbugs-gnu.el (debbugs-gnu-find-contributor): Make regex more
    specific
  Fix various warnings
  Add tests

 Makefile             |   4 ++
 debbugs-browse.el    |   3 +-
 debbugs-compat.el    |   3 ++
 debbugs-gnu.el       |  24 +++++-----
 debbugs-org.el       |   7 +--
 debbugs.el           |  12 ++---
 test/test-debbugs.el | 101 +++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 133 insertions(+), 21 deletions(-)
 create mode 100644 Makefile
 create mode 100644 test/test-debbugs.el

-- 
2.45.2






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#72574: [PATCH 1/3] * debbugs-gnu.el (debbugs-gnu-find-contributor): Make regex more specific
  2024-08-11 12:15 bug#72574: [PATCH 0/3] debbugs improvements. Add tests Morgan Smith
@ 2024-08-11 12:18 ` Morgan Smith
  2024-08-11 13:54   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-08-11 12:38 ` bug#72574: [PATCH 0/3] debbugs improvements. Add tests Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-08-11 22:05 ` bug#72574: [PATCH v2] " Morgan Smith
  2 siblings, 1 reply; 6+ messages in thread
From: Morgan Smith @ 2024-08-11 12:18 UTC (permalink / raw)
  To: 72574; +Cc: Morgan Smith, Michael Albinus

---
 debbugs-gnu.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index 3f5a9aebc8..6b6dd4992b 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -2702,7 +2702,7 @@ If SELECTIVELY, query the user before applying the patch."
   (let ((found 0)
 	(match (concat "^[0-9].*" string)))
     (dolist (file (directory-files-recursively
-		   debbugs-gnu-current-directory "ChangeLog\\(.[0-9]+\\)?$"))
+		   debbugs-gnu-current-directory "ChangeLog\\(\\.[0-9]+\\)?\\'"))
       (with-temp-buffer
 	(when (file-exists-p file)
 	  (insert-file-contents file))
-- 
2.45.2






^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#72574: [PATCH 0/3] debbugs improvements.  Add tests
  2024-08-11 12:15 bug#72574: [PATCH 0/3] debbugs improvements. Add tests Morgan Smith
  2024-08-11 12:18 ` bug#72574: [PATCH 1/3] * debbugs-gnu.el (debbugs-gnu-find-contributor): Make regex more specific Morgan Smith
@ 2024-08-11 12:38 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-08-11 22:05 ` bug#72574: [PATCH v2] " Morgan Smith
  2 siblings, 0 replies; 6+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-08-11 12:38 UTC (permalink / raw)
  To: Morgan Smith; +Cc: 72574

Morgan Smith <Morgan.J.Smith@outlook.com> writes:

> Hello!

Hi Morgan,

Great to see you, again!

> I would like to start contributing some improvements to debbugs.  However, when
> changing things I found it difficult to avoid regressions.  So I figured I'd
> try to add a test suite to debbugs first.
>
> The first two patches are not that interesting.

I've scanned them rougly, and they seem to be OK. Will commit them later
today, with a more precise reading.

> I was hoping to get feedback on the "Add tests" patch.  Obviously more
> tests are needed but I would like to know if I'm on the right path.

It looks like the right path, yes. Will comment this patch.

> Thanks,
>
> Morgan

Best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#72574: [PATCH 1/3] * debbugs-gnu.el (debbugs-gnu-find-contributor): Make regex more specific
  2024-08-11 12:18 ` bug#72574: [PATCH 1/3] * debbugs-gnu.el (debbugs-gnu-find-contributor): Make regex more specific Morgan Smith
@ 2024-08-11 13:54   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-08-11 13:54 UTC (permalink / raw)
  To: Morgan Smith; +Cc: 72574

Morgan Smith <Morgan.J.Smith@outlook.com> writes:

> ---
>  debbugs-gnu.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

pushed.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#72574: [PATCH v2] Add tests
  2024-08-11 12:15 bug#72574: [PATCH 0/3] debbugs improvements. Add tests Morgan Smith
  2024-08-11 12:18 ` bug#72574: [PATCH 1/3] * debbugs-gnu.el (debbugs-gnu-find-contributor): Make regex more specific Morgan Smith
  2024-08-11 12:38 ` bug#72574: [PATCH 0/3] debbugs improvements. Add tests Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-08-11 22:05 ` Morgan Smith
  2024-08-12  9:57   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2 siblings, 1 reply; 6+ messages in thread
From: Morgan Smith @ 2024-08-11 22:05 UTC (permalink / raw)
  To: 72574; +Cc: Morgan Smith, Michael Albinus

* Makefile: New file.
* test/test-debbugs.el: New file.
---

I made all the changes you requested.

I hope you like it!

 Makefile             |  20 +++++++
 test/test-debbugs.el | 132 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 152 insertions(+)
 create mode 100644 Makefile
 create mode 100644 test/test-debbugs.el

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..86cc575a2b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,20 @@
+EMACS ?= emacs
+
+SOURCE=$(wildcard *.el)
+TESTSOURCE=$(wildcard test/*.el)
+TARGET=$(patsubst %.el,%.elc,$(SOURCE))
+TESTTARGET=$(patsubst %.el,%.elc,$(TESTSOURCE))
+
+.PHONY: check clean
+.PRECIOUS: %.elc
+
+%.elc: %.el
+	@$(EMACS) -Q -batch -L . -f batch-byte-compile $<
+
+build: $(TARGET)
+
+check: build $(TESTTARGET)
+	emacs -Q --batch -L . -l $(TESTSOURCE) -f ert-run-tests-batch-and-exit
+
+clean:
+	-rm -f $(TARGET) $(TESTTARGET)
diff --git a/test/test-debbugs.el b/test/test-debbugs.el
new file mode 100644
index 0000000000..e22aadc14d
--- /dev/null
+++ b/test/test-debbugs.el
@@ -0,0 +1,132 @@
+;;; debbugs-tests.el --- tests for debbugs.el -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Free Software Foundation, Inc.
+
+;; Author: Morgan Smith <Morgan.J.Smith@outlook.com>
+;; Package: debbugs
+
+;; 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 GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Please ensure tests don't actually make network calls.
+
+;;; Code:
+
+(require 'debbugs)
+
+;;; Helper Data:
+
+;; Generated using this:
+;; (soap-invoke debbugs-wsdl debbugs-port "get_status" [64064])
+(defconst debbugs-test--bug-status-soap-return
+  '(((item
+      (key . 64064)
+      (value
+       (package . "emacs") (found_date) (last_modified . 1689593050)
+       (affects) (date . 1686745022) (fixed_versions)
+       (originator . "Morgan Smith <Morgan.J.Smith@outlook.com>")
+       (blocks) (archived . 1) (found) (unarchived) (tags . "patch")
+       (severity . "normal") (location . "archive") (owner) (fixed)
+       (blockedby) (pending . "done") (keywords . "patch") (id . 64064)
+       (found_versions) (mergedwith) (summary) (forwarded)
+       (log_modified . 1689593050)
+       (done . "Michael Albinus <michael.albinus@gmx.de>")
+       (source . "unknown")
+       (msgid
+        . "<DM5PR03MB31632E3A4FE170C62E7D4B0CC55AA@DM5PR03MB3163.namprd03.prod.outlook.com>")
+       (bug_num . 64064) (subject . "[PATCH 0/4] debbugs improvements")
+       (fixed_date))))))
+
+;; Generated using this:
+;; (debbugs-get-status 64064)
+(defconst debbugs-test--bug-status
+  '(((cache_time . 5000) (source . "unknown") (unarchived)
+     (keywords "patch") (blocks) (pending . "done") (severity . "normal")
+     (done . "Michael Albinus <michael.albinus@gmx.de>") (location . "archive")
+     (log_modified . 1689593050) (subject . "[PATCH 0/4] debbugs improvements")
+     (last_modified . 1689593050) (found) (tags "patch") (package "emacs")
+     (originator . "Morgan Smith <Morgan.J.Smith@outlook.com>") (archived . t)
+     (blockedby) (affects) (mergedwith) (summary) (date . 1686745022)
+     (fixed_versions) (id . 64064) (fixed) (found_date) (forwarded)
+     (msgid
+      . "<DM5PR03MB31632E3A4FE170C62E7D4B0CC55AA@DM5PR03MB3163.namprd03.prod.outlook.com>")
+     (owner) (found_versions) (fixed_date) (bug_num . 64064))))
+
+;;; Helper Functions:
+
+(defvar debbugs-test--soap-operation-name nil)
+(defvar debbugs-test--soap-parameters nil)
+(defun debbugs-test--soap-invoke-internal (callback _cbargs _wsdl _service
+                                                    operation-name
+                                                    &rest parameters)
+  "Over-ride for testing"
+  (setq debbugs-test--soap-operation-name operation-name)
+  (setq debbugs-test--soap-parameters parameters)
+  (let ((return
+         (cond ((string-equal operation-name "get_status")
+                debbugs-test--bug-status-soap-return)
+               ((string-equal operation-name "get_usertag")
+                '(((hi))))
+               (t '((0))))))
+    (if callback
+        (progn
+          (funcall callback return)
+          nil)
+      return)))
+
+(add-function
+ :override (symbol-function #'soap-invoke-internal)
+ #'debbugs-test--soap-invoke-internal)
+
+;;; Tests:
+
+(ert-deftest debbugs-test-get-bugs ()
+  (let (debbugs-test--soap-operation-name debbugs-test--soap-parameters)
+    (debbugs-get-bugs
+     :tag "patch"
+     :severity "critical"
+     :status "open"
+     :status "forwarded")
+    (should (string-equal debbugs-test--soap-operation-name "get_bugs"))
+    (should (equal debbugs-test--soap-parameters
+                   '(["tag" "patch" "severity" "critical"
+                      "status" "open" "status" "forwarded"])))))
+
+(ert-deftest debbugs-test-newest-bugs ()
+  (let (debbugs-test--soap-operation-name debbugs-test--soap-parameters)
+    (debbugs-newest-bugs 4)
+    (should (string-equal debbugs-test--soap-operation-name "newest_bugs"))
+    (should (equal debbugs-test--soap-parameters '(4)))))
+
+(ert-deftest debbugs-test-get-status ()
+  (let (debbugs-test--soap-operation-name debbugs-test--soap-parameters)
+    (cl-letf (((symbol-function #'float-time)
+               (lambda (&optional _specified-time) 5000)))
+      (should (= (float-time) 5000))
+      (should (equal (sort (car (debbugs-get-status 64064)))
+                     (sort (car debbugs-test--bug-status))))
+      (should (string-equal debbugs-test--soap-operation-name "get_status"))
+      (should (equal debbugs-test--soap-parameters '([64064]))))))
+
+(ert-deftest debbugs-test-get-usertag ()
+  (let (debbugs-test--soap-operation-name debbugs-test--soap-parameters)
+    (should (equal (debbugs-get-usertag :user "emacs") '("hi")))
+    (should (string-equal debbugs-test--soap-operation-name "get_usertag"))
+    (should (equal debbugs-test--soap-parameters '("emacs")))))
+
+(provide 'debbugs-tests)
+;;; debbugs-tests.el ends here
-- 
2.45.2






^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#72574: [PATCH v2] Add tests
  2024-08-11 22:05 ` bug#72574: [PATCH v2] " Morgan Smith
@ 2024-08-12  9:57   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-08-12  9:57 UTC (permalink / raw)
  To: Morgan Smith; +Cc: 72574-done

Morgan Smith <Morgan.J.Smith@outlook.com> writes:

Hi Morgan,

> * Makefile: New file.
> * test/test-debbugs.el: New file.
> ---
>
> I made all the changes you requested.
>
> I hope you like it!

Yes, thank you! I've pushed them to the ELPA repository. I made also some
small changes afterwards, nothing serious.

Closing the bug.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-12  9:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-11 12:15 bug#72574: [PATCH 0/3] debbugs improvements. Add tests Morgan Smith
2024-08-11 12:18 ` bug#72574: [PATCH 1/3] * debbugs-gnu.el (debbugs-gnu-find-contributor): Make regex more specific Morgan Smith
2024-08-11 13:54   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-11 12:38 ` bug#72574: [PATCH 0/3] debbugs improvements. Add tests Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-11 22:05 ` bug#72574: [PATCH v2] " Morgan Smith
2024-08-12  9:57   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.