File: gen_dune.ml

package info (click to toggle)
liquidsoap 2.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,844 kB
  • sloc: ml: 74,136; javascript: 27,320; ansic: 505; sh: 139; xml: 114; lisp: 96; makefile: 26
file content (71 lines) | stat: -rw-r--r-- 1,768 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(* test name, (deps, args) *)
let test_params =
  [
    ( "json_test",
      ( "(:json ./json) (:json5 ./json5) (:big-list-of-naughty-strings \
         ./big-list-of-naughty-strings)",
        [""] ) );
    ( "stream_decoder_test",
      ( "(:test_wav ./test.wav) (:test_mp3 ./test.mp3)",
        ["%{test_wav} bla.wav"; "%{test_mp3} bla.wav"] ) );
    ("parsesrt", ("(:test_srt ./test.srt)", ["%{test_srt}"]));
  ]

let test_names = ref []

let test_name s =
  let test_name = Filename.remove_extension s in
  test_names := Printf.sprintf "(alias %s)" test_name :: !test_names;
  test_name

let () =
  let location = Sys.getcwd () in
  let tests =
    List.sort Stdlib.compare
      (List.filter_map
         (fun f ->
           if f <> "gen_dune.ml" && Filename.extension f = ".ml" then
             Some (Filename.remove_extension f)
           else None)
         (Build_tools.read_files ~location ""))
  in
  List.iter
    (fun test ->
      let deps, args =
        match List.assoc_opt test test_params with
          | None -> ("", [""])
          | Some (deps, args) -> (deps, args)
      in
      Printf.printf
        {|
(executable
 (name %s)
 (modules %s)
 (libraries liquidsoap_core liquidsoap_optionals))

(rule
 (alias %s)
 (package liquidsoap)
 (deps
  %s
  (:%s %s.exe))
 (action %s%s%s))

|}
        (test_name test) test test deps test test
        (if List.length args > 1 then "(progn " else "")
        (String.concat " "
           (List.map
              (fun arg -> Printf.sprintf "(run %%{%s} %s)" test arg)
              args))
        (if List.length args > 1 then ")" else ""))
    tests

let () =
  Printf.printf
    {|(alias
  (name citest)
  (deps
    %s))
|}
    (String.concat "\n    " (List.sort_uniq Stdlib.compare !test_names))