Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI tests: use dune to run ocamlformat #1157

Merged
merged 1 commit into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
+ Refactor code that interprets CLI options (#1127, #1156) (Jules Aguillon)
+ Testing interactions between break-infix and break-infix-before-func (#1136) (Guillaume Petiot)
+ Add dune to repositories checked for regressions (#1129) (Jules Aguillon)
+ Use an expect test for cli tests (#1126) (Etienne Millon)
+ Remove the test generator for cli tests (#1126, #1157) (Etienne Millon)
+ Factor out a private library (#1134, #1148) (Etienne Millon)
+ Remove global reference `Cmts.remove` (#1142) (Etienne Millon)
+ Remove symbol strings in `Cmts` (#1146) (Etienne Millon)
Expand Down
6 changes: 0 additions & 6 deletions test/cli/.ocamlformat

This file was deleted.

254 changes: 249 additions & 5 deletions test/cli/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,249 @@
(test
(name test_cli)
(libraries unix stdio)
(deps .ocamlformat (glob_files sample/*))
(action (run %{test} %{bin:ocamlformat})))
(rule
(with-outputs-to
err_default_several_file.output
(system "! %{bin:ocamlformat} %{dep:sample/a.ml} %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff err_default_several_file.expected err_default_several_file.output)))

(rule
(with-outputs-to
err_inplace_and_check.output
(system "! %{bin:ocamlformat} --inplace --check %{dep:sample/a.ml}")))

(alias
(name runtest)
(action
(diff err_inplace_and_check.expected err_inplace_and_check.output)))

(rule
(with-outputs-to
err_inplace_and_output.output
(system "! %{bin:ocamlformat} --inplace --output o.ml %{dep:sample/a.ml}")))

(alias
(name runtest)
(action
(diff err_inplace_and_output.expected err_inplace_and_output.output)))

(rule
(with-outputs-to
err_no_arg.output
(system "! %{bin:ocamlformat}")))

(alias
(name runtest)
(action
(diff err_no_arg.expected err_no_arg.output)))

(rule
(with-outputs-to
err_output_and_check.output
(system "! %{bin:ocamlformat} --output x.ml --check %{dep:sample/a.ml}")))

(alias
(name runtest)
(action
(diff err_output_and_check.expected err_output_and_check.output)))

(rule
(with-outputs-to
err_output_several_files.output
(system
"! %{bin:ocamlformat} --output x.ml %{dep:sample/a.ml} %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff err_output_several_files.expected err_output_several_files.output)))

(rule
(with-outputs-to
err_stdin_and_file.output
(system "! %{bin:ocamlformat} %{dep:sample/a.ml} -")))

(alias
(name runtest)
(action
(diff err_stdin_and_file.expected err_stdin_and_file.output)))

(rule
(with-outputs-to
err_stdin_and_inplace.output
(system "! %{bin:ocamlformat} --inplace -")))

(alias
(name runtest)
(action
(diff err_stdin_and_inplace.expected err_stdin_and_inplace.output)))

(rule
(with-outputs-to
err_stdin_no_kind.output
(system "! %{bin:ocamlformat} -")))

(alias
(name runtest)
(action
(diff err_stdin_no_kind.expected err_stdin_no_kind.output)))

(rule
(with-outputs-to
stdin_and_impl.output
(system "%{bin:ocamlformat} --impl - < %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff stdin_and_impl.expected stdin_and_impl.output)))

(rule
(with-outputs-to
stdin_and_intf.output
(system "%{bin:ocamlformat} --intf - < %{dep:sample/a.mli}")))

(alias
(name runtest)
(action
(diff stdin_and_intf.expected stdin_and_intf.output)))

(rule
(with-outputs-to
stdin_and_name.output
(system "%{bin:ocamlformat} --name a.ml - < %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff stdin_and_name.expected stdin_and_name.output)))

(rule
(with-outputs-to
name_unknown_ext.output
(system "%{bin:ocamlformat} --name b.cpp %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff name_unknown_ext.expected name_unknown_ext.output)))

(rule
(with-outputs-to
err_stdin_name_unknown_ext.output
(system "! %{bin:ocamlformat} --name b.cpp - < %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff err_stdin_name_unknown_ext.expected err_stdin_name_unknown_ext.output)))

(rule
(with-outputs-to
err_several_files_and_kind.output
(system
"! %{bin:ocamlformat} --impl --check %{dep:sample/a.mli} %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff err_several_files_and_kind.expected err_several_files_and_kind.output)))

(rule
(with-outputs-to
err_several_files_and_name.output
(system
"! %{bin:ocamlformat} --name foo.ml --check %{dep:sample/a.mli} %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff err_several_files_and_name.expected err_several_files_and_name.output)))

(rule
(with-outputs-to
err_several_files_and_kind_inplace.output
(system
"! %{bin:ocamlformat} --impl --check %{dep:sample/a.mli} %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff err_several_files_and_kind_inplace.expected
err_several_files_and_kind_inplace.output)))

(rule
(with-outputs-to
err_several_files_and_name_inplace.output
(system
"! %{bin:ocamlformat} --name foo.ml --check %{dep:sample/a.mli} %{dep:sample/b.ml}")))

(alias
(name runtest)
(action
(diff err_several_files_and_name_inplace.expected
err_several_files_and_name_inplace.output)))

(rule
(with-outputs-to
fmterr_file_and_name.output
(system "! %{bin:ocamlformat} --name foo.ml %{dep:sample/syntax_error.ml}")))

(alias
(name runtest)
(action
(diff fmterr_file_and_name.expected fmterr_file_and_name.output)))

(rule
(with-outputs-to
fmterr_stdin_and_name.output
(system
"! %{bin:ocamlformat} --name foo.ml - < %{dep:sample/syntax_error.ml}")))

(alias
(name runtest)
(action
(diff fmterr_stdin_and_name.expected fmterr_stdin_and_name.output)))

(rule
(with-outputs-to
fmterr_file_bad_kind.output
(system "! %{bin:ocamlformat} --impl %{dep:sample/a.mli}")))

(alias
(name runtest)
(action
(diff fmterr_file_bad_kind.expected fmterr_file_bad_kind.output)))

(rule
(with-outputs-to
fmterr_stdin_bad_kind.output
(system "! %{bin:ocamlformat} --impl - < %{dep:sample/a.mli}")))

(alias
(name runtest)
(action
(diff fmterr_stdin_bad_kind.expected fmterr_stdin_bad_kind.output)))

(rule
(with-outputs-to
fmterr_file_and_name_bad_kind.output
(system "! %{bin:ocamlformat} --name foo.ml %{dep:sample/a.mli}")))

(alias
(name runtest)
(action
(diff fmterr_file_and_name_bad_kind.expected
fmterr_file_and_name_bad_kind.output)))

(rule
(with-outputs-to
fmterr_stdin_and_name_bad_kind.output
(system "! %{bin:ocamlformat} --name foo.ml - < %{dep:sample/a.mli}")))

(alias
(name runtest)
(action
(diff fmterr_stdin_and_name_bad_kind.expected
fmterr_stdin_and_name_bad_kind.output)))
1 change: 1 addition & 0 deletions test/cli/err_default_several_file.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Must specify exactly one input file without --inplace or --check
1 change: 1 addition & 0 deletions test/cli/err_inplace_and_check.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Cannot specify --inplace with --check
1 change: 1 addition & 0 deletions test/cli/err_inplace_and_output.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Cannot specify --output with --inplace
1 change: 1 addition & 0 deletions test/cli/err_no_arg.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Must specify at least one input file, or `-` for stdin
1 change: 1 addition & 0 deletions test/cli/err_output_and_check.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Cannot specify --output with --check
1 change: 1 addition & 0 deletions test/cli/err_output_several_files.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Must specify exactly one input file without --inplace or --check
1 change: 1 addition & 0 deletions test/cli/err_several_files_and_kind.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Cannot specify --impl or --intf with multiple inputs
1 change: 1 addition & 0 deletions test/cli/err_several_files_and_kind_inplace.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Cannot specify --impl or --intf with multiple inputs
1 change: 1 addition & 0 deletions test/cli/err_several_files_and_name.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Cannot specify --name with multiple inputs
1 change: 1 addition & 0 deletions test/cli/err_several_files_and_name_inplace.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Cannot specify --name with multiple inputs
1 change: 1 addition & 0 deletions test/cli/err_stdin_and_file.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Cannot specify stdin together with other inputs
1 change: 1 addition & 0 deletions test/cli/err_stdin_and_inplace.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Must specify at least one of --name, --impl or --intf when reading from stdin
1 change: 1 addition & 0 deletions test/cli/err_stdin_name_unknown_ext.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Cannot deduce file kind from passed --name. Please specify --impl or --intf
1 change: 1 addition & 0 deletions test/cli/err_stdin_no_kind.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocamlformat: Must specify at least one of --name, --impl or --intf when reading from stdin
3 changes: 3 additions & 0 deletions test/cli/fmterr_file_and_name.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ocamlformat: ignoring "foo.ml" (syntax error)
File "foo.ml", line 2, characters 0-0:
Error: Syntax error
3 changes: 3 additions & 0 deletions test/cli/fmterr_file_and_name_bad_kind.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ocamlformat: ignoring "foo.ml" (syntax error)
File "foo.ml", line 5, characters 0-0:
Error: Syntax error
3 changes: 3 additions & 0 deletions test/cli/fmterr_file_bad_kind.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ocamlformat: ignoring "sample/a.mli" (syntax error)
File "sample/a.mli", line 5, characters 0-0:
Error: Syntax error
3 changes: 3 additions & 0 deletions test/cli/fmterr_stdin_and_name.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ocamlformat: ignoring "foo.ml" (syntax error)
File "foo.ml", line 2, characters 0-0:
Error: Syntax error
3 changes: 3 additions & 0 deletions test/cli/fmterr_stdin_and_name_bad_kind.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ocamlformat: ignoring "foo.ml" (syntax error)
File "foo.ml", line 5, characters 0-0:
Error: Syntax error
3 changes: 3 additions & 0 deletions test/cli/fmterr_stdin_bad_kind.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ocamlformat: ignoring "<standard input>" (syntax error)
File "<standard input>", line 5, characters 0-0:
Error: Syntax error
1 change: 1 addition & 0 deletions test/cli/name_unknown_ext.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = print_endline A.x
1 change: 1 addition & 0 deletions test/cli/stdin_and_impl.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = print_endline A.x
4 changes: 4 additions & 0 deletions test/cli/stdin_and_intf.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
val x : string

module X : S
(** Make sure this file cannot be parsed as an impl file *)
1 change: 1 addition & 0 deletions test/cli/stdin_and_name.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = print_endline A.x
Loading