Skip to content

Commit

Permalink
test lib misc
Browse files Browse the repository at this point in the history
  • Loading branch information
just-max committed Sep 8, 2023
1 parent d678050 commit 697c25c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
15 changes: 0 additions & 15 deletions src/test-lib/grading.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,6 @@ let empty_node ?(attributes = []) label =
(* empty data, otherwise xmlm doesn't (self-)close empty tags! *) (* TODO: is this still an issue? *)
El ((("", label), attributes), [ Data "" ])
let prettify_results_basic fn =
(* reads a whole file from disk as a string *)
let read_file_whole fn =
let ch = open_in_bin fn in
let s = really_input_string ch (in_channel_length ch) in
close_in ch;
s
in
let data = read_file_whole fn in
let data = Str.global_substitute (Str.regexp "<failure[^>]+?>\n?") (Fun.const {|<failure type="assert">|}) data in
let data = Str.global_substitute (Str.regexp "\n*No backtrace.</failure>") (Fun.const "</failure>") data in
let oc = open_out fn in
output_string oc data;
close_out oc
(* TODO: The functionality for extracting test results and for evaluating a grading
scheme should be extracted to separate functions. The former would be useful
to grade test results distributed across multiple files. *)
Expand Down
2 changes: 0 additions & 2 deletions src/test-lib/grading.mli
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ val group :
?skip:string -> ?max_points:int clamp -> string -> grading list -> grading
(** Wrapper for {{!type-grading.Group}[Group]}. *)

val prettify_results_basic : string -> unit

(** Main entry point: [prettify_results ~grading file_name] reads the JUnit XML
file in [file_name], evalutes the given [grading] scheme and writes the result
back to the same file. *)
Expand Down
3 changes: 2 additions & 1 deletion src/test-lib/oUnit_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ let message_of_visibility = function
(** Hide a test according to the [visibility] argument. *)
let hide_test ?(visibility = PassFail) =
let fail_test () =
raise_notrace (OUnit_failure (message_of_visibility visibility))
Printexc.record_backtrace false;
assert_failure (message_of_visibility visibility)
in
let hide_func func ctx =
match visibility with
Expand Down
4 changes: 4 additions & 0 deletions src/test-lib/qCheck_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ let report_result = function
| Error e ->
Printexc.record_backtrace false;
QCheck.Test.fail_report e

(** Check a property against a fixed input. *)
let make_test_single ?name ?print x prop =
QCheck2.Test.make (QCheck2.Gen.pure x) prop ~count:1 ~max_gen:1 ?name ?print

0 comments on commit 697c25c

Please sign in to comment.