From: Mikhail F. <mi...@ki...> - 2003-06-04 21:00:07
|
Hi! > > > > My preference would be to be able to compile the > > > > library *without* the unit testing code in it. > > > > This will require some thought, and probably > > > > some makefile hacking. > > > > > > Why Brian ? > > > I mean, having a big ExtLib.cma is not a problem, > since > > > we're using different modules, > > > > Unit testing code is usually implemented as a seperate > > program which uses the library, not as part of the > library. > > > > This actually limits the ability of the unit testing to > nail down what > just broke. For example, the PSQueue module has internal > functions > "rotate_right" and "rotate_left". I'd like the unit > tests to test those > functions independently- and balance as seperate from > rotate. Allowing me > to tell if I broke insert, balance, or a rotate. > > My inclination is to agree with Nicolas and just toss the > test functions > into the library and worry about size when it becomes a > problem. This won't be unit testing in the usual sense then. Unit testing covers external interface of the library; the main point is to figure out that something is broken; as long as it is known, it is easy to find exact error line, even by putting "let () = print_string error_here in" in the code. Including tests for internal functions does not buy much but makes the whole thing more complex. This kind of testing is usually implemented by inserting asserts in C code and by raising Invalid_argument in some ocaml functions. If you really need to test internal function I think (with my limited ocaml expirience) that it is possible to compile a special version of the library by copying library.ml to testlibrary.ml and creating the specil version of the library out of it which would include all the functions. I don't remember if .mli file is strictly required (I've never tried to build a library without it), but if it is not, then it is even easier. Mikhail |