From e6d2ebc693ff210c2bca00935a327cb7bd236405 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 31 Oct 2019 17:39:37 +0100 Subject: [PATCH 1/7] Add CLI tests --- test/cli/dune | 10 +++++++++ test/cli/dune.inc | 10 +++++++++ test/cli/gen/dune | 2 ++ test/cli/gen/gen.ml | 44 +++++++++++++++++++++++++++++++++++++ test/cli/no_arg.opts | 0 test/cli/no_arg.ref | 1 + test/cli/no_arg.should-fail | 0 7 files changed, 67 insertions(+) create mode 100644 test/cli/dune create mode 100644 test/cli/dune.inc create mode 100644 test/cli/gen/dune create mode 100644 test/cli/gen/gen.ml create mode 100644 test/cli/no_arg.opts create mode 100644 test/cli/no_arg.ref create mode 100644 test/cli/no_arg.should-fail diff --git a/test/cli/dune b/test/cli/dune new file mode 100644 index 0000000000..9e8b171063 --- /dev/null +++ b/test/cli/dune @@ -0,0 +1,10 @@ +(include dune.inc) + +(rule + (targets dune.inc.gen) + (deps (source_tree .)) + (action (with-stdout-to %{targets} (run ./gen/gen.exe)))) + +(alias + (name runtest) + (action (diff dune.inc dune.inc.gen))) diff --git a/test/cli/dune.inc b/test/cli/dune.inc new file mode 100644 index 0000000000..058122e7a7 --- /dev/null +++ b/test/cli/dune.inc @@ -0,0 +1,10 @@ + +(rule + (targets no_arg.output) + (action + (with-outputs-to %{targets} + (system "! %{bin:ocamlformat} %{read-lines:no_arg.opts}")))) + +(alias + (name runtest) + (action (diff no_arg.ref no_arg.output))) diff --git a/test/cli/gen/dune b/test/cli/gen/dune new file mode 100644 index 0000000000..9df6b5100e --- /dev/null +++ b/test/cli/gen/dune @@ -0,0 +1,2 @@ +(executable + (name gen)) diff --git a/test/cli/gen/gen.ml b/test/cli/gen/gen.ml new file mode 100644 index 0000000000..b163022c24 --- /dev/null +++ b/test/cli/gen/gen.ml @@ -0,0 +1,44 @@ +module StringMap = Map.Make (String) + +type entry = { + should_fail : bool +} + +let empty_entry = { + should_fail = false; +} + +let register_file entries fname = + let update_or_add key ~f = + StringMap.update key (function + | Some entry -> Some (f entry) + | None -> Some (f empty_entry)) entries + in + match String.split_on_char '.' fname with + | [ test_name; "opts" ] -> + update_or_add test_name ~f:(fun e -> e) + | [ test_name; "should-fail" ] -> + update_or_add test_name ~f:(fun _e -> { should_fail = true }) + | _ -> + entries + +let emit_test test_name entry = + let cmd_prefix = if entry.should_fail then "! " else "" in + Printf.printf {| +(rule + (targets %s.output) + (action + (with-outputs-to %%{targets} + (system "%s%%{bin:ocamlformat} %%{read-lines:%s.opts}")))) + +(alias + (name runtest) + (action (diff %s.ref %s.output))) +|} + test_name cmd_prefix test_name + test_name test_name + +let () = + Sys.readdir "." + |> Array.fold_left register_file StringMap.empty + |> StringMap.iter emit_test diff --git a/test/cli/no_arg.opts b/test/cli/no_arg.opts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/cli/no_arg.ref b/test/cli/no_arg.ref new file mode 100644 index 0000000000..4bc1d3b5e1 --- /dev/null +++ b/test/cli/no_arg.ref @@ -0,0 +1 @@ +ocamlformat: Must specify at least one input file, or `-` for stdin diff --git a/test/cli/no_arg.should-fail b/test/cli/no_arg.should-fail new file mode 100644 index 0000000000..e69de29bb2 From e08a11f9078f60c148fee88e71a817328bae1dc8 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 31 Oct 2019 18:01:23 +0100 Subject: [PATCH 2/7] Show error when .opts or .ref file is missing --- test/cli/gen/gen.ml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/test/cli/gen/gen.ml b/test/cli/gen/gen.ml index b163022c24..2ef545dd83 100644 --- a/test/cli/gen/gen.ml +++ b/test/cli/gen/gen.ml @@ -1,10 +1,14 @@ module StringMap = Map.Make (String) type entry = { + has_ref : bool; + has_opts : bool; should_fail : bool } let empty_entry = { + has_ref = false; + has_opts = false; should_fail = false; } @@ -15,13 +19,24 @@ let register_file entries fname = | None -> Some (f empty_entry)) entries in match String.split_on_char '.' fname with + | [ test_name; "ref" ] -> + update_or_add test_name ~f:(fun e -> { e with has_ref = true }) | [ test_name; "opts" ] -> - update_or_add test_name ~f:(fun e -> e) + update_or_add test_name ~f:(fun e -> { e with has_opts = true }) | [ test_name; "should-fail" ] -> - update_or_add test_name ~f:(fun _e -> { should_fail = true }) + update_or_add test_name ~f:(fun e -> { e with should_fail = true }) | _ -> entries +let check_test test_name entry ok = + let e ok b = + if b then Format.kfprintf (fun _ -> false) Format.err_formatter + else Format.ikfprintf (fun _ -> ok) Format.err_formatter + in + let ok = e ok (not entry.has_ref) "@{Error@}: Missing file %s.ref\n" test_name in + let ok = e ok (not entry.has_opts) "@{Error@}: Missing file %s.opts\n" test_name in + ok + let emit_test test_name entry = let cmd_prefix = if entry.should_fail then "! " else "" in Printf.printf {| @@ -39,6 +54,8 @@ let emit_test test_name entry = test_name test_name let () = - Sys.readdir "." - |> Array.fold_left register_file StringMap.empty - |> StringMap.iter emit_test + let files = Sys.readdir "." in + let tests = Array.fold_left register_file StringMap.empty files in + if not (StringMap.fold check_test tests true) then + exit 1; + StringMap.iter emit_test tests From fe9bd20a24ec778db55ccab0336866f2ac08e0f0 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 31 Oct 2019 18:11:12 +0100 Subject: [PATCH 3/7] Add tests for CLI errors --- test/cli/default_several_file.opts | 1 + test/cli/default_several_file.ref | 1 + test/cli/default_several_file.should-fail | 0 test/cli/dune.inc | 80 +++++++++++++++++++++++ test/cli/inplace_and_check.opts | 1 + test/cli/inplace_and_check.ref | 1 + test/cli/inplace_and_check.should-fail | 0 test/cli/inplace_and_output.opts | 1 + test/cli/inplace_and_output.ref | 1 + test/cli/inplace_and_output.should-fail | 0 test/cli/output_and_check.opts | 1 + test/cli/output_and_check.ref | 1 + test/cli/output_and_check.should-fail | 0 test/cli/output_several_files.opts | 1 + test/cli/output_several_files.ref | 1 + test/cli/output_several_files.should-fail | 0 test/cli/sample/a.ml | 1 + test/cli/sample/b.ml | 1 + test/cli/stdin_and_file.opts | 1 + test/cli/stdin_and_file.ref | 1 + test/cli/stdin_and_file.should-fail | 0 test/cli/stdin_and_inplace.opts | 1 + test/cli/stdin_and_inplace.ref | 1 + test/cli/stdin_and_inplace.should-fail | 0 test/cli/stdin_no_kind.opts | 1 + test/cli/stdin_no_kind.ref | 1 + test/cli/stdin_no_kind.should-fail | 0 27 files changed, 98 insertions(+) create mode 100644 test/cli/default_several_file.opts create mode 100644 test/cli/default_several_file.ref create mode 100644 test/cli/default_several_file.should-fail create mode 100644 test/cli/inplace_and_check.opts create mode 100644 test/cli/inplace_and_check.ref create mode 100644 test/cli/inplace_and_check.should-fail create mode 100644 test/cli/inplace_and_output.opts create mode 100644 test/cli/inplace_and_output.ref create mode 100644 test/cli/inplace_and_output.should-fail create mode 100644 test/cli/output_and_check.opts create mode 100644 test/cli/output_and_check.ref create mode 100644 test/cli/output_and_check.should-fail create mode 100644 test/cli/output_several_files.opts create mode 100644 test/cli/output_several_files.ref create mode 100644 test/cli/output_several_files.should-fail create mode 100644 test/cli/sample/a.ml create mode 100644 test/cli/sample/b.ml create mode 100644 test/cli/stdin_and_file.opts create mode 100644 test/cli/stdin_and_file.ref create mode 100644 test/cli/stdin_and_file.should-fail create mode 100644 test/cli/stdin_and_inplace.opts create mode 100644 test/cli/stdin_and_inplace.ref create mode 100644 test/cli/stdin_and_inplace.should-fail create mode 100644 test/cli/stdin_no_kind.opts create mode 100644 test/cli/stdin_no_kind.ref create mode 100644 test/cli/stdin_no_kind.should-fail diff --git a/test/cli/default_several_file.opts b/test/cli/default_several_file.opts new file mode 100644 index 0000000000..de26e376b3 --- /dev/null +++ b/test/cli/default_several_file.opts @@ -0,0 +1 @@ +sample/a.ml sample/b.ml diff --git a/test/cli/default_several_file.ref b/test/cli/default_several_file.ref new file mode 100644 index 0000000000..8231c3424e --- /dev/null +++ b/test/cli/default_several_file.ref @@ -0,0 +1 @@ +ocamlformat: Must specify exactly one input file without --inplace or --check diff --git a/test/cli/default_several_file.should-fail b/test/cli/default_several_file.should-fail new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/cli/dune.inc b/test/cli/dune.inc index 058122e7a7..13fcb900ac 100644 --- a/test/cli/dune.inc +++ b/test/cli/dune.inc @@ -1,4 +1,34 @@ +(rule + (targets default_several_file.output) + (action + (with-outputs-to %{targets} + (system "! %{bin:ocamlformat} %{read-lines:default_several_file.opts}")))) + +(alias + (name runtest) + (action (diff default_several_file.ref default_several_file.output))) + +(rule + (targets inplace_and_check.output) + (action + (with-outputs-to %{targets} + (system "! %{bin:ocamlformat} %{read-lines:inplace_and_check.opts}")))) + +(alias + (name runtest) + (action (diff inplace_and_check.ref inplace_and_check.output))) + +(rule + (targets inplace_and_output.output) + (action + (with-outputs-to %{targets} + (system "! %{bin:ocamlformat} %{read-lines:inplace_and_output.opts}")))) + +(alias + (name runtest) + (action (diff inplace_and_output.ref inplace_and_output.output))) + (rule (targets no_arg.output) (action @@ -8,3 +38,53 @@ (alias (name runtest) (action (diff no_arg.ref no_arg.output))) + +(rule + (targets output_and_check.output) + (action + (with-outputs-to %{targets} + (system "! %{bin:ocamlformat} %{read-lines:output_and_check.opts}")))) + +(alias + (name runtest) + (action (diff output_and_check.ref output_and_check.output))) + +(rule + (targets output_several_files.output) + (action + (with-outputs-to %{targets} + (system "! %{bin:ocamlformat} %{read-lines:output_several_files.opts}")))) + +(alias + (name runtest) + (action (diff output_several_files.ref output_several_files.output))) + +(rule + (targets stdin_and_file.output) + (action + (with-outputs-to %{targets} + (system "! %{bin:ocamlformat} %{read-lines:stdin_and_file.opts}")))) + +(alias + (name runtest) + (action (diff stdin_and_file.ref stdin_and_file.output))) + +(rule + (targets stdin_and_inplace.output) + (action + (with-outputs-to %{targets} + (system "! %{bin:ocamlformat} %{read-lines:stdin_and_inplace.opts}")))) + +(alias + (name runtest) + (action (diff stdin_and_inplace.ref stdin_and_inplace.output))) + +(rule + (targets stdin_no_kind.output) + (action + (with-outputs-to %{targets} + (system "! %{bin:ocamlformat} %{read-lines:stdin_no_kind.opts}")))) + +(alias + (name runtest) + (action (diff stdin_no_kind.ref stdin_no_kind.output))) diff --git a/test/cli/inplace_and_check.opts b/test/cli/inplace_and_check.opts new file mode 100644 index 0000000000..3506fed9bd --- /dev/null +++ b/test/cli/inplace_and_check.opts @@ -0,0 +1 @@ +--inplace --check sample/a.ml diff --git a/test/cli/inplace_and_check.ref b/test/cli/inplace_and_check.ref new file mode 100644 index 0000000000..d02df733fc --- /dev/null +++ b/test/cli/inplace_and_check.ref @@ -0,0 +1 @@ +ocamlformat: Cannot specify --inplace with --check diff --git a/test/cli/inplace_and_check.should-fail b/test/cli/inplace_and_check.should-fail new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/cli/inplace_and_output.opts b/test/cli/inplace_and_output.opts new file mode 100644 index 0000000000..a4edab7c55 --- /dev/null +++ b/test/cli/inplace_and_output.opts @@ -0,0 +1 @@ +--inplace --output o.ml sample/a.ml diff --git a/test/cli/inplace_and_output.ref b/test/cli/inplace_and_output.ref new file mode 100644 index 0000000000..eab3df1da6 --- /dev/null +++ b/test/cli/inplace_and_output.ref @@ -0,0 +1 @@ +ocamlformat: Cannot specify --output with --inplace diff --git a/test/cli/inplace_and_output.should-fail b/test/cli/inplace_and_output.should-fail new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/cli/output_and_check.opts b/test/cli/output_and_check.opts new file mode 100644 index 0000000000..0f5ea082d4 --- /dev/null +++ b/test/cli/output_and_check.opts @@ -0,0 +1 @@ +--output x.ml --check sample/a.ml diff --git a/test/cli/output_and_check.ref b/test/cli/output_and_check.ref new file mode 100644 index 0000000000..d5ddb63fd2 --- /dev/null +++ b/test/cli/output_and_check.ref @@ -0,0 +1 @@ +ocamlformat: Cannot specify --output with --check diff --git a/test/cli/output_and_check.should-fail b/test/cli/output_and_check.should-fail new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/cli/output_several_files.opts b/test/cli/output_several_files.opts new file mode 100644 index 0000000000..5bf5068a24 --- /dev/null +++ b/test/cli/output_several_files.opts @@ -0,0 +1 @@ +--output x.ml sample/a.ml sample/b.ml diff --git a/test/cli/output_several_files.ref b/test/cli/output_several_files.ref new file mode 100644 index 0000000000..8231c3424e --- /dev/null +++ b/test/cli/output_several_files.ref @@ -0,0 +1 @@ +ocamlformat: Must specify exactly one input file without --inplace or --check diff --git a/test/cli/output_several_files.should-fail b/test/cli/output_several_files.should-fail new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/cli/sample/a.ml b/test/cli/sample/a.ml new file mode 100644 index 0000000000..e4a4afaa45 --- /dev/null +++ b/test/cli/sample/a.ml @@ -0,0 +1 @@ +let x = "Hello World" diff --git a/test/cli/sample/b.ml b/test/cli/sample/b.ml new file mode 100644 index 0000000000..7572c13af9 --- /dev/null +++ b/test/cli/sample/b.ml @@ -0,0 +1 @@ +let () = print_endline A.x diff --git a/test/cli/stdin_and_file.opts b/test/cli/stdin_and_file.opts new file mode 100644 index 0000000000..21a99e0df7 --- /dev/null +++ b/test/cli/stdin_and_file.opts @@ -0,0 +1 @@ +sample/a.ml - diff --git a/test/cli/stdin_and_file.ref b/test/cli/stdin_and_file.ref new file mode 100644 index 0000000000..8e45bd830d --- /dev/null +++ b/test/cli/stdin_and_file.ref @@ -0,0 +1 @@ +ocamlformat: Cannot specify stdin together with other inputs diff --git a/test/cli/stdin_and_file.should-fail b/test/cli/stdin_and_file.should-fail new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/cli/stdin_and_inplace.opts b/test/cli/stdin_and_inplace.opts new file mode 100644 index 0000000000..969edf8227 --- /dev/null +++ b/test/cli/stdin_and_inplace.opts @@ -0,0 +1 @@ +--inplace - diff --git a/test/cli/stdin_and_inplace.ref b/test/cli/stdin_and_inplace.ref new file mode 100644 index 0000000000..7ad1eb3bb9 --- /dev/null +++ b/test/cli/stdin_and_inplace.ref @@ -0,0 +1 @@ +ocamlformat: Must specify at least one of --impl, --intf or --use-file when reading from stdin diff --git a/test/cli/stdin_and_inplace.should-fail b/test/cli/stdin_and_inplace.should-fail new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/cli/stdin_no_kind.opts b/test/cli/stdin_no_kind.opts new file mode 100644 index 0000000000..39cdd0ded6 --- /dev/null +++ b/test/cli/stdin_no_kind.opts @@ -0,0 +1 @@ +- diff --git a/test/cli/stdin_no_kind.ref b/test/cli/stdin_no_kind.ref new file mode 100644 index 0000000000..7ad1eb3bb9 --- /dev/null +++ b/test/cli/stdin_no_kind.ref @@ -0,0 +1 @@ +ocamlformat: Must specify at least one of --impl, --intf or --use-file when reading from stdin diff --git a/test/cli/stdin_no_kind.should-fail b/test/cli/stdin_no_kind.should-fail new file mode 100644 index 0000000000..e69de29bb2 From 6101d5b1a855b617e519b75c7b9629e33ed94730 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 4 Nov 2019 11:49:38 +0100 Subject: [PATCH 4/7] Handle .stdin file --- test/cli/gen/gen.ml | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/test/cli/gen/gen.ml b/test/cli/gen/gen.ml index 2ef545dd83..0d56b73221 100644 --- a/test/cli/gen/gen.ml +++ b/test/cli/gen/gen.ml @@ -3,12 +3,14 @@ module StringMap = Map.Make (String) type entry = { has_ref : bool; has_opts : bool; + has_stdin : bool; should_fail : bool } let empty_entry = { has_ref = false; has_opts = false; + has_stdin = false; should_fail = false; } @@ -25,6 +27,8 @@ let register_file entries fname = update_or_add test_name ~f:(fun e -> { e with has_opts = true }) | [ test_name; "should-fail" ] -> update_or_add test_name ~f:(fun e -> { e with should_fail = true }) + | [ test_name; "stdin" ] -> + update_or_add test_name ~f:(fun e -> { e with has_stdin = true }) | _ -> entries @@ -39,19 +43,25 @@ let check_test test_name entry ok = let emit_test test_name entry = let cmd_prefix = if entry.should_fail then "! " else "" in - Printf.printf {| -(rule - (targets %s.output) - (action - (with-outputs-to %%{targets} - (system "%s%%{bin:ocamlformat} %%{read-lines:%s.opts}")))) - -(alias - (name runtest) - (action (diff %s.ref %s.output))) -|} - test_name cmd_prefix test_name - test_name test_name + let run_action pf () = + Format.fprintf pf "(with-outputs-to %%{targets}@\n (system \"%s%%{bin:ocamlformat} %%{read-lines:%s.opts}\"))" + cmd_prefix test_name + in + let wrap_stdin action pf () = + Format.fprintf pf "(with-stdin-from %s.stdin@\n @[%a@])" test_name action () + in + let action = if entry.has_stdin then wrap_stdin run_action else run_action in + Format.printf {| +(rule@ + (targets %s.output)@ + (action@ + @[%a@]))@ +|} test_name action (); + Format.printf {| +(alias@ + (name runtest)@ + (action (diff %s.ref %s.output)))@ +|} test_name test_name let () = let files = Sys.readdir "." in From 1a6fca85bc7ef815887646a41d03c6f26f373132 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 4 Nov 2019 12:05:13 +0100 Subject: [PATCH 5/7] (with-stdin-from) is not available --- test/cli/dune.inc | 10 ++++++++++ test/cli/gen/gen.ml | 13 +++++-------- test/cli/stdin.opts | 1 + test/cli/stdin.ref | 1 + test/cli/stdin.stdin | 1 + 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 test/cli/stdin.opts create mode 100644 test/cli/stdin.ref create mode 120000 test/cli/stdin.stdin diff --git a/test/cli/dune.inc b/test/cli/dune.inc index 13fcb900ac..8cd227b0f2 100644 --- a/test/cli/dune.inc +++ b/test/cli/dune.inc @@ -59,6 +59,16 @@ (name runtest) (action (diff output_several_files.ref output_several_files.output))) +(rule + (targets stdin.output) + (action + (with-outputs-to %{targets} + (system "%{bin:ocamlformat} %{read-lines:stdin.opts} < stdin.stdin")))) + +(alias + (name runtest) + (action (diff stdin.ref stdin.output))) + (rule (targets stdin_and_file.output) (action diff --git a/test/cli/gen/gen.ml b/test/cli/gen/gen.ml index 0d56b73221..0f7c0bfb27 100644 --- a/test/cli/gen/gen.ml +++ b/test/cli/gen/gen.ml @@ -42,21 +42,18 @@ let check_test test_name entry ok = ok let emit_test test_name entry = - let cmd_prefix = if entry.should_fail then "! " else "" in + let bang pf b = if b then Format.fprintf pf "! " else () in + let redir_in pf b = if b then Format.fprintf pf " < %s.stdin" test_name else () in let run_action pf () = - Format.fprintf pf "(with-outputs-to %%{targets}@\n (system \"%s%%{bin:ocamlformat} %%{read-lines:%s.opts}\"))" - cmd_prefix test_name + Format.fprintf pf "(with-outputs-to %%{targets}@\n (system \"%a%%{bin:ocamlformat} %%{read-lines:%s.opts}%a\"))" + bang entry.should_fail test_name redir_in entry.has_stdin in - let wrap_stdin action pf () = - Format.fprintf pf "(with-stdin-from %s.stdin@\n @[%a@])" test_name action () - in - let action = if entry.has_stdin then wrap_stdin run_action else run_action in Format.printf {| (rule@ (targets %s.output)@ (action@ @[%a@]))@ -|} test_name action (); +|} test_name run_action (); Format.printf {| (alias@ (name runtest)@ diff --git a/test/cli/stdin.opts b/test/cli/stdin.opts new file mode 100644 index 0000000000..f5e9fd6ddc --- /dev/null +++ b/test/cli/stdin.opts @@ -0,0 +1 @@ +--impl - diff --git a/test/cli/stdin.ref b/test/cli/stdin.ref new file mode 100644 index 0000000000..7572c13af9 --- /dev/null +++ b/test/cli/stdin.ref @@ -0,0 +1 @@ +let () = print_endline A.x diff --git a/test/cli/stdin.stdin b/test/cli/stdin.stdin new file mode 120000 index 0000000000..04b0bf39e8 --- /dev/null +++ b/test/cli/stdin.stdin @@ -0,0 +1 @@ +sample/b.ml \ No newline at end of file From 2438be4b94612d3095ea024f4ddc4b8600e58822 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 4 Nov 2019 12:07:43 +0100 Subject: [PATCH 6/7] Prefix error tests with "err_" --- test/cli/dune.inc | 60 +++++++++---------- ...ile.opts => err_default_several_file.opts} | 0 ..._file.ref => err_default_several_file.ref} | 0 ...l => err_default_several_file.should-fail} | 0 ..._check.opts => err_inplace_and_check.opts} | 0 ...nd_check.ref => err_inplace_and_check.ref} | 0 ...fail => err_inplace_and_check.should-fail} | 0 ...utput.opts => err_inplace_and_output.opts} | 0 ..._output.ref => err_inplace_and_output.ref} | 0 ...ail => err_inplace_and_output.should-fail} | 0 test/cli/{no_arg.opts => err_no_arg.opts} | 0 test/cli/{no_arg.ref => err_no_arg.ref} | 0 ...arg.should-fail => err_no_arg.should-fail} | 0 ...d_check.opts => err_output_and_check.opts} | 0 ...and_check.ref => err_output_and_check.ref} | 0 ...-fail => err_output_and_check.should-fail} | 0 ...les.opts => err_output_several_files.opts} | 0 ...files.ref => err_output_several_files.ref} | 0 ...l => err_output_several_files.should-fail} | 0 ..._and_file.opts => err_stdin_and_file.opts} | 0 ...in_and_file.ref => err_stdin_and_file.ref} | 0 ...ld-fail => err_stdin_and_file.should-fail} | 0 ...nplace.opts => err_stdin_and_inplace.opts} | 0 ..._inplace.ref => err_stdin_and_inplace.ref} | 0 ...fail => err_stdin_and_inplace.should-fail} | 0 ...in_no_kind.opts => err_stdin_no_kind.opts} | 0 ...tdin_no_kind.ref => err_stdin_no_kind.ref} | 0 ...uld-fail => err_stdin_no_kind.should-fail} | 0 test/cli/{stdin.opts => stdin_and_impl.opts} | 0 test/cli/{stdin.ref => stdin_and_impl.ref} | 0 .../cli/{stdin.stdin => stdin_and_impl.stdin} | 0 31 files changed, 30 insertions(+), 30 deletions(-) rename test/cli/{default_several_file.opts => err_default_several_file.opts} (100%) rename test/cli/{default_several_file.ref => err_default_several_file.ref} (100%) rename test/cli/{default_several_file.should-fail => err_default_several_file.should-fail} (100%) rename test/cli/{inplace_and_check.opts => err_inplace_and_check.opts} (100%) rename test/cli/{inplace_and_check.ref => err_inplace_and_check.ref} (100%) rename test/cli/{inplace_and_check.should-fail => err_inplace_and_check.should-fail} (100%) rename test/cli/{inplace_and_output.opts => err_inplace_and_output.opts} (100%) rename test/cli/{inplace_and_output.ref => err_inplace_and_output.ref} (100%) rename test/cli/{inplace_and_output.should-fail => err_inplace_and_output.should-fail} (100%) rename test/cli/{no_arg.opts => err_no_arg.opts} (100%) rename test/cli/{no_arg.ref => err_no_arg.ref} (100%) rename test/cli/{no_arg.should-fail => err_no_arg.should-fail} (100%) rename test/cli/{output_and_check.opts => err_output_and_check.opts} (100%) rename test/cli/{output_and_check.ref => err_output_and_check.ref} (100%) rename test/cli/{output_and_check.should-fail => err_output_and_check.should-fail} (100%) rename test/cli/{output_several_files.opts => err_output_several_files.opts} (100%) rename test/cli/{output_several_files.ref => err_output_several_files.ref} (100%) rename test/cli/{output_several_files.should-fail => err_output_several_files.should-fail} (100%) rename test/cli/{stdin_and_file.opts => err_stdin_and_file.opts} (100%) rename test/cli/{stdin_and_file.ref => err_stdin_and_file.ref} (100%) rename test/cli/{stdin_and_file.should-fail => err_stdin_and_file.should-fail} (100%) rename test/cli/{stdin_and_inplace.opts => err_stdin_and_inplace.opts} (100%) rename test/cli/{stdin_and_inplace.ref => err_stdin_and_inplace.ref} (100%) rename test/cli/{stdin_and_inplace.should-fail => err_stdin_and_inplace.should-fail} (100%) rename test/cli/{stdin_no_kind.opts => err_stdin_no_kind.opts} (100%) rename test/cli/{stdin_no_kind.ref => err_stdin_no_kind.ref} (100%) rename test/cli/{stdin_no_kind.should-fail => err_stdin_no_kind.should-fail} (100%) rename test/cli/{stdin.opts => stdin_and_impl.opts} (100%) rename test/cli/{stdin.ref => stdin_and_impl.ref} (100%) rename test/cli/{stdin.stdin => stdin_and_impl.stdin} (100%) diff --git a/test/cli/dune.inc b/test/cli/dune.inc index 8cd227b0f2..ce99519b57 100644 --- a/test/cli/dune.inc +++ b/test/cli/dune.inc @@ -1,100 +1,100 @@ (rule - (targets default_several_file.output) + (targets err_default_several_file.output) (action (with-outputs-to %{targets} - (system "! %{bin:ocamlformat} %{read-lines:default_several_file.opts}")))) + (system "! %{bin:ocamlformat} %{read-lines:err_default_several_file.opts}")))) (alias (name runtest) - (action (diff default_several_file.ref default_several_file.output))) + (action (diff err_default_several_file.ref err_default_several_file.output))) (rule - (targets inplace_and_check.output) + (targets err_inplace_and_check.output) (action (with-outputs-to %{targets} - (system "! %{bin:ocamlformat} %{read-lines:inplace_and_check.opts}")))) + (system "! %{bin:ocamlformat} %{read-lines:err_inplace_and_check.opts}")))) (alias (name runtest) - (action (diff inplace_and_check.ref inplace_and_check.output))) + (action (diff err_inplace_and_check.ref err_inplace_and_check.output))) (rule - (targets inplace_and_output.output) + (targets err_inplace_and_output.output) (action (with-outputs-to %{targets} - (system "! %{bin:ocamlformat} %{read-lines:inplace_and_output.opts}")))) + (system "! %{bin:ocamlformat} %{read-lines:err_inplace_and_output.opts}")))) (alias (name runtest) - (action (diff inplace_and_output.ref inplace_and_output.output))) + (action (diff err_inplace_and_output.ref err_inplace_and_output.output))) (rule - (targets no_arg.output) + (targets err_no_arg.output) (action (with-outputs-to %{targets} - (system "! %{bin:ocamlformat} %{read-lines:no_arg.opts}")))) + (system "! %{bin:ocamlformat} %{read-lines:err_no_arg.opts}")))) (alias (name runtest) - (action (diff no_arg.ref no_arg.output))) + (action (diff err_no_arg.ref err_no_arg.output))) (rule - (targets output_and_check.output) + (targets err_output_and_check.output) (action (with-outputs-to %{targets} - (system "! %{bin:ocamlformat} %{read-lines:output_and_check.opts}")))) + (system "! %{bin:ocamlformat} %{read-lines:err_output_and_check.opts}")))) (alias (name runtest) - (action (diff output_and_check.ref output_and_check.output))) + (action (diff err_output_and_check.ref err_output_and_check.output))) (rule - (targets output_several_files.output) + (targets err_output_several_files.output) (action (with-outputs-to %{targets} - (system "! %{bin:ocamlformat} %{read-lines:output_several_files.opts}")))) + (system "! %{bin:ocamlformat} %{read-lines:err_output_several_files.opts}")))) (alias (name runtest) - (action (diff output_several_files.ref output_several_files.output))) + (action (diff err_output_several_files.ref err_output_several_files.output))) (rule - (targets stdin.output) + (targets err_stdin_and_file.output) (action (with-outputs-to %{targets} - (system "%{bin:ocamlformat} %{read-lines:stdin.opts} < stdin.stdin")))) + (system "! %{bin:ocamlformat} %{read-lines:err_stdin_and_file.opts}")))) (alias (name runtest) - (action (diff stdin.ref stdin.output))) + (action (diff err_stdin_and_file.ref err_stdin_and_file.output))) (rule - (targets stdin_and_file.output) + (targets err_stdin_and_inplace.output) (action (with-outputs-to %{targets} - (system "! %{bin:ocamlformat} %{read-lines:stdin_and_file.opts}")))) + (system "! %{bin:ocamlformat} %{read-lines:err_stdin_and_inplace.opts}")))) (alias (name runtest) - (action (diff stdin_and_file.ref stdin_and_file.output))) + (action (diff err_stdin_and_inplace.ref err_stdin_and_inplace.output))) (rule - (targets stdin_and_inplace.output) + (targets err_stdin_no_kind.output) (action (with-outputs-to %{targets} - (system "! %{bin:ocamlformat} %{read-lines:stdin_and_inplace.opts}")))) + (system "! %{bin:ocamlformat} %{read-lines:err_stdin_no_kind.opts}")))) (alias (name runtest) - (action (diff stdin_and_inplace.ref stdin_and_inplace.output))) + (action (diff err_stdin_no_kind.ref err_stdin_no_kind.output))) (rule - (targets stdin_no_kind.output) + (targets stdin_and_impl.output) (action (with-outputs-to %{targets} - (system "! %{bin:ocamlformat} %{read-lines:stdin_no_kind.opts}")))) + (system "%{bin:ocamlformat} %{read-lines:stdin_and_impl.opts} < stdin_and_impl.stdin")))) (alias (name runtest) - (action (diff stdin_no_kind.ref stdin_no_kind.output))) + (action (diff stdin_and_impl.ref stdin_and_impl.output))) diff --git a/test/cli/default_several_file.opts b/test/cli/err_default_several_file.opts similarity index 100% rename from test/cli/default_several_file.opts rename to test/cli/err_default_several_file.opts diff --git a/test/cli/default_several_file.ref b/test/cli/err_default_several_file.ref similarity index 100% rename from test/cli/default_several_file.ref rename to test/cli/err_default_several_file.ref diff --git a/test/cli/default_several_file.should-fail b/test/cli/err_default_several_file.should-fail similarity index 100% rename from test/cli/default_several_file.should-fail rename to test/cli/err_default_several_file.should-fail diff --git a/test/cli/inplace_and_check.opts b/test/cli/err_inplace_and_check.opts similarity index 100% rename from test/cli/inplace_and_check.opts rename to test/cli/err_inplace_and_check.opts diff --git a/test/cli/inplace_and_check.ref b/test/cli/err_inplace_and_check.ref similarity index 100% rename from test/cli/inplace_and_check.ref rename to test/cli/err_inplace_and_check.ref diff --git a/test/cli/inplace_and_check.should-fail b/test/cli/err_inplace_and_check.should-fail similarity index 100% rename from test/cli/inplace_and_check.should-fail rename to test/cli/err_inplace_and_check.should-fail diff --git a/test/cli/inplace_and_output.opts b/test/cli/err_inplace_and_output.opts similarity index 100% rename from test/cli/inplace_and_output.opts rename to test/cli/err_inplace_and_output.opts diff --git a/test/cli/inplace_and_output.ref b/test/cli/err_inplace_and_output.ref similarity index 100% rename from test/cli/inplace_and_output.ref rename to test/cli/err_inplace_and_output.ref diff --git a/test/cli/inplace_and_output.should-fail b/test/cli/err_inplace_and_output.should-fail similarity index 100% rename from test/cli/inplace_and_output.should-fail rename to test/cli/err_inplace_and_output.should-fail diff --git a/test/cli/no_arg.opts b/test/cli/err_no_arg.opts similarity index 100% rename from test/cli/no_arg.opts rename to test/cli/err_no_arg.opts diff --git a/test/cli/no_arg.ref b/test/cli/err_no_arg.ref similarity index 100% rename from test/cli/no_arg.ref rename to test/cli/err_no_arg.ref diff --git a/test/cli/no_arg.should-fail b/test/cli/err_no_arg.should-fail similarity index 100% rename from test/cli/no_arg.should-fail rename to test/cli/err_no_arg.should-fail diff --git a/test/cli/output_and_check.opts b/test/cli/err_output_and_check.opts similarity index 100% rename from test/cli/output_and_check.opts rename to test/cli/err_output_and_check.opts diff --git a/test/cli/output_and_check.ref b/test/cli/err_output_and_check.ref similarity index 100% rename from test/cli/output_and_check.ref rename to test/cli/err_output_and_check.ref diff --git a/test/cli/output_and_check.should-fail b/test/cli/err_output_and_check.should-fail similarity index 100% rename from test/cli/output_and_check.should-fail rename to test/cli/err_output_and_check.should-fail diff --git a/test/cli/output_several_files.opts b/test/cli/err_output_several_files.opts similarity index 100% rename from test/cli/output_several_files.opts rename to test/cli/err_output_several_files.opts diff --git a/test/cli/output_several_files.ref b/test/cli/err_output_several_files.ref similarity index 100% rename from test/cli/output_several_files.ref rename to test/cli/err_output_several_files.ref diff --git a/test/cli/output_several_files.should-fail b/test/cli/err_output_several_files.should-fail similarity index 100% rename from test/cli/output_several_files.should-fail rename to test/cli/err_output_several_files.should-fail diff --git a/test/cli/stdin_and_file.opts b/test/cli/err_stdin_and_file.opts similarity index 100% rename from test/cli/stdin_and_file.opts rename to test/cli/err_stdin_and_file.opts diff --git a/test/cli/stdin_and_file.ref b/test/cli/err_stdin_and_file.ref similarity index 100% rename from test/cli/stdin_and_file.ref rename to test/cli/err_stdin_and_file.ref diff --git a/test/cli/stdin_and_file.should-fail b/test/cli/err_stdin_and_file.should-fail similarity index 100% rename from test/cli/stdin_and_file.should-fail rename to test/cli/err_stdin_and_file.should-fail diff --git a/test/cli/stdin_and_inplace.opts b/test/cli/err_stdin_and_inplace.opts similarity index 100% rename from test/cli/stdin_and_inplace.opts rename to test/cli/err_stdin_and_inplace.opts diff --git a/test/cli/stdin_and_inplace.ref b/test/cli/err_stdin_and_inplace.ref similarity index 100% rename from test/cli/stdin_and_inplace.ref rename to test/cli/err_stdin_and_inplace.ref diff --git a/test/cli/stdin_and_inplace.should-fail b/test/cli/err_stdin_and_inplace.should-fail similarity index 100% rename from test/cli/stdin_and_inplace.should-fail rename to test/cli/err_stdin_and_inplace.should-fail diff --git a/test/cli/stdin_no_kind.opts b/test/cli/err_stdin_no_kind.opts similarity index 100% rename from test/cli/stdin_no_kind.opts rename to test/cli/err_stdin_no_kind.opts diff --git a/test/cli/stdin_no_kind.ref b/test/cli/err_stdin_no_kind.ref similarity index 100% rename from test/cli/stdin_no_kind.ref rename to test/cli/err_stdin_no_kind.ref diff --git a/test/cli/stdin_no_kind.should-fail b/test/cli/err_stdin_no_kind.should-fail similarity index 100% rename from test/cli/stdin_no_kind.should-fail rename to test/cli/err_stdin_no_kind.should-fail diff --git a/test/cli/stdin.opts b/test/cli/stdin_and_impl.opts similarity index 100% rename from test/cli/stdin.opts rename to test/cli/stdin_and_impl.opts diff --git a/test/cli/stdin.ref b/test/cli/stdin_and_impl.ref similarity index 100% rename from test/cli/stdin.ref rename to test/cli/stdin_and_impl.ref diff --git a/test/cli/stdin.stdin b/test/cli/stdin_and_impl.stdin similarity index 100% rename from test/cli/stdin.stdin rename to test/cli/stdin_and_impl.stdin From df847c811043ce2ada86714e03bc864bbb6fc1ad Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 4 Nov 2019 12:11:46 +0100 Subject: [PATCH 7/7] Add stdin_and_intf test --- test/cli/dune.inc | 10 ++++++++++ test/cli/sample/a.mli | 1 + test/cli/stdin_and_intf.opts | 1 + test/cli/stdin_and_intf.ref | 1 + test/cli/stdin_and_intf.stdin | 1 + 5 files changed, 14 insertions(+) create mode 100644 test/cli/sample/a.mli create mode 100644 test/cli/stdin_and_intf.opts create mode 100644 test/cli/stdin_and_intf.ref create mode 120000 test/cli/stdin_and_intf.stdin diff --git a/test/cli/dune.inc b/test/cli/dune.inc index ce99519b57..d0347b335e 100644 --- a/test/cli/dune.inc +++ b/test/cli/dune.inc @@ -98,3 +98,13 @@ (alias (name runtest) (action (diff stdin_and_impl.ref stdin_and_impl.output))) + +(rule + (targets stdin_and_intf.output) + (action + (with-outputs-to %{targets} + (system "%{bin:ocamlformat} %{read-lines:stdin_and_intf.opts} < stdin_and_intf.stdin")))) + +(alias + (name runtest) + (action (diff stdin_and_intf.ref stdin_and_intf.output))) diff --git a/test/cli/sample/a.mli b/test/cli/sample/a.mli new file mode 100644 index 0000000000..66e8138932 --- /dev/null +++ b/test/cli/sample/a.mli @@ -0,0 +1 @@ +val x : string diff --git a/test/cli/stdin_and_intf.opts b/test/cli/stdin_and_intf.opts new file mode 100644 index 0000000000..b42b0826cf --- /dev/null +++ b/test/cli/stdin_and_intf.opts @@ -0,0 +1 @@ +--intf - diff --git a/test/cli/stdin_and_intf.ref b/test/cli/stdin_and_intf.ref new file mode 100644 index 0000000000..66e8138932 --- /dev/null +++ b/test/cli/stdin_and_intf.ref @@ -0,0 +1 @@ +val x : string diff --git a/test/cli/stdin_and_intf.stdin b/test/cli/stdin_and_intf.stdin new file mode 120000 index 0000000000..9222cb771f --- /dev/null +++ b/test/cli/stdin_and_intf.stdin @@ -0,0 +1 @@ +sample/a.mli \ No newline at end of file