diff --git a/ci/coq-tests.el b/ci/coq-tests.el
index 8040b1229..f06e13243 100644
--- a/ci/coq-tests.el
+++ b/ci/coq-tests.el
@@ -112,11 +112,9 @@
(defun coq-set-flags (val flags)
(when (member 'show-proof-stepwise flags) (setq coq-show-proof-stepwise val))
- (when (member 'diffs-on flags) (if val (setq coq-diffs 'on) (setq coq-diffs 'off)))
- )
+ (when (member 'diffs-on flags) (if val (setq coq-diffs 'on) (setq coq-diffs 'off))))
-
-(defun coq-fixture-on-file (file body &rest flags)
+(defun coq-fixture-on-file (file body &rest flags)
"Fixture to setup the test env: open FILE if non-nil, or a temp file
then evaluate the BODY function and finally tear-down (exit Coq)."
;; AVOID THE FOLLOWING ERROR:
@@ -167,24 +165,28 @@ For example, COMMENT could be (*test-definition*)"
(goto-char (point-min))
(search-forward comment))
-(defun coq-should-response (message)
- (should (equal message
+(defun coq-should-response (str)
+ (should (equal str
(string-trim
(with-current-buffer "*response*"
(buffer-substring-no-properties (point-min) (point-max)))))))
-(defun coq-should-buffer (message)
- (should (string-match-p message
+(defun coq-should-buffer-regexp (regexp)
+ (should (string-match-p regexp
(string-trim
(with-current-buffer "*coq*"
(buffer-substring-no-properties (point-min) (point-max)))))))
+(defun coq-should-buffer-string (str)
+ "Particular case of `coq-should-buffer-regexp'."
+ (coq-should-buffer-regexp (regexp-quote str)))
+
;; TODO: Use https://github.com/rejeep/ert-async.el
;; and/or ERT https://www.gnu.org/software/emacs/manual/html_node/ert/index.html
(ert-deftest 010_coq-test-running ()
"Test that the coqtop process is started properly."
- (coq-fixture-on-file nil
+ (coq-fixture-on-file nil
(lambda ()
(coq-test-cmd "Print 0.")
;; (should (process-list)) ; wouldn't be a strong enough assert.
@@ -193,8 +195,8 @@ For example, COMMENT could be (*test-definition*)"
(ert-deftest 020_coq-test-definition ()
"Test *response* output after asserting a Definition."
- (coq-fixture-on-file
- (coq-test-full-path "test_stepwise.v")
+ (coq-fixture-on-file
+ (coq-test-full-path "test_stepwise.v")
(lambda ()
(coq-test-goto-before "(*test-definition*)")
(proof-goto-point)
@@ -203,9 +205,9 @@ For example, COMMENT could be (*test-definition*)"
(ert-deftest 021_coq-test-regression-goto-point ()
- "Regression test for proof-goto-point after a comment, PR #90"
- (coq-fixture-on-file
- (coq-test-full-path "test_stepwise.v")
+ "Regression test for proof-goto-point after a comment, PR #490"
+ (coq-fixture-on-file
+ (coq-test-full-path "test_stepwise.v")
(lambda ()
(coq-test-goto-after "(*test-definition*)")
(proof-goto-point)
@@ -215,8 +217,8 @@ For example, COMMENT could be (*test-definition*)"
(ert-deftest 030_coq-test-position ()
"Test locked region after Qed."
- (coq-fixture-on-file
- (coq-test-full-path "test_stepwise.v")
+ (coq-fixture-on-file
+ (coq-test-full-path "test_stepwise.v")
(lambda ()
(coq-test-goto-before " (*test-lemma*)")
(let ((proof-point (point)))
@@ -227,8 +229,8 @@ For example, COMMENT could be (*test-definition*)"
(ert-deftest 040_coq-test-insert ()
"Test retract on insert from Qed."
- (coq-fixture-on-file
- (coq-test-full-path "test_stepwise.v")
+ (coq-fixture-on-file
+ (coq-test-full-path "test_stepwise.v")
(lambda ()
(coq-test-goto-before " (*test-lemma*)")
(proof-goto-point)
@@ -243,8 +245,8 @@ For example, COMMENT could be (*test-definition*)"
(ert-deftest 050_coq-test-lemma-false ()
"Test retract on proof error."
- (coq-fixture-on-file
- (coq-test-full-path "test_stepwise.v")
+ (coq-fixture-on-file
+ (coq-test-full-path "test_stepwise.v")
(lambda ()
(coq-test-goto-before " (*test-lemma2*)")
(let ((proof-point (save-excursion (coq-test-goto-after "(*error*)"))))
@@ -269,8 +271,8 @@ For example, COMMENT could be (*test-definition*)"
(ert-deftest 070_coq-test-regression-wholefile-no-proof ()
"Regression test for no proof bug"
- (coq-fixture-on-file
- (coq-test-full-path "test_wholefile.v")
+ (coq-fixture-on-file
+ (coq-test-full-path "test_wholefile.v")
(lambda ()
(proof-process-buffer)
(proof-shell-wait)
@@ -280,28 +282,28 @@ For example, COMMENT could be (*test-definition*)"
(ert-deftest 080_coq-test-regression-show-proof-stepwise()
"Regression test for the \"Show Proof\" option"
- (coq-fixture-on-file
- (coq-test-full-path "test_stepwise.v")
+ (coq-fixture-on-file
+ (coq-test-full-path "test_stepwise.v")
(lambda ()
(coq-test-goto-before " (*test-insert*)")
(proof-goto-point)
(proof-shell-wait)
- (coq-should-response "(fun (A : Prop) (proof_of_A : A) => ?Goal)"))
+ (coq-should-buffer-string "(fun (A : Prop) (proof_of_A : A) => ?Goal)"))
'show-proof-stepwise))
(ert-deftest 081_coq-test-regression-show-proof-diffs()
"Test for Show Proof Diffs"
- (coq-fixture-on-file
- (coq-test-full-path "test_stepwise.v")
+ (coq-fixture-on-file
+ (coq-test-full-path "test_stepwise.v")
(lambda ()
(coq-test-goto-before " (*test-insert*)")
(proof-goto-point)
(proof-shell-wait)
;; If coq--post-v811, it should be "Show Proof Diffs." otherwise "Show Proof."
(if (coq--post-v811)
- (coq-should-buffer "(fun (A : Prop) (proof_of_A : A) => \\?Goal)")
- (coq-should-buffer "(fun (A : Prop) (proof_of_A : A) => \\?Goal)")))
+ (coq-should-buffer-string "(fun (A : Prop) (proof_of_A : A) => ?Goal)")
+ (coq-should-buffer-string "(fun (A : Prop) (proof_of_A : A) => ?Goal)")))
'show-proof-stepwise 'diffs-on))
diff --git a/coq/coq.el b/coq/coq.el
index df7c5a668..efa603499 100644
--- a/coq/coq.el
+++ b/coq/coq.el
@@ -1237,13 +1237,6 @@ should match the `coq-show-proof-diffs-regexp'."
;; the number of nested goals, then Unset Silent and Show the goal
(and (string-match-p "BackTo\\s-" cmd)
(> (length coq-last-but-one-proofstack) coq--retract-naborts)))
- ;; "Set Diffs" always re-prints the proof context with (if enabled) diffs
- ;; (list "Unset Silent." (if (coq--post-v810) (coq-diffs) "Show.")
- ;; (when coq-show-proof-stepwise
- ;; (or
- ;; (when (eq coq-diffs 'off) "Show Proof.")
- ;; (when (eq coq-diffs 'on) "Show Proof Diffs.")
- ;; (when (eq coq-diffs 'removed) "Show Proof Diffs removed.")))))
(let ((showlist (list "Unset Silent." (if (coq--post-v810) (coq-diffs) "Show."))))
(when coq-show-proof-stepwise
(add-to-list 'showlist