How do I get ocp-build to run oUnit tests for an ocaml project?

142 views Asked by At

I've set up a tiny ocaml project that uses ocp-build. I builds just fine, but I can't figure out how to get oUnit tests to run, nor can I find any good examples online.

My project is laid out like this:

-sample_project
 |-src
 | |-main
 | | |-build.ocp
 | | |-main.ml
 | |-test
 |   |-test.ml
 |   |-test.ocp 

main.ml is just "hello world" test.ml is an example test from the oUnit site.

The build files contain:

build.ocp:

begin program "hello"
  files = [ "main.ml"]
  requires = [ "batteries" ]
end

test.ocp:

begin program "run_test"
  files = [ "test.ml"]
  requires = [ "oUnit" ]
end

begin test "test"
  files = [ ]
  requires = [ "run_test" ]
  test_cmd = "run_test"
  tests = [ "test_list_length" ]
end

Here's the output I get running ocp-build:

sample_project>ocp-build -test
find_project_root
Warning: Could not find OCaml ocamldoc tool.
Warning: 4 missing and 2 disabled (use -print-missing)
Updating ocp-build.root
Warning: 2 missing and 1 disabled (use -print-missing)
Warning: 5 package conflicts solved (use -print-conflicts)
Build Successful in 0.13s. 0 jobs (parallelism 0.0x), 0 files generated.

sample_project>ocp-build tests
find_project_root
Warning: Could not find OCaml ocamldoc tool.
Warning: 4 missing and 2 disabled (use -print-missing)
Updating ocp-build.root
Warning: 2 missing and 1 disabled (use -print-missing)
Warning: 5 package conflicts solved (use -print-conflicts)
Error: project contains no targets
        Are your .ocp files empty ?

The test is designed to fail(and does fail when run as bytecode).

Even the ocp-build project itself (I got the source online), which has a test defined, doesn't seem to work. (I get similar output as for my sample project).

Thanks in advance.

1

There are 1 answers

0
Juan Chanco On BEST ANSWER

I ended up using oasis instead, and will probably switch to just make eventually.