From: Ruijie Yu via "General discussions about Org-mode." <emacs-orgmode@gnu.org>
To: Bruno Barbier <brubar.cs@gmail.com>
Cc: Ihor Radchenko <yantar92@posteo.net>, emacs-orgmode@gnu.org
Subject: Re: [PATCH] Add tests for ob-haskell (GHCi)
Date: Sun, 07 May 2023 17:18:15 +0800 [thread overview]
Message-ID: <sdvjzxkh4ft.fsf@netyu.xyz> (raw)
In-Reply-To: <6457663a.df0a0220.f6b38.a05e@mx.google.com>
Minor remarks below regarding the patchset.
Bruno Barbier <brubar.cs@gmail.com> writes:
> From 9ef867cd2cf89e77b5c5a5a7090fd37b1702e06a Mon Sep 17 00:00:00 2001
> From: Bruno BARBIER <brubar.cs@gmail.com>
> Date: Fri, 18 Nov 2022 20:14:20 +0100
> Subject: [PATCH 01/13] ob-haskell: Add tests for GHCi
>
> testing/lisp/test-ob-haskell-ghci.el: New file.
> ---
> testing/lisp/test-ob-haskell-ghci.el | 453 +++++++++++++++++++++++++++
> 1 file changed, 453 insertions(+)
> create mode 100644 testing/lisp/test-ob-haskell-ghci.el
>
> diff --git a/testing/lisp/test-ob-haskell-ghci.el b/testing/lisp/test-ob-haskell-ghci.el
> new file mode 100644
> index 000000000..aba94d73f
> --- /dev/null
> +++ b/testing/lisp/test-ob-haskell-ghci.el
> @@ -0,0 +1,453 @@
> +;;; test-ob-haskell-ghci.el --- tests for ob-haskell.el GHCi -*- lexical-binding: t; -*-
> +
> +;; Copyright (c) 2023 Free Software Foundation, Inc.
lisp/org.el has only a single space, so probably single space here as well.
> +
> +;; Authors: Bruno BARBIER <brubar.cs@gmail.com>
> +
> +;; This program is free software; you can redistribute it and/or modify
> +;; it under the terms of the GNU General Public License as published by
> +;; the Free Software Foundation, either version 3 of the License, or
> +;; (at your option) any later version.
Do we need the text for "part of GNU Emacs"?
> +
> +;; This program is distributed in the hope that it will be useful,
> +;; but WITHOUT ANY WARRANTY; without even the implied warranty of
> +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +;; GNU General Public License for more details.
> +
> +;; You should have received a copy of the GNU General Public License
> +;; along with this program. If not, see <https://www.gnu.org/licenses/>.
> +
> +;;; Commentary:
> +;;
> +
> +;;;; Useful references
> +;;
> +;; - https://orgmode.org/worg/org-contrib/babel/languages/lang-compat.html
> +;; - GHCi manual: https://downloads.haskell.org/ghc/latest/docs/users_guide/ghci.html
> +;;;; FIXME: Random failures
> +;;
> +;; 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
> +;;
Wanted to say something here, but then realized that you deleted this
portion in a later commit.
> +
> +;;;; 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 |
> +
> +
> +;;; Code:
> +;;
> +
> +(require 'org-test "../testing/org-test")
> +(org-test-for-executable "ghci")
> +(unless (featurep 'haskell-mode)
> + (signal 'missing-test-dependency "haskell-mode"))
> +
> +
> +;;; Helpers
> +;;
> +
> +(defun test-ob-haskell-ghci--with-global-session-worker (todo)
> + "See `test-ob-haskell-ghci--with-global-session-worker'."
This docstring doesn't say much and only refers to itself. Maybe
explain what it does? (Or now that I look at it, potentially you wanted
to refer to the macro `test-ob-haskell-ghci-with-global-session'
instead.)
> +(defun test-ob-haskell-ghci (args content &optional preamble unprotected)
> + "Execute the code block CONTENT in a new GHCi session; return the result.
> +Add ARGS to the code block argument line. Insert PREAMBLE
> +before the code block. When UNPROTECTED is non-nil, don't control
> +which session is used (i.e. don't call
> +`test-ob-haskell-ghci--with-global-session-worker')."
> + (when (listp content)
> + (setq content (string-join content "\n")))
> + (unless preamble
> + (setq preamble ""))
> + (let ((todo (lambda ()
One space.
> +;;;; Data tables
> +;;
> +
> +(ert-deftest ob-haskell/int-table-data ()
> + "From worg: int-table-data."
> + (should (equal 10 (test-ob-haskell-ghci ":var t=int-table-data"
> + "sum [sum r | r <- t]"
> + "#+name: int-table-data
> + | 1 | 2 |
> + | 3 | 4 |"))))
> +
> +(ert-deftest ob-haskell/float-table-data ()
> + "From worg: float-table-data."
> + (should (equal 11.0 (test-ob-haskell-ghci ":var t=float-table-data"
> + "sum [sum r | r <- t]"
> + "#+name: float-table-data
> + | 1.1 | 2.2 |
> + | 3.3 | 4.4 |"))))
> +
> +(ert-deftest ob-haskell/string-table-data ()
> + "From worg: string-table-data."
> + (should (equal "abcd" (test-ob-haskell-ghci ":var t=string-table-data"
> + "concat [concat r | r <- t]"
> + "#+name: string-table-data
> + | a | b |
> + | c | d |"))))
> +
> +;;;; Reuse results
> +;;
> +(ert-deftest ob-haskell/reuse-table ()
> + "Reusing a computed tables."
> + (should (equal 78 (test-ob-haskell-ghci ":var t=a-table"
> + "sum [sum r | r <- t]"
> + "#+name: a-table
> +#+begin_src haskell
> + [ [x..x+2] | x <- [1,4 .. 12] ]
> +#+end_src
> +"))))
> +
> +
> +;;;; Not define errors
> +;;
Single space?
--
Best,
RY
next prev parent reply other threads:[~2023-05-07 9:34 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-19 9:12 [PATCH] Add tests for ob-haskell (GHCi) Bruno Barbier
2023-03-19 10:20 ` Ihor Radchenko
2023-03-19 10:28 ` Ihor Radchenko
2023-03-19 10:32 ` Bruno Barbier
2023-03-22 10:16 ` Ihor Radchenko
2023-03-24 10:36 ` Ihor Radchenko
2023-03-25 10:01 ` Bruno Barbier
2023-03-26 9:09 ` Ihor Radchenko
2023-03-26 9:40 ` Bruno Barbier
2023-03-26 9:46 ` Ihor Radchenko
[not found] ` <notmuch-sha1-0807e1720f829950d42ef560bc30e56bd152766c>
2023-05-07 8:50 ` Bruno Barbier
2023-05-07 9:18 ` Ruijie Yu via General discussions about Org-mode. [this message]
2023-05-07 11:15 ` Bruno Barbier
2023-05-08 10:59 ` Ihor Radchenko
2023-05-21 7:40 ` Bruno Barbier
2023-06-02 8:44 ` Ihor Radchenko
2023-08-10 12:51 ` Ihor Radchenko
2023-08-25 19:10 ` Bruno Barbier
2023-09-07 14:21 ` Bruno Barbier
2023-09-08 8:23 ` Ihor Radchenko
2023-09-08 9:49 ` Bruno Barbier
2023-03-23 10:35 ` Ihor Radchenko
2023-03-23 21:01 ` ParetoOptimalDev
2023-03-23 21:30 ` ParetoOptimalDev
2023-03-24 10:40 ` Ihor Radchenko
2023-03-26 3:27 ` ParetoOptimalDev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sdvjzxkh4ft.fsf@netyu.xyz \
--to=emacs-orgmode@gnu.org \
--cc=brubar.cs@gmail.com \
--cc=ruijie@netyu.xyz \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).