# Dune test error: 'Fatal error: exception Sys\_error("data/abs.decTest: No such file or directory")'

**URL:** <https://discuss.ocaml.org/t/dune-test-error-fatal-error-exception-sys-error-data-abs-dectest-no-such-file-or-directory/6815>\
**Category:** Ecosystem\
**Tags:** testing, dune\
**Created:** [November 20, 2020, 4:15pm UTC](https://discuss.ocaml.org/t/dune-test-error-fatal-error-exception-sys-error-data-abs-dectest-no-such-file-or-directory/6815 "2020-11-20T16:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [November 20, 2020, 4:15pm UTC](https://discuss.ocaml.org/t/dune-test-error-fatal-error-exception-sys-error-data-abs-dectest-no-such-file-or-directory/6815/1 "2020-11-20T16:15:43Z")

</div>

Hi, running `dune test` in CI ( [https://opam.ci.ocaml.org/github/ocaml/opam-repository/commit/22cd4fd03c1642202eb2f4c2097c190285b9e91c/variant/compilers,4.08,decimal.0.1.0,tests](https://opam.ci.ocaml.org/github/ocaml/opam-repository/commit/22cd4fd03c1642202eb2f4c2097c190285b9e91c/variant/compilers,4.08,decimal.0.1.0,tests) ) is failing with the following output:

```auto
### output ###
# decimal_test alias test/runtest (exit 2)
# (cd _build/default/test && ./decimal_test.exe)
# Test file: data/abs.decTest
# Fatal error: exception Sys_error("data/abs.decTest: No such file or directory")

```

The line `Test file: data/abs.decTest` is printed from the following code in `decimal_test.ml`:

```auto
let eval_file filename =
  print_string "Test file: ";
  print_endline filename;
  let ch = open_in filename in
  let str = really_input_string ch (in_channel_length ch) in
  close_in ch;
  eval_str str

```

So it’s throwing the exception when trying to open the file `data/abs.decTest`. Thing is, the file (among others) does exist in the repo:

```auto
test/
  data/
    abs.decTest
  decimal_test.ml
  dune

```

I know that dune does the build in an internal working directory, do I need to somehow tell it to copy the test data files into that and if so how? Would that be with [https://dune.readthedocs.io/en/stable/dune-files.html?highlight=copy#copy-files](https://dune.readthedocs.io/en/stable/dune-files.html?highlight=copy#copy-files) ?

---

<div class="post-metadata">

**Author:** ![CraigFe](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/craigfe/32/1989_2.png) [@CraigFe](https://discuss.ocaml.org/u/CraigFe)\
**Post date:** [November 20, 2020, 4:31pm UTC](https://discuss.ocaml.org/t/dune-test-error-fatal-error-exception-sys-error-data-abs-dectest-no-such-file-or-directory/6815/2 "2020-11-20T16:31:41Z")

</div>

You should tell Dune that those files are a dependency of your tests:

```diff
diff --git a/test/dune b/test/dune
index f4745b3..660ae37 100644
--- a/test/dune
+++ b/test/dune
@@ -1,3 +1,4 @@
 (test
   (name decimal_test)
+ (deps (glob_files data/*))
   (libraries angstrom decimal))

```

It’ll then make sure that those files make it into the `_build` directory as and when they are required.

Unrelated aside: you probably want to raise your lower OCaml bound and/or use `(preprocess future_syntax)`, since your tests rely on 4.08’s let-binding operators.

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [November 20, 2020, 4:33pm UTC](https://discuss.ocaml.org/t/dune-test-error-fatal-error-exception-sys-error-data-abs-dectest-no-such-file-or-directory/6815/3 "2020-11-20T16:33:56Z")

</div>

Thank you! You’re totally right, I’ll raise the lower bound too.
