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

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

[nongnu] elpa/idris-mode 19aa3d7b02 3/6: Rewrite test idris-test-idris-t


From: ELPA Syncer
Subject: [nongnu] elpa/idris-mode 19aa3d7b02 3/6: Rewrite test idris-test-idris-type-at-point to use stubs
Date: Wed, 11 Jan 2023 10:03:39 -0500 (EST)

branch: elpa/idris-mode
commit 19aa3d7b02d8d3d5fbb254c2b1b51e0f3597a68e
Author: Marek L <nospam.keram@gmail.com>
Commit: Marek L <nospam.keram@gmail.com>

    Rewrite test idris-test-idris-type-at-point to use stubs
    
    instead of relying on running Idris connection.
    Why:
    The event processing nature of the tests makes
    it regularly fail on CI.
    It is great to have full integration tests but no at the price of
    reliability of test suite.
---
 test/idris-commands-test.el | 63 ++++++++++++++++++++++++++++-----------------
 1 file changed, 39 insertions(+), 24 deletions(-)

diff --git a/test/idris-commands-test.el b/test/idris-commands-test.el
index 179a7f16a5..98a430f0f6 100644
--- a/test/idris-commands-test.el
+++ b/test/idris-commands-test.el
@@ -243,30 +243,45 @@ myReverse xs = revAcc [] xs where
 
 (ert-deftest idris-test-idris-type-at-point ()
   "Test that `idris-type-at-point' works."
-  (let ((buffer (find-file-noselect "test-data/AddClause.idr")))
-    ;; Assert that we have clean global test state
-    (should (not idris-connection))
-    (with-current-buffer buffer
-      (switch-to-buffer buffer)
-      (goto-char (point-min))
-      (re-search-forward "data Test")
-      (funcall-interactively 'idris-type-at-point nil)
-      ;; Assert that Idris connection is created
-      (should idris-connection)
-      ;; Assert that focus is in the Idris info buffer
-      (should (string= (buffer-name) idris-info-buffer-name))
-      ;; Assert that the info buffer displays a type
-      (should (string-match-p "Test : Type" (buffer-substring-no-properties 
(point-min) (point-max))))
-
-      ;; TODO: How to emulate "q" key binding to quit info buffer?
-      (idris-info-quit)
-      ;; Assert leaving info buffer will get us back to Idris code buffer
-      (should (eq (current-buffer) buffer))
-
-      ;; Cleanup
-      (idris-delete-ibc t)
-      (kill-buffer))
-    (idris-quit)))
+  (let ((buffer (find-file-noselect "test-data/AddClause.idr"))
+        file-loaded-p
+        eval-args)
+    (cl-flet ((idris-load-file-sync-stub () (setq file-loaded-p t) nil)
+              (idris-eval-stub (&optional &rest args)
+                               (setq eval-args args)
+                               '("Test : Type"
+                                (0 4 ((:name "AddClause.Test")
+                                      (:implicit :False)
+                                      (:key "AQAAAAAAAAAA")
+                                      (:decor :type)
+                                      (:doc-overview "")
+                                      (:type "Type")
+                                      (:namespace "AddClause")))
+                                (7 4 ((:decor :type)
+                                      (:type "Type")
+                                      (:doc-overview "The type of types")
+                                      (:name "Type")))
+                                (7 4 ((:tt-term "AAAAAAAAAAAHAAAAAAA"))))))
+      (advice-add 'idris-load-file-sync :override #'idris-load-file-sync-stub)
+      (advice-add 'idris-eval :override #'idris-eval-stub)
+
+      (unwind-protect
+          (with-current-buffer buffer
+            (switch-to-buffer buffer)
+            (goto-char (point-min))
+            (re-search-forward "data Test")
+            (funcall-interactively 'idris-type-at-point nil)
+            (should (eq file-loaded-p t))
+            (should (equal eval-args '((:type-of "Test"))))
+            (should (string= (buffer-name) idris-info-buffer-name))
+            (should (string-match-p "Test : Type" 
(buffer-substring-no-properties (point-min) (point-max))))
+            (idris-info-quit)
+            (should (eq (current-buffer) buffer)))
+
+        (advice-remove 'idris-load-file-sync #'idris-load-file-sync-stub)
+        (advice-remove 'idris-eval #'idris-eval-stub)
+        (kill-buffer buffer)
+        (idris-quit)))))
 
 ;; Tests by Yasuhiko Watanabe
 ;; https://github.com/idris-hackers/idris-mode/pull/537/files



reply via email to

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