caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Building and Tests
@ 2007-08-19  1:52 Robert Fischer
  2007-08-19  6:28 ` [Caml-list] " Andrew Gacek
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Fischer @ 2007-08-19  1:52 UTC (permalink / raw)
  To: caml-list

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Building and Tests
  2007-08-19  1:52 Building and Tests Robert Fischer
@ 2007-08-19  6:28 ` Andrew Gacek
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Gacek @ 2007-08-19  6:28 UTC (permalink / raw)
  To: Robert Fischer; +Cc: caml-list

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
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-19  6:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-19  1:52 Building and Tests Robert Fischer
2007-08-19  6:28 ` [Caml-list] " Andrew Gacek

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).