File: gen_tests.ml

package info (click to toggle)
ocaml-cstruct 6.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 904 kB
  • sloc: ml: 3,578; ansic: 53; makefile: 28; javascript: 21
file content (31 lines) | stat: -rw-r--r-- 635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let output_stanzas name =
  Printf.printf
    {|
(rule
  (deps pp.exe (:input %s))
  (targets %s.errors)
  (action
    (progn
      (with-stderr-to %%{targets}
        (run ./pp.exe --impl %%{input}))
      (bash "sed -i.bak '1d' %%{targets}"))))
(rule
  (alias runtest)
  (package ppx_cstruct)
  (action
    (diff %s.expected %s.errors)))
|}
    name name name name

let is_test = function
  | "pp.ml" -> false
  | "pp.pp.ml" -> false
  | "gen_tests.ml" -> false
  | e -> Filename.check_suffix e ".ml"

let () =
  Sys.readdir "."
  |> Array.to_list
  |> List.sort String.compare
  |> List.filter is_test
  |> List.iter output_stanzas