Quantcast
Channel: OCaml - Topics tagged dune
Viewing all articles
Browse latest Browse all 521

Not able to access library code in tests in a Dune project

$
0
0

Hi folks,

Hopefully this is the right place for this question. I have a Dune project:

$ tree
.
├── bin
│   ├── dune
│   └── main.ml
├── compiler.opam
├── dune-project
├── lib
│   ├── dune
│   └── foo.ml
└── test
    ├── compiler.ml
    └── dune

where test/compiler.ml contains the following:

open OUnit2

let tests =  
  "foo" >:::
  ["returns the value passed" >:: 
   (fun _ -> assert_equal 2  (foo 2))]

 let _ = run_test_tt_main tests

The function foo is defined in lib/foo.ml as

let foo x = x

When I try to build with dune build, I get:

$ dune build
File "test/compiler.ml", line 6, characters 30-33:
6 |    (fun _ -> assert_equal 2  (foo 2))]
                                  ^^^
Error: Unbound value foo

How do I get the tests to see the code in my library? My lib/dune contains

(library
 (name compiler))

and test/dune has

(test
 (name compiler)
 (libraries ounit2 compiler))

Thanks!

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 521

Trending Articles