# Dune rules, library targets and inline test runners

**URL:** <https://discuss.ocaml.org/t/dune-rules-library-targets-and-inline-test-runners/11722>\
**Category:** Ecosystem\
**Tags:** dune\
**Created:** [March 20, 2023, 10:14am UTC](https://discuss.ocaml.org/t/dune-rules-library-targets-and-inline-test-runners/11722 "2023-03-20T10:14:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Release-Candidate](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/release-candidate/32/3550_2.png) [@Release-Candidate](https://discuss.ocaml.org/u/Release-Candidate)\
**Post date:** [March 20, 2023, 10:14am UTC](https://discuss.ocaml.org/t/dune-rules-library-targets-and-inline-test-runners/11722/1 "2023-03-20T10:14:15Z")

</div>

Is there a simpler way than doing the following to get the path of an inline test runner to a given source file (a test in a source file):

- I know the path to be something like `_build/default/test/foo/.LIBRARY.inline-tests/inline_test_runner_LIBRARY.exe`
- to get the name of the library `LIBRARY` I parse the output of `dune rules -r test`
- I search for a sexp containing the source file and `"library-name=\"LIBRARY\"` which yields the name.  
The problem is that `dune build test` does not build the inline test runners, only `dune test` builds them, so there is no mention of the inline test runner in the output of `dune rules -r test`.

For example a file `test/foo/bar.ml` that is part of a library `baz` with the inline runner executable `_build/default/test/foo/.baz.inline-tests/inline_test_runner_baz.exe`: `baz` is the minimal amount of information I need, the path of the test runner’s executable would be the optimum.

I’ve tried parsing the `dune` file for the library containing the source file, but that only works for ‘simple’ ones and not for files like this:

```auto
(library
 (name dune_file_watcher_tests_lib)
 (modules dune_file_watcher_tests_lib)
 (libraries dune_file_watcher base stdune threads.posix stdio spawn))

(library
 (name dune_file_watcher_tests_macos)
 (modules dune_file_watcher_tests_macos)
 (inline_tests
  (enabled_if
   (and
    (<> %{env:CI=false} true) ;; in github action, CI=true
    (= %{system} macosx)))
  (deps
   (sandbox always)))
 (libraries
  dune_file_watcher
  dune_file_watcher_tests_lib
  ppx_expect.config
  ppx_expect.config_types
  ppx_expect.common
  base
  stdune
  ppx_inline_test.config
  threads.posix
  stdio
  spawn)
 (preprocess
  (pps ppx_expect)))

(library
 (name dune_file_watcher_tests_linux)
 (modules dune_file_watcher_tests_linux)
 (inline_tests
  (enabled_if
   (= %{system} linux))
  (deps
   (sandbox always)))
 (libraries
  dune_file_watcher
  dune_file_watcher_tests_lib
  ppx_expect.config
  ppx_expect.config_types
  ppx_expect.common
  base
  stdune
  ppx_inline_test.config
  threads.posix
  stdio
  spawn)
 (preprocess
  (pps ppx_expect)))

```

And ‘ask ChatGPT’ is not an option!
