[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Add tests for ob-haskell (GHCi)
From: |
Bruno Barbier |
Subject: |
Re: [PATCH] Add tests for ob-haskell (GHCi) |
Date: |
Sun, 26 Mar 2023 11:40:25 +0200 |
Ihor Radchenko <yantar92@posteo.net> writes:
> Bruno Barbier <brubar.cs@gmail.com> writes:
>
>> Note that I've changed the tests about errors; I'm now expecting
>> ob-haskell to raise errors. I'm not sure what we should expect to be
>> consistent with other org babel backends.
>
> Errors are usually displayed separately, using
> `org-babel-eval-error-notify'.
I'll see what can be done with GHCi and use this if possible.
Thanks.
>> +;; To increase the chances of failure when running tests, you can use this
>> command line:
>> +;;
>> +;; (for I in 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6
>> 7 8 9 10; do make 'BTEST_OB_LANGUAGES=haskell' BTEST_RE='haskell' test-dirty
>> & done) 2>&1 | grep FAILED
>> +;;
>> +
>> +;;;; Status
>> +;;
>> +;; All the tests should succeed (except for random failures); those
>> +;; flagged with ":expected-result :failed" are known
>> +;; limitations/bugs. Tested with (2023-03-18):
>> +;;
>> +;; | emacs-version | 29.0.60 |
>> +;; | org-version | main@4cad6c8ea (Mar 16 2023) |
>> +;; | haskell-mode | master@20d4e23 (Mar 4 2023) |
>> +;; | ghci | 9.0.2 |
>
> You can probably remove this.
Definitely. I'll do. Thanks.
>> + (`value (org-babel-comint-with-output
>> + (session org-babel-haskell-eoe nil full-body)
>> + (insert "__LAST_VALUE_IMPROBABLE_NAME__=()::()\n")
>> + (comint-send-input nil t)
>> + (insert full-body)
>> + (comint-send-input nil t)
>> + (insert "__LAST_VALUE_IMPROBABLE_NAME__=it\n")
>> + (comint-send-input nil t)
>> + (insert (concat "putStrLn (\"\\\"\" ++ "
>> org-babel-haskell-eoe " ++ \"\\\"\")\n"))
>
> Why not simply putStrLn ("\"" ++ show it ++ "\"") ?
>
I'm not sure I understand. I'm using the first
'org-babel-comint-with-output' to execute the source block and save the
last value (the "it" variable). Then, I'm using a second
'org-babel-comint-with-output' to make sure the output of this one
contains only the last value. If I display "it" in the first block, I
will not be able to differentiate between some output, previous values
and the last value. And, printing "org-babel-haskell-eoe" updates the
"it" variable (the last value becoming "()"), so I have to store the
real "it" somewhere.
Am I missing something ?
>> + (when (and session-name (string= session-name "none"))
>> + (setq session-name nil))
>> + (unless session-name
>> + ;; As haskell-mode is using the buffer name "*haskell*", we stay
>> + ;; away from it.
>> + (setq session-name (generate-new-buffer-name "*ob-haskell*")))
>
> This will make ob-haskell spawn a separate ghci process buffer every
> single time a user runs non-session src block. And the buffer is not
> closed after getting the result.
Very good point!
I will update this to use the same buffer named "*ob-haskell*" when the
user doesn't set the session name. I guess it's consistent with other
org-babel backends.
Thank you very much for the review and you help!
Bruno
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
- [PATCH] Add tests for ob-haskell (GHCi), Bruno Barbier, 2023/03/19
- Re: [PATCH] Add tests for ob-haskell (GHCi), Ihor Radchenko, 2023/03/19
- Re: [PATCH] Add tests for ob-haskell (GHCi), Ihor Radchenko, 2023/03/19
- Re: [PATCH] Add tests for ob-haskell (GHCi), Bruno Barbier, 2023/03/19
- Re: [PATCH] Add tests for ob-haskell (GHCi), Ihor Radchenko, 2023/03/22
- Re: [PATCH] Add tests for ob-haskell (GHCi), Ihor Radchenko, 2023/03/24
- Re: [PATCH] Add tests for ob-haskell (GHCi), Bruno Barbier, 2023/03/25
- Re: [PATCH] Add tests for ob-haskell (GHCi), Ihor Radchenko, 2023/03/26
- Re: [PATCH] Add tests for ob-haskell (GHCi),
Bruno Barbier <=
- Re: [PATCH] Add tests for ob-haskell (GHCi), Ihor Radchenko, 2023/03/26
Re: [PATCH] Add tests for ob-haskell (GHCi), Ihor Radchenko, 2023/03/23