|
74 | 74 |
|
75 | 75 | (etest-deftest ess-command-test () |
76 | 76 | "`ess-command' saves output in specified buffer." |
77 | | - :eval (let ((output-buffer (get-buffer-create " *ess-test-command-output*"))) |
78 | | - (ess-command "identity(TRUE)\n" output-buffer) |
79 | | - (should (string= (with-current-buffer output-buffer |
80 | | - (ess-kill-last-line) |
81 | | - (buffer-string)) |
82 | | - "[1] TRUE"))) |
| 77 | + (let ((output-buffer (get-buffer-create " *ess-test-command-output*"))) |
| 78 | + (ess-command "identity(TRUE)\n" output-buffer) |
| 79 | + (should (string= (with-current-buffer output-buffer |
| 80 | + (ess-kill-last-line) |
| 81 | + (buffer-string)) |
| 82 | + "[1] TRUE"))) |
83 | 83 | ;; No impact on inferior output |
84 | 84 | :inf-result "") |
85 | 85 |
|
|
117 | 117 |
|
118 | 118 | (etest-deftest ess-command-incomplete-test () |
119 | 119 | "`ess-command' fails with incomplete input." |
120 | | - :eval (should-error (ess-command "list(" nil nil nil nil nil nil 0.01)) |
| 120 | + (should-error (ess-command "list(" nil nil nil nil nil nil 0.01)) |
121 | 121 |
|
122 | 122 | ;; No impact on inferior output |
123 | 123 | :inf-result "" |
124 | 124 |
|
125 | 125 | ;; Process has been interrupted, is no longer busy, and we can run a |
126 | 126 | ;; command again |
127 | | - :eval ((should (inferior-ess-available-p)) |
128 | | - (should-error (ess-command "list(" nil nil nil nil nil nil 0.01))) |
| 127 | + (should (inferior-ess-available-p)) |
| 128 | + (should-error (ess-command "list(" nil nil nil nil nil nil 0.01)) |
129 | 129 | :inf-result "") |
130 | 130 |
|
131 | 131 | (etest-deftest ess-command-hanging-test () |
132 | 132 | "`ess-command' fails with hanging command." |
133 | | - :eval (should-error (ess-command "Sys.sleep(2)\n" nil nil nil nil nil nil 0.01)) |
| 133 | + (should-error (ess-command "Sys.sleep(2)\n" nil nil nil nil nil nil 0.01)) |
134 | 134 | :inf-result "" |
135 | | - :eval (should (inferior-ess-available-p))) |
| 135 | + (should (inferior-ess-available-p))) |
136 | 136 |
|
137 | 137 | (defun ess-test--browser () |
138 | 138 | (ess-send-string (ess-get-process) "{ browser(); NULL }\n") |
|
146 | 146 | (etest-deftest ess--command-browser-timeout-test () |
147 | 147 | "`ess-command' fails with hanging command within browser (#1081)." |
148 | 148 | :cleanup (ess-test--browser-cleanup) |
149 | | - :eval (ess-test--browser) |
| 149 | + (ess-test--browser) |
150 | 150 | :inf-result "Called from: top level |
151 | 151 | Browse[1]> debug at #1: NULL |
152 | 152 | Browse[1]> " |
153 | 153 |
|
154 | | - :eval (should-error (ess-command "Sys.sleep(2)\n" nil nil nil nil nil nil 0.01)) |
| 154 | + (should-error (ess-command "Sys.sleep(2)\n" nil nil nil nil nil nil 0.01)) |
155 | 155 |
|
156 | 156 | ;; No impact on inferior |
157 | 157 | :inf-result "" |
158 | | - :eval (should (inferior-ess-available-p)) |
| 158 | + (should (inferior-ess-available-p)) |
159 | 159 |
|
160 | 160 | ;; We're still in the browser |
161 | | - :eval (progn |
162 | | - (ess-send-string (ess-get-process) "NULL\n") |
163 | | - (ess-wait-for-process)) |
| 161 | + (ess-send-string (ess-get-process) "NULL\n") |
| 162 | + (ess-wait-for-process) |
164 | 163 | :inf-result "NULL |
165 | 164 | Browse[1]> ") |
166 | 165 |
|
167 | 166 | (etest-deftest ess-command-browser-curly-braces () |
168 | 167 | "`{` expressions when debugger is active do not interrupt command." |
169 | 168 | :cleanup (ess-test--browser-cleanup) |
170 | | - :eval (ess-test--browser) |
| 169 | + (ess-test--browser) |
171 | 170 | :inf-result "Called from: top level |
172 | 171 | Browse[1]> debug at #1: NULL |
173 | 172 | Browse[1]> " |
174 | 173 |
|
175 | | - :eval (should (string= (ess-string-command "{ 1; 2 }\n") |
176 | | - "[1] 2")) |
| 174 | + (should (string= (ess-string-command "{ 1; 2 }\n") |
| 175 | + "[1] 2")) |
177 | 176 | :inf-result "" |
178 | | - :eval (should (inferior-ess-available-p))) |
| 177 | + (should (inferior-ess-available-p))) |
179 | 178 |
|
180 | 179 | (etest-deftest ess-command-environment () |
181 | 180 | "Can access current env with `.ess.environment()`" |
182 | 181 | :cleanup (ess-test--browser-cleanup) |
183 | | - :eval (progn |
184 | | - (ess-send-string (ess-get-process) |
185 | | - "local({ foo <- 1; browser(); NULL })\n") |
186 | | - (ess-wait-for-process)) |
187 | | - :eval (should (string= (ess-string-command "ls(envir = .ess.environment())\n") |
188 | | - "[1] \"foo\""))) |
| 182 | + (ess-send-string (ess-get-process) |
| 183 | + "local({ foo <- 1; browser(); NULL })\n") |
| 184 | + (ess-wait-for-process) |
| 185 | + (should (string= (ess-string-command "ls(envir = .ess.environment())\n") |
| 186 | + "[1] \"foo\""))) |
189 | 187 |
|
190 | 188 | (etest-deftest ess-command-quit-test () |
191 | 189 | "`ess-command' does not leak output on quit (#794, #842). |
192 | 190 | This is especially important within `while-no-input' used by |
193 | 191 | packages like eldoc and company-quickhelp. `throw-on-input' sets |
194 | 192 | `quit-flag'." |
195 | 193 | ;; Simulate a quit by throwing from a timer |
196 | | - :eval ((run-at-time 0.1 nil (lambda () (throw 'my-quit 'thrown))) |
197 | | - (should (eq (catch 'my-quit |
198 | | - (ess-command "{ cat('output\n'); Sys.sleep(10) }\n" nil nil nil nil nil nil 0.5)) |
199 | | - 'thrown))) |
| 194 | + (run-at-time 0.1 nil (lambda () (throw 'my-quit 'thrown))) |
| 195 | + (should (eq (catch 'my-quit |
| 196 | + (ess-command "{ cat('output\n'); Sys.sleep(10) }\n" nil nil nil nil nil nil 0.5)) |
| 197 | + 'thrown)) |
200 | 198 | ;; There should be no output after the early exit |
201 | 199 | :inf-result "" |
202 | | - :eval (should (inferior-ess-available-p))) |
| 200 | + (should (inferior-ess-available-p))) |
203 | 201 |
|
204 | 202 | (etest-deftest ess-command-quit-async-interrupt-test () |
205 | 203 | "`ess-command' interrupts asynchronously on quits (#1091, #1102). |
206 | 204 | Needed with slow-responding processes." |
207 | | - :eval |
208 | | - (progn |
209 | | - (should (eq (identity (marker-buffer (process-mark (ess-get-process)))) |
210 | | - (ess-get-process-buffer))) |
211 | | - (run-at-time 0.1 nil (lambda () (throw 'my-quit 'thrown))) |
212 | | - (should (eq (catch 'my-quit |
213 | | - (ess-command "{ |
| 205 | + (should (eq (identity (marker-buffer (process-mark (ess-get-process)))) |
| 206 | + (ess-get-process-buffer))) |
| 207 | + (run-at-time 0.1 nil (lambda () (throw 'my-quit 'thrown))) |
| 208 | + (should (eq (catch 'my-quit |
| 209 | + (ess-command "{ |
214 | 210 | cat('output\n') |
215 | 211 | withCallingHandlers( |
216 | 212 | interrupt = function(...) Sys.sleep(0.2), |
217 | 213 | Sys.sleep(10) |
218 | 214 | ) |
219 | 215 | } |
220 | 216 | " |
221 | | - nil nil nil nil nil nil 0.5)) |
222 | | - 'thrown)) |
223 | | - ;; Wait for the async interrupt |
224 | | - (should (ess-wait-for-process (ess-get-process) nil nil 0.5)) |
225 | | - ;; Check that marker buffer was properly restored |
226 | | - (should (eq (marker-buffer (process-mark (ess-get-process))) |
227 | | - (ess-get-process-buffer)))) |
| 217 | + nil nil nil nil nil nil 0.5)) |
| 218 | + 'thrown)) |
| 219 | + ;; Wait for the async interrupt |
| 220 | + (should (ess-wait-for-process (ess-get-process) nil nil 0.5)) |
| 221 | + ;; Check that marker buffer was properly restored |
| 222 | + (should (eq (marker-buffer (process-mark (ess-get-process))) |
| 223 | + (ess-get-process-buffer))) |
228 | 224 |
|
229 | 225 | ;; There should be no output after the early exit or async restoration |
230 | 226 | :inf-result "") |
231 | 227 |
|
232 | 228 | (etest-deftest ess-command-newlines-test () |
233 | 229 | "`ess-command' doesn't garble new lines (#1110)." |
234 | | - :eval ((should (string= (ess--strip-final-newlines "1\n2") |
235 | | - "1\n2")) |
236 | | - (should (equal (ess-get-words-from-vector "{ 'foo'\n'bar'\n }\n") |
237 | | - (list "bar"))))) |
| 230 | + (should (string= (ess--strip-final-newlines "1\n2") |
| 231 | + "1\n2")) |
| 232 | + (should (equal (ess-get-words-from-vector "{ 'foo'\n'bar'\n }\n") |
| 233 | + (list "bar")))) |
238 | 234 |
|
239 | 235 | (etest-deftest ess-command-multiline-test () |
240 | 236 | "`ess-command' output doesn't include continuation prompts (#1116)." |
241 | | - :eval ((let ((buf (generate-new-buffer "ess-command-multiline-test"))) |
242 | | - (ess-command "{ 1\n 2 }\n" buf) |
243 | | - (should (string= (with-current-buffer buf |
244 | | - (buffer-string)) |
245 | | - "[1] 2"))))) |
| 237 | + (let ((buf (generate-new-buffer "ess-command-multiline-test"))) |
| 238 | + (ess-command "{ 1\n 2 }\n" buf) |
| 239 | + (should (string= (with-current-buffer buf |
| 240 | + (buffer-string)) |
| 241 | + "[1] 2")))) |
246 | 242 |
|
247 | 243 | (ert-deftest ess--command-output-info-test () |
248 | 244 | ;; No output |
@@ -306,34 +302,32 @@ new output") |
306 | 302 | With delimiters it might be possible to figure out the output. |
307 | 303 | However if they are not available then the output is |
308 | 304 | indistinguishable from the prompt." |
309 | | - :eval ((should-error (ess-command "cat(1)\n")) |
310 | | - (ess-wait-for-process)) |
| 305 | + (should-error (ess-command "cat(1)\n")) |
| 306 | + (ess-wait-for-process) |
311 | 307 | ;; Leaks output after the error but that seems fine since errors in |
312 | 308 | ;; filters are bugs |
313 | 309 | :inf-result " |
314 | 310 | > ") |
315 | 311 |
|
316 | 312 | (etest-deftest ess-command-intervening-input-test () |
317 | 313 | "Test that user can send input while command is interrupting (#1119)." |
318 | | - :eval |
319 | | - (progn |
320 | | - (run-at-time 0.1 nil (lambda () (throw 'my-quit 'thrown))) |
321 | | - (should (eq (catch 'my-quit |
322 | | - (ess-command "{ |
| 314 | + (run-at-time 0.1 nil (lambda () (throw 'my-quit 'thrown))) |
| 315 | + (should (eq (catch 'my-quit |
| 316 | + (ess-command "{ |
323 | 317 | cat('output\n') |
324 | 318 | withCallingHandlers( |
325 | 319 | interrupt = function(...) Sys.sleep(0.2), |
326 | 320 | Sys.sleep(10) |
327 | 321 | ) |
328 | 322 | } |
329 | 323 | " |
330 | | - nil nil nil nil nil nil 0.5)) |
331 | | - 'thrown)) |
332 | | - ;; Send intervening input right away. Since we wait on the R side |
333 | | - ;; on interrupt, the process hasn't been restored yet |
334 | | - (ess-send-string (ess-get-process) "cat('foobar\\n')\n") |
335 | | - ;; Wait for the async interrupt |
336 | | - (should (ess-wait-for-process nil nil nil 0.5))) |
| 324 | + nil nil nil nil nil nil 0.5)) |
| 325 | + 'thrown)) |
| 326 | + ;; Send intervening input right away. Since we wait on the R side |
| 327 | + ;; on interrupt, the process hasn't been restored yet |
| 328 | + (ess-send-string (ess-get-process) "cat('foobar\\n')\n") |
| 329 | + ;; Wait for the async interrupt |
| 330 | + (should (ess-wait-for-process nil nil nil 0.5)) |
337 | 331 | ;; The output for the intervening input should be shown in the |
338 | 332 | ;; process buffer |
339 | 333 | :inf-result "foobar |
@@ -528,13 +522,13 @@ some. text |
528 | 522 | ;;*;; Help |
529 | 523 |
|
530 | 524 | (etest-deftest ess-help-aliases-test () |
531 | | - :eval (let ((aliases (ess-get-help-aliases-list))) |
532 | | - (should (member "list" aliases))) |
| 525 | + (let ((aliases (ess-get-help-aliases-list))) |
| 526 | + (should (member "list" aliases))) |
533 | 527 | :inf-result "" |
534 | 528 |
|
535 | | - :eval ((ess-help--reset-cache) |
536 | | - (let ((aliases (ess-get-help-aliases-list))) |
537 | | - (should (member "list" aliases))))) |
| 529 | + (ess-help--reset-cache) |
| 530 | + (let ((aliases (ess-get-help-aliases-list))) |
| 531 | + (should (member "list" aliases)))) |
538 | 532 |
|
539 | 533 |
|
540 | 534 | ;;*;; Inferior utils |
|
0 commit comments