16
16
; ; three times `window-min-height' (which defaults to 4). The problem
17
17
; ; was relevant for Emacs 26.3, 27.1, and 27.2 running in batch mode
18
18
; ; in docker containers, because they set their frame height to 9 (and
19
- ; ; their width to 10). For this reason most Proof General CI tests
20
- ; ; disable three pane mode in one or the other way.
19
+ ; ; their width to 10) in such environments . For this reason most Proof
20
+ ; ; General CI tests disable three pane mode in one or the other way.
21
21
; ;
22
- ; ; This file tests the internal function `proof-select-three-b' that
23
- ; ; contains the bug and one user command affected by the bug
24
- ; ; (`proof-toggle-active-scripting' ) with three different frame sizes:
25
- ; ; too small for 3 windows, just big enough for 3 windows, and the
26
- ; ; default frame size.
22
+ ; ; This file tests that the internal function `proof-select-three-b'
23
+ ; ; creates 3 windows if the frame height is big enough. Additionally,
24
+ ; ; it is tested that one user command
25
+ ; ; (`proof-toggle-active-scripting' ) that used to be affected by the
26
+ ; ; bug does not signal an error, regardless of the frame size. Both
27
+ ; ; functions are tested with three different frame sizes: too small
28
+ ; ; for 3 windows, just big enough for 3 windows, and the default frame
29
+ ; ; size.
27
30
28
31
(require 'pg-response )
29
32
@@ -39,51 +42,64 @@ source file."
39
42
(message " Coq and Proof General reseted " )))
40
43
41
44
42
- (defun test-proof-select-three-b-for-height (height )
45
+ (defun test-proof-select-three-b-for-height (height expect-error )
43
46
" Test `proof-select-three-b' in 3-pane mode for HEIGHT.
44
- The function should not signal an error and set up 3 windows."
45
- (let ((b1 (get-buffer-create " test-b1" ))
46
- (b2 (get-buffer-create " test-b2" ))
47
- (b3 (get-buffer-create " test-b3" ))
48
- ; ; the following is set to its default value
49
- (proof-three-window-enable t ))
50
- (reset-coq)
51
- (message " Check test-proof-select-three-b for height %d " height)
52
- (set-frame-height (selected-frame ) height)
53
- (proof-select-three-b b1 b2 b3 'smart )
54
- (message " Apparently no error signaled in proof-select-three-b " )
55
- (message " Check that there are 3 windows " )
56
- (should (eq (length (window-list )) 3 ))))
47
+ EXPECT-ERROR must be non-nil precisely if the frame height is
48
+ expected to be too small for 3 windows. In this case nothing is
49
+ done here, because `proof-select-three-b' must not be called in
50
+ such situations. Otherwise the function should not signal an
51
+ error and set up 3 windows."
52
+ (if expect-error
53
+ (message " Skip test-proof-select-three-b for height %d " height)
54
+ (let ((b1 (get-buffer-create " test-b1" ))
55
+ (b2 (get-buffer-create " test-b2" ))
56
+ (b3 (get-buffer-create " test-b3" ))
57
+ ; ; the following is set to its default value
58
+ (proof-three-window-enable t ))
59
+ (reset-coq)
60
+ (message " Check test-proof-select-three-b for height %d " height)
61
+ (set-frame-height (selected-frame ) height)
62
+ (proof-select-three-b b1 b2 b3 'smart )
63
+ (message " Apparently no error signaled in proof-select-three-b " )
64
+ (message " Check that there are 3 windows " )
65
+ (should (eq (length (window-list )) 3 ))
66
+
67
+ ; ; clean up
68
+ (kill-buffer b1)
69
+ (kill-buffer b2)
70
+ (kill-buffer b3))))
71
+
57
72
58
73
(ert-deftest test-proof-select-three-b-too-small ()
59
74
" Test `proof-select-three-b' for a frame height too small for 3 windows."
60
- :expected-result :failed
61
- (test-proof-select-three-b-for-height (- (* 3 window-min-height) 1 )))
75
+ (test-proof-select-three-b-for-height (- (* 3 window-min-height) 1 ) t ))
62
76
63
77
(ert-deftest test-proof-select-three-b-just-big-enough ()
64
78
" Test `proof-select-three-b' for a frame height just big enough for 3 windows."
65
- (test-proof-select-three-b-for-height (* 3 window-min-height)))
79
+ (test-proof-select-three-b-for-height (* 3 window-min-height) nil ))
66
80
67
81
(ert-deftest test-proof-select-three-b-default-height ()
68
82
" Test `proof-select-three-b' for the default frame height.
69
83
Note that for Emacs 26.3, 27.1, and 27.2, the default frame
70
84
height is 9 when running in a docker container."
71
- :expected-result ( if ( and
72
- ; ; >= 26.3
73
- ( or ( > emacs-major-version 26 )
74
- ( and ( eq emacs-major-version 26 )
75
- ( >= emacs-minor -version 3 )) )
76
- ; ; < 28
77
- ( < emacs-major-version 28 ))
78
- :failed
79
- :passed )
80
- (test-proof-select-three-b-for-height ( frame-height )))
85
+ (test-proof-select-three-b-for-height
86
+ ( frame-height )
87
+ ( if ( and
88
+ ; ; >= 26.3
89
+ ( or ( > emacs-major -version 26 )
90
+ ( and ( eq emacs-major-version 26 ) ( >= emacs-minor-version 3 )))
91
+ ; ; < 28
92
+ ( < emacs-major-version 28 ))
93
+ t
94
+ nil )))
81
95
82
96
83
- (defun test-activate-scripting-for-height (height )
97
+ (defun test-activate-scripting-for-height (height num-win )
84
98
" Test `proof-toggle-active-scripting' in 3-pane mode for HEIGHT.
85
- The function should not signal an error and there should be 3
86
- windows afterwards."
99
+ The function should never signal an error and afterwards there
100
+ should be 3 windows if the frame has enough space and 2
101
+ otherwise. Argument NUM-WIN specifies the expected number of
102
+ windows for HEIGHT."
87
103
(let ((proof-three-window-enable t )
88
104
(proof-three-window-mode-policy 'smart ))
89
105
(reset-coq)
@@ -92,30 +108,29 @@ windows afterwards."
92
108
(find-file " some_file.v" )
93
109
(proof-toggle-active-scripting)
94
110
(message " Apparently no error signaled in proof-toggle-active-scripting " )
95
- (message " Check that there are 3 windows " )
96
- (should (eq (length (window-list )) 3 ))))
111
+ (message " Check that there are %d windows " num-win )
112
+ (should (eq (length (window-list )) num-win ))))
97
113
98
114
99
115
(ert-deftest test-proof-toggle-active-scripting-too-small ()
100
116
" Test `proof-toggle-active-scripting' in a frame too small for 3 windows."
101
- :expected-result :failed
102
- (test-activate-scripting-for-height (- (* 3 window-min-height) 1 )))
117
+ (test-activate-scripting-for-height (* 4 window-min-height) 2 ))
103
118
104
119
(ert-deftest test-proof-toggle-active-scripting-just-big-enough ()
105
120
" Test `proof-toggle-active-scripting' in a frame just enough for 3 windows."
106
- (test-activate-scripting-for-height (* 3 window-min-height)))
121
+ (test-activate-scripting-for-height (+ ( * 4 window-min-height) 1 ) 3 ))
107
122
108
123
(ert-deftest test-proof-toggle-active-scripting-default-height ()
109
124
" Test `proof-toggle-active-scripting' with the default frame size.
110
125
Note that for Emacs 26.3, 27.1, and 27.2, the default frame
111
126
height is 9 when running in a docker container."
112
- :expected-result ( if ( and
113
- ; ; >= 26.3
114
- ( or ( > emacs-major-version 26 )
115
- ( and ( eq emacs-major-version 26 )
116
- ( >= emacs-minor -version 3 )) )
117
- ; ; < 28
118
- ( < emacs-major-version 28 ))
119
- :failed
120
- :passed )
121
- (test-activate-scripting-for-height ( frame-height )))
127
+ (test-activate-scripting-for-height
128
+ ( frame-height )
129
+ ( if ( and
130
+ ; ; >= 26.3
131
+ ( or ( > emacs-major -version 26 )
132
+ ( and ( eq emacs-major-version 26 ) ( >= emacs-minor-version 3 )))
133
+ ; ; < 28
134
+ ( < emacs-major-version 28 ))
135
+ 2
136
+ 3 )))
0 commit comments