OCaml test runner bug?


I was puzzled by a strange problem my student experienced in “List Ops” exercise in OCaml. So I downloaded the exercise myself and wrote the following (incorrect on purpose) code

let length _ = 0
let reverse _ = []
let map ~f _ = []
let filter ~f _ = []
let fold ~init ~f = function
  | [] -> init
  | l -> List.hd l |> f init
let append _ _ = []
let concat _ = []

Obviously the tests fail locally. Please notice that there are no loops or recursion in the code. And when I submitted the code to Exercism here is what I see:

Your tests timed out. This might mean that there was an issue in our infrastructure, but more likely it suggests that your code is running slowly. Is there an infinite loop or something similar?

Please check your code, and if nothing seems to be wrong, try running the tests again.

I have tried to re-run the tests, with the same result. What do I miss?

In order to ensure that the functions are actually tail-call recursive it has to work on very large lists. Unfortunately just the tests exceed the computation limit of the test runners.

More info in this thread: List Ops timing out

My student problem was that the completely tail-recursive solution was blowing up the stack (everything worked locally, of course) and the error message looked to me like test setup was failing. So I wanted to try something simple.

Okay, I had a look at the linked forum thread and Ocaml list-ops tests always time out · Issue #456 · exercism/ocaml · GitHub. What’s the plan?

I wonder if it is possible to use @tailcall in tests instead of huge lists.