@@ -603,14 +603,20 @@ last use time, to discourage saving these into the users database."
603
603
; ; Check validity of proofs
604
604
; ;
605
605
606
- (defun proof-check-report (proof-results )
606
+ (defun proof-check-report (proof-results tap batch )
607
607
" Report `proof-check-proofs' results in PROOF-RESULTS in special buffer.
608
608
Report the results of `proof-check-proofs' in buffer
609
- `proof-check-report-buffer' in human readable form."
609
+ `proof-check-report-buffer' in human readable form or, if TAP is
610
+ not nil, in test anything protocol (TAP). If BATCH is not nil,
611
+ report the results via message, such that they appear on stdout
612
+ when Emacs runs in batch mode or, when BATCH is a string, append
613
+ the results to the file denoted by BATCH."
610
614
(let* ((ok-fail (seq-group-by #'car proof-results))
611
615
(frmt " %-4s %s" )
612
616
(frmt-face (propertize frmt 'face 'error ))
617
+ (count 1 )
613
618
coq-proj-dir src-file)
619
+
614
620
; ; determine a relative file name for current buffer
615
621
(when buffer-file-name
616
622
(setq coq-proj-dir (locate-dominating-file buffer-file-name
@@ -622,25 +628,43 @@ Report the results of `proof-check-proofs' in buffer
622
628
; ; generate header
623
629
(with-current-buffer (get-buffer-create proof-check-report-buffer)
624
630
(erase-buffer )
625
- (insert
626
- (propertize (concat " Proof check results for " src-file) 'face 'bold )
627
- " \n\n " )
628
- (insert
629
- (format
630
- (propertize " %d opaque proofs recognized: %d successful " 'face 'bold )
631
- (length proof-results)
632
- (length (cdr (assoc t ok-fail)))))
633
- (insert (format (propertize " %d FAILING" 'face 'error 'face 'bold )
634
- (length (cdr (assoc nil ok-fail)))))
635
- (insert " \n\n " )
636
- ; ; generate actual proof results
631
+ (if tap
632
+ (insert (format " TAP version 14\n 1..%d \n " (length proof-results)))
633
+ ; ; human output
634
+ (insert
635
+ (propertize (concat " Proof check results for " src-file) 'face 'bold )
636
+ " \n\n " )
637
+ (insert
638
+ (format
639
+ (propertize " %d opaque proofs recognized: %d successful " 'face 'bold )
640
+ (length proof-results)
641
+ (length (cdr (assoc t ok-fail)))))
642
+ (insert (format (propertize " %d FAILING" 'face 'error 'face 'bold )
643
+ (length (cdr (assoc nil ok-fail)))))
644
+ (insert " \n\n " ))
637
645
(dolist (pr proof-results)
638
- (insert (format (if (car pr) frmt frmt-face)
639
- (if (car pr) " OK " " FAIL" )
640
- (cadr pr)))
641
- (insert " \n " ))
642
- (goto-char (point-min ))
643
- (display-buffer (current-buffer )))))
646
+ (if tap
647
+ (progn
648
+ (insert (format " %s ok %d - %s \n "
649
+ (if (car pr) " " " not " )
650
+ count
651
+ (cadr pr)))
652
+ (setq count (1+ count)))
653
+ ; ; human readable
654
+ (insert (format (if (car pr) frmt frmt-face)
655
+ (if (car pr) " OK " " FAIL" )
656
+ (cadr pr)))
657
+ (insert " \n " )))
658
+ (if batch
659
+ (progn
660
+ (insert " \n\n " )
661
+ (if (stringp batch)
662
+ (append-to-file (point-min ) (point-max ) batch)
663
+ (message " %s "
664
+ (buffer-substring-no-properties
665
+ (point-min ) (point-max )))))
666
+ (goto-char (point-min ))
667
+ (display-buffer (current-buffer ))))))
644
668
645
669
(defun proof-check-chunks (chunks )
646
670
" Worker function for `proof-check-proofs for processing CHUNKS.
@@ -727,28 +751,41 @@ as reported by `proof-get-proof-info-fn'."
727
751
(setq chunks (cdr chunks))))
728
752
(nreverse proof-results)))
729
753
730
- (defun proof-check-proofs ()
731
- " Generate overview about valid and invalid proofs in current buffer .
754
+ (defun proof-check-proofs (tap &optional batch )
755
+ " Generate an overview about valid and invalid proofs.
732
756
This command completely processes the current buffer and
733
- generates an overview in the `proof-check-report-buffer' about
734
- all the opaque proofs in it and whether their proof scripts are
735
- valid or invalid.
757
+ generates an overview about all the opaque proofs in it and
758
+ whether their proof scripts are valid or invalid.
736
759
737
760
This command makes sense for a development process where invalid
738
761
proofs are permitted and vos compilation and the omit proofs
739
762
feature (see `proof-omit-proofs-configured' ) are used to work at
740
763
the most interesting or challenging point instead of on the first
741
764
invalid proof.
742
765
766
+ Argument TAP, which can be set by a prefix argument, controls the
767
+ form of the generated overview. Nil, without prefix, gives an
768
+ human readable overview, otherwise it's test anything
769
+ protocol (TAP). Argument BATCH controls where the overview goes
770
+ to. If nil, or in an interactive call, the overview appears in
771
+ `proof-check-report-buffer' . If BATCH is a string, it should be a
772
+ filename and the overview is appended there. Otherwise the
773
+ overview is output via `message' such that it appears on stdout
774
+ when this command runs in batch mode.
775
+
743
776
In the same way as the omit-proofs feature, this command only
744
777
tolerates errors inside scripts of opaque proofs. Any other error
745
778
is reported to the user without generating an overview. The
746
779
overview only contains those names of theorems whose proofs
747
780
scripts are classified as opaque by the omit-proofs feature. For
748
781
Coq for instance, among others, proof scripts terminated with
749
782
'Defined' are not opaque and do not appear in the generated
750
- overview."
751
- (interactive )
783
+ overview.
784
+
785
+ Note that this command does not (re-)compile required files.
786
+ Files must be required before running this commands, for instance
787
+ by asserting all require commands beforehand."
788
+ (interactive " P" )
752
789
(unless (and proof-omit-proofs-configured
753
790
proof-get-proof-info-fn
754
791
proof-retract-command-fn)
@@ -773,7 +810,7 @@ overview."
773
810
nil " proof-check: first chunk cannot be a proof" )
774
811
(setq proof-results (proof-check-chunks chunks))
775
812
(proof-shell-exit t )
776
- (proof-check-report proof-results)))
813
+ (proof-check-report proof-results tap batch )))
777
814
778
815
779
816
0 commit comments