caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Andrew Gacek" <andrew.gacek@gmail.com>
To: "Robert Fischer" <robert@fischerventure.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Building and Tests
Date: Sun, 19 Aug 2007 01:28:51 -0500	[thread overview]
Message-ID: <ff170bdf0708182328o66d62902kb676a8fa3020e58b@mail.gmail.com> (raw)
In-Reply-To: <46C7A266.6010606@fischerventure.com>

One thing I find helpful is to define tests anonymously inside of a
single test group. So inside of say list_test.ml I have

let tests =
  "List" >::: [
    "Empty list should have size zero" >::
      (fun () ->
        assert_equal 0 (List.length [])) ;

    "Singleton list should have size one" >::
      (fun () ->
        assert_equal 1 (List.length [0])) ;

   ...

  ]

Then I have a single file for the project called test.ml which
includes all the module tests explicitly and runs them. For example,

let tests = "Project Tests" >:::
  [
    List_test.tests ;
    Array_test.tests ;
    String_test.tests ;
    ...
  ]

let _ = run_test_tt_main tests

Finally in my OMakefile I have

TEST_FILES[] =
    $(rootname $(find . -name *_test.ml))
    test

.PHONY: test
test: $(OCamlProgram unit_test, $(OUNIT) $(FILES) $(TEST_FILES))
    ./unit_test -verbose

The end result of all of this is that when I add a new test to an
existing module, I don't have to explicitly include it to be run. The
only thing I have to do explicitly is list my module tests in the
master test.ml file, and this list rarely changes.

-Andrew

On 8/18/07, Robert Fischer <robert@fischerventure.com> wrote:
> Is there any kind of automation that other people have built for OUnit?
> I'm wondering if anyone has pulled together OMake or shell scripts to
> execute all the tests in multiple different files, or a test-then-build
> structure?
>
> ~~ Robert.
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


      reply	other threads:[~2007-08-19  6:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-19  1:52 Robert Fischer
2007-08-19  6:28 ` Andrew Gacek [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ff170bdf0708182328o66d62902kb676a8fa3020e58b@mail.gmail.com \
    --to=andrew.gacek@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=robert@fischerventure.com \
    /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.
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 NNTP newsgroup(s).