Skip to content

Commit 1f7c3d7

Browse files
committed
CI: add proof-check tests
1 parent 06cea8d commit 1f7c3d7

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

ci/simple-tests/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ coq-test-prelude-correct
1515
coq-test-goals-present
1616
: test that Proof General shows goals correctly in various
1717
situations
18+
coq-test-proof-stat
19+
: test proof-check-proofs
1820

1921
# Overview of existing tests for qRHL
2022

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
;; This file is part of Proof General.
2+
;;
3+
;; © Copyright 2024 Hendrik Tews
4+
;;
5+
;; Authors: Hendrik Tews
6+
;; Maintainer: Hendrik Tews <hendrik@askra.de>
7+
;;
8+
;; SPDX-License-Identifier: GPL-3.0-or-later
9+
10+
;;; Commentary:
11+
;;
12+
;; Test proof-check-proofs.
13+
14+
;; For seq-group-by inside `proof-script-check-report'. This is
15+
;; apparently not automatically loaded in Emacs 26.3. Though in a real
16+
;; PG session it is apparently present.
17+
(require 'seq)
18+
19+
(defun reset-coq ()
20+
"Reset Coq and Proof General.
21+
Do `proof-shell-exit' to kill Coq and reset the locked region and
22+
a lot of other internal state of Proof General. Used at the
23+
beginning of the test when several tests work on the same Coq
24+
source file."
25+
(when (and (boundp 'proof-shell-buffer)
26+
(buffer-live-p proof-shell-buffer))
27+
(proof-shell-exit t)
28+
(message "Coq and Proof General reseted")))
29+
30+
31+
(ert-deftest proof-check-correct-stat ()
32+
"Test `proof-check-proofs' on a file that is correct in non-opaque parts.
33+
Test that the report buffer contains the expected output."
34+
(setq proof-three-window-enable nil)
35+
(reset-coq)
36+
(find-file "proof_stat.v")
37+
38+
;; run check on file where all errors are in opaque parts
39+
(proof-script-check-proofs)
40+
41+
;; the result buffer should exist
42+
(should (buffer-live-p (get-buffer "*proof-check-report*")))
43+
(with-current-buffer "*proof-check-report*"
44+
;; the summary should be correct
45+
(goto-char (point-min))
46+
(should
47+
(search-forward "3 opaque proofs recognized: 1 successful 2 FAILING"
48+
nil t))
49+
;; results for all 3 test lemmas should be correct
50+
(mapc
51+
(lambda (s) (should (search-forward s nil t)))
52+
'("FAIL a1_equal_4"
53+
"OK b_equal_6"
54+
"FAIL b2_equal_6"))))
55+
56+
57+
(ert-deftest proof-check-error-on-error ()
58+
"Test `proof-check-proofs' with errors in non-opaque parts.
59+
Check that `proof-check-proofs' signals an error with the expected message."
60+
(setq proof-three-window-enable nil)
61+
(reset-coq)
62+
(let (buffer)
63+
(unwind-protect
64+
(progn
65+
(find-file "proof_stat.v")
66+
(setq buffer (current-buffer))
67+
68+
;; insert an error in non-opaque part
69+
(goto-char (point-min))
70+
(should (search-forward "automatic test marker 1" nil t))
71+
(end-of-line)
72+
(insert " X ")
73+
74+
;; proof-script-check-proofs should abort now with an error
75+
(condition-case err-desc
76+
(progn
77+
(proof-script-check-proofs)
78+
;; Still here? Make test fail!
79+
(should nil))
80+
(error
81+
(should
82+
(equal (error-message-string err-desc)
83+
"Error encountered outside opaque proofs after line 10")))))
84+
85+
;; clean-up modified file in any case
86+
(when buffer
87+
(with-current-buffer buffer
88+
(set-buffer-modified-p nil))
89+
(kill-buffer buffer)))))

0 commit comments

Comments
 (0)