emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/realgud 7c0d2c4 007/140: fixed unload; added ert-based


From: Rocky Bernstein
Subject: [elpa] externals/realgud 7c0d2c4 007/140: fixed unload; added ert-based tests for realgud
Date: Sat, 25 May 2019 19:35:20 -0400 (EDT)

branch: externals/realgud
commit 7c0d2c4c05e937c266fb78cec75fe9bfda1f144c
Author: Roy Mathew <address@hidden>
Commit: Roy Mathew <address@hidden>

    fixed unload; added ert-based tests for realgud
---
 realgud.el           | 40 ++++++++--------------------------------
 test/test-realgud.el | 49 ++++++++++++++++++++++++++-----------------------
 2 files changed, 34 insertions(+), 55 deletions(-)

diff --git a/realgud.el b/realgud.el
index dde1b50..e5c8a6d 100644
--- a/realgud.el
+++ b/realgud.el
@@ -113,42 +113,18 @@
   )
 
 (defun realgud:loaded-features()
-  "Return a list of loaded debugger features. These are the
-features that start with 'realgud-' and also include standalone debugger 
features
-like 'pydbgr'."
-  (let ((result nil)
-       (feature-str))
-    (dolist (feature features result)
-      (setq feature-str (symbol-name feature))
-      (cond ((eq 't
-                (string-prefix-p feature-str "realgud-"))
-            (setq result (cons feature-str result)))
-           ((eq 't
-                (string-prefix-p feature-str "nodejs"))
-            (setq result (cons feature-str result)))
-           ((eq 't
-                ;; No trailing '-' to get a plain "trepan".
-                (string-prefix-p feature-str "trepan"))
-            (setq result (cons feature-str result)))
-           ((eq 't
-                ;; No trailing '-' to get a plain "trepanx".
-                (string-prefix-p feature-str "trepanx"))
-            (setq result (cons feature-str result)))
-           ('t nil))
-       )
-      )
-)
+  "Return a list of loaded debugger features. These are the features
+that start with 'realgud-' and 'realgud:'"
+
+  (delq nil
+               (mapcar (lambda (x) (and (string-match-p 
"^\\(realgud:\\|realgud-\\)" (symbol-name x)) x))
+                               features)))
 
 (defun realgud:unload-features()
   "Remove all features loaded from this package. Used in
 `realgud:reload-features'. See that."
-  (interactive "")
-  (let ((result (realgud:loaded-features)))
-    (dolist (feature result result)
-      (unless (symbolp feature) (setq feature (make-symbol feature)))
-      (if (featurep feature)
-       (unload-feature feature) 't))
-  ))
+  (dolist (feature (realgud:loaded-features))
+       (unload-feature feature t)))
 
 (defun realgud:reload-features()
   "Reload all features loaded from this package. Useful if have
diff --git a/test/test-realgud.el b/test/test-realgud.el
index 2e7d09e..d5cf437 100644
--- a/test/test-realgud.el
+++ b/test/test-realgud.el
@@ -1,31 +1,34 @@
-;; Press C-x C-e at the end of the next line to run this file test 
non-interactively
-;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory 
(locate-library "test-simple.elc")) buffer-file-name)
+;; Manually run the test as follows:
+;; emacs --batch --no-site-file --no-splash --script setup.el --chdir 
PACAKGESDIR/realgud  -l test/test-realgud.el -f ert-run-tests-batch-and-exit
+;;
+;; where setup.el looks something like:
+;; (add-to-list 'load-path "$HOME/.emacs.d/elpa/test-simple-20170117.411")
+;; (add-to-list 'load-path "$HOME/.emacs.d/elpa/load-relative-20160716.438")
+;; (add-to-list 'load-path "$HOME/.emacs.d/elpa/loc-changes-20160801.1008")
 
-(require 'test-simple)
-(load-file "../realgud.el")
+(defun realgud-test-helper()
+  (delq nil
+               (mapcar (lambda (x) (and (string-match-p 
"^\\(realgud:\\|realgud-\\)" (symbol-name x)) x))
+                               features)))
 
-(declare-function realgud:loaded-features    'realgud)
-(declare-function realgud:unload-features    'realgud-regexp)
-(declare-function __FILE__                   'load-relative)
+(ert-deftest test-feature-unload()
 
-(test-simple-start)
+  ; no realgud features exist by default
+  (should (= 0 (length (realgud-test-helper))))
+  (should-not (member 'realgud-pdb features))
 
-(eval-when-compile
-  (defvar test-realgud:features)
-)
+  (load-file "realgud.el") ; manually load the first time
 
-(note "realgud")
+  ; we should now have realgud features;
+  (should-not (= 0 (length (realgud-test-helper))))
+  (should (member 'realgud-pdb features))
+  ; test at least 1 by name
+  (should (member 'realgud-pdb features))
 
-(note "realgud:loaded-features")
-(set (make-local-variable 'test-realgud:features) (realgud:loaded-features))
-;; (dolist (feature '(realgud-trepan
-;;                            realgud-core))
-;;   (assert-t (not (not (member feature test-realgud:features)))) )
+  (realgud:unload-features) ; unload all and test
+  (should (= 0 (length (realgud-test-helper))))
 
-(note "realgud-unload-features")
-(load-file "../realgud.el")
-(assert-nil (not (realgud:loaded-features)))
-(assert-nil (not (realgud:unload-features)))
-(realgud:loaded-features)
+  (realgud:load-features) ; load and test
+  (should-not (= 0 (length (realgud-test-helper))))
+  (should (member 'realgud-pdb features)))
 
-(end-tests)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]