@@ -20,23 +20,23 @@ A classic `test.ml` file is as follows:
2020open Test_lib
2121open Report
2222
23- let exercise_1 = ..
23+ let exercise_1 () = ..
2424
25- let exercise_2 = ..
25+ let exercise_2 () = ..
2626
27- let exercise_3 = ..
27+ let exercise_3 () = ..
2828
2929
3030let () =
3131 set_result @@
3232 ast_sanity_check code_ast @@ fun () ->
33- [ exercise_1 ; exercise_2 ; exercise_3 ]
33+ [ exercise_1 () ; exercise_2 () ; exercise_3 () ]
3434
3535```
3636
37- The values ` exercise_x ` are values of type ` Learnocaml_report.report ` , which is
37+ The return values of ` exercise_x ` are of type ` Learnocaml_report.report ` , which is
3838a representation of the report given by the grader. In this example, each of
39- these values are referring to a specific question from the exercise. Their
39+ these values is referring to a specific question from the exercise. Their
4040content is detailed in the next section. These reports are then given to the
4141function ` ast_sanity_check ` , which ensures that some modules are never used
4242(` Obj ` , ` Marshall ` , all the modules from ` compiler-libs ` or the library that
@@ -46,7 +46,7 @@ allows introspection), and also excludes some syntactic features of the language
4646
4747# Writing tests and reports
4848
49- The format of reports can be found in ` src/state /learnocaml_report.ml ` . A report
49+ The format of reports can be found in ` src/grader /learnocaml_report.ml ` . A report
5050describes the result of what should be outputted and interpreted by the
5151grader. It can be classified into sections for lisibility, and return many kind
5252of messages:
@@ -252,3 +252,23 @@ forbidden or required. The two functions `ast_check_expr` and
252252pattern-matching on some specific patterns into the code. The function
253253` find_binding ` look for a toplevel value and apply a given function on its
254254syntax tree.
255+
256+ ### Using helper libraries for testing
257+
258+ Using a ` test_libs.txt ` file, it is possible to include libraries that define
259+ helpers for grading.
260+
261+ The file should contain the ocamlfind names of the libraries, one per line.
262+
263+ Example of such libs include
264+ [ mutation_testing] ( https://github.com/ocaml-sf/learn-ocaml/blob/master/src/grader-plugins/mutation_test.ml )
265+ (from McGill University, included in this repository), or
266+ [ easy-check] ( https://github.com/lsylvestre/easy-check ) from University Paris 6.
267+
268+ See ` src/grader-plugins/dune ` to get how to build such libraries. Like
269+ ` test.ml ` , they can access the ` Introspection ` and ` Test_lib ` interfaces. They
270+ cannot, at the time of writing, define new samplers or printers, but if you need
271+ that feature and are ready to contribute, all that is missing is the inclusion
272+ of their ` cmi ` files in the grading-toplevel environment (these features rely
273+ on dynamic typing, and the ` cma ` library doesn't include the required typing
274+ information).
0 commit comments