Search code examples
ocamlocaml-duneocamldebug

How can I run inline unit tests in ocamldebug?


With the Dune buildsystem, it is easy to output a bytecode file for an executable for use with ocamldebug. However, it isn't clear how to do the same with inline unit tests; the Dune docs say how to run tests in bytecode, but then it is not clear how to actually run the tests in ocamldebug. A file that seems like it should be bytecode is produced in _build/default/src/.libname.inline-tests/inline_test_runner_libname.bc, but ocamldebug fails to run it claiming it is not a bytecode file, and the file command confirms this:

file _build/default/src/.tlapm_lib.inline-tests/inline_test_runner_tlapm_lib.bc _build/default/src/.tlapm_lib.inline-tests/inline_test_runner_tlapm_lib.bc: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=546a34751609fc98b4202c4ede320378c83a8138, for GNU/Linux 4.4.0, with debug_info, not stripped

Since running inline unit tests in a debugger is very valuable, how can this be done?


Solution

  • The answer is that this is not possible, but it isn't a big deal because OCaml developers don't actually use the debugger anyway. Instead, they opt for REPLs like utop.