Skip to content

Commit 4e75d37

Browse files
committed
CI: extend goals present tests with Search and Check commdands
- After Search and Check the goals should be up-to-date and the response should be visible, also in two-pane mode. - Extend existing tests to check that the response is also visible in two-pane mode, if applicable. - Use Proof General variables containing the buffer instead of buffer names.
1 parent 9861316 commit 4e75d37

File tree

1 file changed

+119
-28
lines changed

1 file changed

+119
-28
lines changed

ci/simple-tests/coq-test-goals-present.el

Lines changed: 119 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,26 @@ Proof.
117117
"Coq source code for checking that goals are updated even in case of error.")
118118

119119

120+
(defconst coq-src-update-goal-after-search
121+
"
122+
Lemma g : 1 + 1 = 2.
123+
Proof using.
124+
simpl.
125+
Search (0 + _).
126+
"
127+
"Coq source code for checking that goals are up-to-date after Search.")
128+
129+
130+
(defconst coq-src-update-goal-after-check
131+
"
132+
Lemma h : 1 + 2 = 3.
133+
Proof using.
134+
simpl.
135+
Check plus_O_n.
136+
"
137+
"Coq source code for checking that goals are up-to-date after Check.")
138+
139+
120140
;;; utility functions
121141

122142
(defun record-buffer-content (buf)
@@ -146,7 +166,8 @@ BUF should be a string."
146166
Process COQ-SRC in a new buffer in one step and check that the
147167
goals buffer is not empty afterwards. If CHECK-RESPONSE-NONEMPTY
148168
is non-nil, additionally check that the response buffer is
149-
non-empty, i.e., shows some error message."
169+
non-empty, i.e., shows some message, and is visible in some
170+
window also in two-pane mode."
150171
(message "goals-after-test: Check goals are present after %s." msg)
151172
(setq proof-three-window-enable nil)
152173
(let (buffer)
@@ -161,16 +182,20 @@ non-empty, i.e., shows some error message."
161182
;; (record-buffer-content "*goals*")
162183

163184
;; check that there is a goal in the goals buffer
164-
(with-current-buffer "*goals*"
185+
(with-current-buffer proof-goals-buffer
165186
(goto-char (point-min))
166187
(should (looking-at "1 \\(sub\\)?goal (ID")))
167188

168189
(when check-response-nonempty
169190
(message
170191
"goals-after-test: Check response buffer is nonempty after %s."
171192
msg)
172-
(with-current-buffer "*response*"
173-
(should (not (equal (point-min) (point-max)))))))
193+
(with-current-buffer proof-response-buffer
194+
(should (not (equal (point-min) (point-max)))))
195+
(message
196+
"goals-after-test: Check response buffer is visible after %s."
197+
msg)
198+
(should (get-buffer-window proof-response-buffer))))
174199

175200
;; clean up
176201
(when buffer
@@ -190,7 +215,7 @@ the goals buffer is expected to be empty."
190215
;; (record-buffer-content "*goals*")
191216

192217
;; check that the goals buffer is empty
193-
(with-current-buffer "*goals*"
218+
(with-current-buffer proof-goals-buffer
194219
(should (equal (point-min) (point-max)))))
195220

196221
(defun goals-buffer-should-get-reset (coq-src coq-stm msg)
@@ -221,7 +246,7 @@ which action the goals buffer should have been reset."
221246
(proof-goto-point)
222247
(wait-for-coq)
223248
;; there should be something in the goals buffer now
224-
(with-current-buffer "*goals*"
249+
(with-current-buffer proof-goals-buffer
225250
(should (not (equal (point-min) (point-max)))))
226251

227252
(goals-buffer-should-be-empty (point-max) msg))
@@ -272,50 +297,116 @@ which action the goals buffer should have been reset."
272297
(goals-buffer-should-get-reset coq-src-qed
273298
"Proof using" "Qed"))
274299

275-
(ert-deftest update-goals-after-error ()
276-
"Test goals are updated after an error."
277-
:expected-result :failed
278-
(message "update-goals-after-error: Check goals are updated after error")
300+
(defun update-goals-when-response (coq-src first-pos goal-2nd msg)
301+
"Test goals are up-to-date after an error or a command that produces response.
302+
Process COQ-SRC up to the line after the first match of regular
303+
expression FIRST-POS. At this point the goals buffer should not
304+
be empty. Process now COQ-SRC up to the end. If GOAL-2ND is a
305+
regular expression as a string, then check that the goals have
306+
been updated to contain a match for GOAL-2ND. If GOAL-2ND is no
307+
string, only check that the goals buffer is non-empty. In any
308+
case, check that the response buffer is not empty and visible in
309+
two-pane mode."
310+
311+
(message "update-goals-when-response: Check goals are updated after %s" msg)
279312
(setq proof-three-window-enable nil)
280313
(let (buffer)
281314
(unwind-protect
282315
(progn
283316
(find-file "goals.v")
284317
(setq buffer (current-buffer))
285-
(insert coq-src-update-goal-after-error)
318+
(insert coq-src)
286319
(goto-char (point-min))
287-
(should (re-search-forward "point A" nil t))
288-
(beginning-of-line)
320+
(should (re-search-forward first-pos nil t))
321+
(forward-line 1)
289322
(proof-goto-point)
290323
(wait-for-coq)
291324
;; (record-buffer-content "*coq*")
292325
;; (record-buffer-content "*goals*")
293326

294-
;; the complete goal should be present
295-
(message "Check that the complete goal is present in *goals*")
296-
(with-current-buffer "*goals*"
297-
(goto-char (point-min))
298-
(should (re-search-forward "(eq_one 1 -> False) -> False" nil t)))
327+
;; goals should be present
328+
(message "Check that goals are present")
329+
(with-current-buffer proof-goals-buffer
330+
(should (not (equal (point-min) (point-max)))))
299331

300-
(should (re-search-forward "point B" nil t))
301-
(beginning-of-line)
332+
(goto-char (point-max))
302333
(proof-goto-point)
303334
(wait-for-coq)
304335
;; (record-buffer-content "*coq*")
305336
;; (record-buffer-content "*goals*")
306337

307-
;; the hypothesis H should be present
308-
(message "Check that the goals buffer has been updated")
309-
(with-current-buffer "*goals*"
338+
(with-current-buffer proof-goals-buffer
310339
(goto-char (point-min))
311-
(should (re-search-forward "H : eq_one 1 -> False" nil t)))
340+
(if (stringp goal-2nd)
341+
(progn
342+
(message "Check that goals have been updated")
343+
(should (re-search-forward goal-2nd nil t)))
344+
(message "Check that goals are still present")
345+
(should (not (equal (point-min) (point-max))))))
346+
347+
;; something should be in the response buffer
348+
(message "Check that there is some response present")
349+
(with-current-buffer proof-response-buffer
350+
(should (not (equal (point-min) (point-max)))))
312351

313-
;; some error should be in the response buffer
314-
(message "Check that there is some error message present")
315-
(with-current-buffer "*response*"
316-
(should (not (equal (point-min) (point-max))))))
352+
(message "Check that the response is visible in two-pane mode")
353+
(should (get-buffer-window proof-response-buffer)))
317354

318355
(when buffer
319356
(with-current-buffer buffer
320357
(set-buffer-modified-p nil))
321358
(kill-buffer buffer)))))
359+
360+
(ert-deftest goals-up-to-date-at-error ()
361+
"Check that goals are updated before showing the error."
362+
:expected-result :failed
363+
(update-goals-when-response coq-src-update-goal-after-error
364+
"Lemma foo"
365+
"H : eq_one 1 -> False"
366+
"error"))
367+
368+
(ert-deftest goals-up-to-date-after-search-one-step ()
369+
"Check that goals are still present before showing result of one search cmd.
370+
This test checks a single Search command inside a proof. After
371+
processing that Search command alone, the goals buffer should not
372+
be empty and the response buffer should contain something and be
373+
visible in two-pane mode."
374+
(update-goals-when-response coq-src-update-goal-after-search
375+
"simpl"
376+
t
377+
"Search"))
378+
379+
(ert-deftest goals-updated-after-search-many-steps ()
380+
"Check that goals are updated before showing result of search cmd.
381+
This test checks several commands inside a proof with a final
382+
Search command. After processing these commands, the goals buffer
383+
should have been updated and the response buffer should contain
384+
something and be visible in two-pane mode."
385+
:expected-result :failed
386+
(update-goals-when-response coq-src-update-goal-after-search
387+
"Lemma g"
388+
"2 = 2"
389+
"Search"))
390+
391+
(ert-deftest goals-up-to-date-after-check-one-step ()
392+
"Check that goals are still present before showing result of one check cmd.
393+
This test checks a single Check command inside a proof. After
394+
processing that Check command alone, the goals buffer should not
395+
be empty and the response buffer should contain something and be
396+
visible in two-pane mode."
397+
(update-goals-when-response coq-src-update-goal-after-check
398+
"simpl"
399+
t
400+
"Check"))
401+
402+
(ert-deftest goals-updated-after-check-many-steps ()
403+
"Check that goals are updated before showing result of check cmd.
404+
This test checks several commands inside a proof with a final
405+
Check command. After processing these commands, the goals buffer
406+
should have been updated and the response buffer should contain
407+
something and be visible in two-pane mode."
408+
:expected-result :failed
409+
(update-goals-when-response coq-src-update-goal-after-check
410+
"Lemma h"
411+
"3 = 3"
412+
"Check"))

0 commit comments

Comments
 (0)