File tree Expand file tree Collapse file tree 4 files changed +30
-2
lines changed
Expand file tree Collapse file tree 4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ Run `make .merlin` to create the `.merlin` file.
5151
5252 Test cases cannot be nested.
5353
54- - ` CWEndTest ` .
54+ - ` CWEndTest `
5555
5656 Ends a test case. This command is optional before ` CWTest ` and ` CWEndGroup ` .
5757
Original file line number Diff line number Diff line change 11open Pp
22
33let solution_file = " /workspace/Solution.v"
4+ let ocaml_compiler = " ocamlopt"
5+ let driver_file = " driver.ml"
46
57let format_msg =
68 let re = Str. regexp_string " \n " in
@@ -134,3 +136,21 @@ let test_file_regex ?(fname = solution_file) match_flag regex =
134136 failed " Bad match" ;
135137 CErrors. user_err (str " Bad match" )
136138 end
139+
140+ let run_system_command args =
141+ let cmd = String. concat " " args in
142+ Printf. printf " Running: %s" cmd;
143+ match Unix. system cmd with
144+ | Unix. WEXITED 0 -> passed " OK"
145+ | _ -> failed " Failed"
146+
147+ let write_file fname str =
148+ let oc = open_out fname in
149+ Printf. fprintf oc " %s" str;
150+ close_out oc
151+
152+ let compile_and_run files ?(options = " " ) driver_code =
153+ write_file driver_file driver_code;
154+ run_system_command ([ocaml_compiler; options] @ files @ [driver_file]);
155+ run_system_command [" ./a.out" ];
156+ passed " OK"
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ val test_file_size : ?fname:string -> int -> unit
66
77val test_file_regex : ?fname : string -> bool -> string -> unit
88
9+ val compile_and_run : string list -> ?options : string -> string -> unit
10+
911val begin_group : string -> string -> unit
1012
1113val end_group : string -> unit
Original file line number Diff line number Diff line change @@ -54,4 +54,10 @@ VERNAC COMMAND EXTEND CWFileNegMatch CLASSIFIED AS QUERY
5454| [ " CWFile" string_opt(fname) " Does" " Not" " Match" string (regex)] -> [
5555 Coq_cw. test_file_regex ?fname false regex
5656 ]
57- END
57+ END
58+
59+ VERNAC COMMAND EXTEND CWCompileAndRun CLASSIFIED AS SIDEFF
60+ | [ " CWCompileAndRun" string_list(files) " Options" string_opt(options) " Driver" string (driver) ] -> [
61+ Coq_cw. compile_and_run files ?options driver
62+ ]
63+ END
You can’t perform that action at this time.
0 commit comments