diff --git a/src/examples/dune b/src/examples/dune index 933cb51c..95aaa2eb 100644 --- a/src/examples/dune +++ b/src/examples/dune @@ -4,16 +4,6 @@ (action (run ocaml-protoc --binary --pp --ml_out ./ %{deps}))) -(rule - (alias runtest) - (action - (diff example01.ml.expected example01.ml))) - -(rule - (alias runtest) - (action - (diff example01.mli.expected example01.mli))) - (test (name example01) (modules t_example01 example01) @@ -26,16 +16,6 @@ (action (run ocaml-protoc --pp --ml_out ./ %{deps}))) -(rule - (alias runtest) - (action - (diff example03.ml.expected example03.ml))) - -(rule - (alias runtest) - (action - (diff example03.mli.expected example03.mli))) - (test (name example03) (modules t_example03 example03) @@ -48,16 +28,6 @@ (action (run ocaml-protoc --pp --ml_out ./ %{deps}))) -(rule - (alias runtest) - (action - (diff example04.ml.expected example04.ml))) - -(rule - (alias runtest) - (action - (diff example04.mli.expected example04.mli))) - (test (name example04) (modules t_example04 example04) @@ -70,16 +40,6 @@ (action (run ocaml-protoc --binary --pp --ml_out ./ %{deps}))) -(rule - (alias runtest) - (action - (diff example05.ml.expected example05.ml))) - -(rule - (alias runtest) - (action - (diff example05.mli.expected example05.mli))) - (test (name example05) (modules t_example05 example05) @@ -92,16 +52,6 @@ (action (run ocaml-protoc --binary --pp --yojson --services --ml_out ./ %{deps}))) -(rule - (alias runtest) - (action - (diff calculator.ml.expected calculator.ml))) - -(rule - (alias runtest) - (action - (diff calculator.mli.expected calculator.mli))) - (test (name calculator) (modules t_calculator calculator) @@ -114,16 +64,6 @@ (action (run ocaml-protoc --binary --pp --yojson --services --ml_out ./ %{deps}))) -(rule - (alias runtest) - (action - (diff file_server.ml.expected file_server.ml))) - -(rule - (alias runtest) - (action - (diff file_server.mli.expected file_server.mli))) - (test (name file_server) (modules file_server) ; just check that it compiles @@ -136,18 +76,31 @@ (action (run ocaml-protoc --pp --binary --ml_out ./ %{deps}))) +(test + (name orgchart_ml) + (modules orgchart orgchart_ml) + (package ocaml-protoc) + (libraries pbrt)) + +(include dune.inc) + (rule (alias runtest) (action - (diff orgchart.ml.expected orgchart.ml))) + (diff dune.inc dune.inc.gen))) (rule - (alias runtest) + (deps + (:gen-dune ./gen-dune/main.exe)) (action - (diff orgchart.mli.expected orgchart.mli))) - -(test - (name orgchart_ml) - (modules orgchart orgchart_ml) - (package ocaml-protoc) - (libraries pbrt)) + (with-stdout-to + dune.inc.gen + (run + %{gen-dune} + calculator + example01 + example03 + example04 + example05 + file_server + orgchart)))) diff --git a/src/examples/dune.inc b/src/examples/dune.inc new file mode 100644 index 00000000..98a4e359 --- /dev/null +++ b/src/examples/dune.inc @@ -0,0 +1,71 @@ +; dune file generated by './gen-dune/main.exe' -- do not edit. + +(rule + (alias runtest) + (action + (diff calculator.ml.expected calculator.ml))) + +(rule + (alias runtest) + (action + (diff calculator.mli.expected calculator.mli))) + +(rule + (alias runtest) + (action + (diff example01.ml.expected example01.ml))) + +(rule + (alias runtest) + (action + (diff example01.mli.expected example01.mli))) + +(rule + (alias runtest) + (action + (diff example03.ml.expected example03.ml))) + +(rule + (alias runtest) + (action + (diff example03.mli.expected example03.mli))) + +(rule + (alias runtest) + (action + (diff example04.ml.expected example04.ml))) + +(rule + (alias runtest) + (action + (diff example04.mli.expected example04.mli))) + +(rule + (alias runtest) + (action + (diff example05.ml.expected example05.ml))) + +(rule + (alias runtest) + (action + (diff example05.mli.expected example05.mli))) + +(rule + (alias runtest) + (action + (diff file_server.ml.expected file_server.ml))) + +(rule + (alias runtest) + (action + (diff file_server.mli.expected file_server.mli))) + +(rule + (alias runtest) + (action + (diff orgchart.ml.expected orgchart.ml))) + +(rule + (alias runtest) + (action + (diff orgchart.mli.expected orgchart.mli))) diff --git a/src/examples/gen-dune/dune b/src/examples/gen-dune/dune new file mode 100644 index 00000000..69dd4ade --- /dev/null +++ b/src/examples/gen-dune/dune @@ -0,0 +1,2 @@ +(executable + (name main)) diff --git a/src/examples/gen-dune/main.ml b/src/examples/gen-dune/main.ml new file mode 100644 index 00000000..ddac87a6 --- /dev/null +++ b/src/examples/gen-dune/main.ml @@ -0,0 +1,20 @@ +(* This is a helper program used to generate dune rules that get included to the + parent directory's dune file, via [../dune.inc]. *) + +let () = + Printf.printf + "; dune file generated by './gen-dune/main.exe' -- do not edit.\n"; + Sys.argv |> Array.to_list |> List.tl |> List.sort String.compare + |> List.iter (fun arg -> + List.iter + (fun ext -> + let file = arg ^ ext in + Printf.printf + {| +(rule + (alias runtest) + (action + (diff %s.expected %s))) +|} + file file) + [ ".ml"; ".mli" ])