Skip to content

Commit b82ea40

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

File tree

2 files changed

+86
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)