Skip to content

Commit c432909

Browse files
committed
fix: Do some cleanup & Fix mutation_testing test lib
Now, an optional library that demonstrates the use of grader libraries.
1 parent 7d27523 commit c432909

File tree

12 files changed

+65
-42
lines changed

12 files changed

+65
-42
lines changed

META.learn-ocaml.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ package "test_lib" (
44
description = "Learn-ocaml dependencies for automatic graders"
55
requires = "compiler-libs"
66
)
7+
# DUNE_GEN
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
learn-ocaml.mutation_testing

src/grader-plugins/dune

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(library
2+
(name mutation_testing)
3+
(public_name learn-ocaml.mutation_testing)
4+
(wrapped false)
5+
(modes byte)
6+
(libraries compiler-libs)
7+
;; The following lines are specific for compiling from within learn-ocaml.
8+
;; When writing grader-helper libs, use instead:
9+
;; (libraries learn-ocaml.test_lib)
10+
;; (preprocess (action (run %{libexec:learn-ocaml.test_lib:grader-ppx} %{input-file})))
11+
(flags (:standard -I src/grader/test_lib -open Test_lib.Open_me))
12+
(modules mutation_test)
13+
(preprocess (pps grader_ppx))
14+
(preprocessor_deps (alias ../grader/test_lib/test_lib_cmis))
15+
;; this is not a preprocessor deps, but dune does not allow other kinds of deps...
16+
)
File renamed without changes.

src/grader/mutation_test.mli renamed to src/grader-plugins/mutation_test.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module M: sig
100100
val passed_mutation_testing: Learnocaml_report.t -> bool
101101
end
102102

103-
include M
103+
include module type of M
104104

105105
(** For backwards compatibility *)
106-
module Make (_: module type of Test_lib) = M
106+
module Make (_: module type of Test_lib): module type of M

src/grader/dune

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
(library_flags :standard -linkall)
3636
(libraries ty
3737
toploop
38-
learnocaml_ppx_metaquot
3938
learnocaml_ppx_metaquot_lib
39+
grader_ppx
4040
ocplib-json-typed
4141
learnocaml_report
4242
learnocaml_repository
4343
introspection_intf
4444
pre_test)
4545
(modules Test_lib)
46-
(preprocess (pps learnocaml_ppx_metaquot))
46+
(preprocess (pps grader_ppx))
4747
)
4848
(rule
4949
(target testing_dyn.js)
@@ -167,29 +167,12 @@
167167
(run ocp-ocamlres -format ocamlres %{deps})))
168168
)
169169

170-
;; cmis that are needed to precompile the graders for exercises
171-
(install
172-
(section lib)
173-
(package learn-ocaml)
174-
(files
175-
(../ppx-metaquot/.ty.objs/byte/ty.cmi as test_lib/ty.cmi)
176-
(../ppx-metaquot/.fun_ty.objs/byte/fun_ty.cmi as test_lib/fun_ty.cmi)
177-
;; (.exercise_init.objs/byte/exercise_init.cmi as test_lib/exercise_init.cmi)
178-
(.introspection_intf.objs/byte/introspection_intf.cmi as test_lib/introspection_intf.cmi)
179-
(.pre_test.objs/byte/learnocaml_internal.cmi as test_lib/learnocaml_internal.cmi)
180-
(.pre_test.objs/byte/pre_test.cmi as test_lib/pre_test.cmi)
181-
(.learnocaml_report.objs/byte/learnocaml_report.cmi as test_lib/learnocaml_report.cmi)
182-
(.pre_test.objs/byte/learnocaml_callback.cmi as test_lib/learnocaml_callback.cmi) ;;FIXME separate lib??
183-
(.testing_dyn.objs/byte/test_lib.cmi as test_lib/test_lib.cmi))
184-
)
185-
186-
187170
(library
188171
(name grading)
189172
(wrapped false)
190173
(modes byte)
191174
(library_flags :standard -linkall)
192-
(libraries learnocaml_ppx_metaquot
175+
(libraries grader_ppx
193176
ocplib-ocamlres.runtime
194177
toploop
195178
learnocaml_internal_intf
@@ -201,7 +184,7 @@
201184
(modules Introspection
202185
Embedded_grading_lib
203186
Grading)
204-
(preprocess (per_module ((pps ppx_ocplib_i18n learnocaml_ppx_metaquot) Grading)))
187+
(preprocess (per_module ((pps ppx_ocplib_i18n grader_ppx) Grading)))
205188
)
206189

207190

src/grader/test_lib/dune

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
;; cmis that are needed to precompile the graders for exercises
2+
3+
(rule
4+
(alias test_lib_cmis)
5+
(action (progn
6+
(copy %{dep:../../ppx-metaquot/.ty.objs/byte/ty.cmi} ty.cmi)
7+
(copy %{dep:../../ppx-metaquot/.fun_ty.objs/byte/fun_ty.cmi} fun_ty.cmi)
8+
;; (copy %{dep:../.exercise_init.objs/byte/exercise_init.cmi} exercise_init.cmi)
9+
(copy %{dep:../.introspection_intf.objs/byte/introspection_intf.cmi} introspection_intf.cmi)
10+
(copy %{dep:../.pre_test.objs/byte/learnocaml_internal.cmi} learnocaml_internal.cmi)
11+
(copy %{dep:../.pre_test.objs/byte/pre_test.cmi} pre_test.cmi)
12+
(copy %{dep:../.learnocaml_report.objs/byte/learnocaml_report.cmi} learnocaml_report.cmi)
13+
(copy %{dep:../.pre_test.objs/byte/learnocaml_callback.cmi} learnocaml_callback.cmi)
14+
(copy %{dep:../.testing_dyn.objs/byte/test_lib.cmi} test_lib.cmi)))
15+
)
16+
17+
(install
18+
(section lib)
19+
(package learn-ocaml)
20+
(files
21+
(ty.cmi as test_lib/ty.cmi)
22+
(fun_ty.cmi as test_lib/fun_ty.cmi)
23+
;; (exercise_init.cmi as test_lib/exercise_init.cmi)
24+
(introspection_intf.cmi as test_lib/introspection_intf.cmi)
25+
(learnocaml_internal.cmi as test_lib/learnocaml_internal.cmi)
26+
(pre_test.cmi as test_lib/pre_test.cmi)
27+
(learnocaml_report.cmi as test_lib/learnocaml_report.cmi)
28+
(learnocaml_callback.cmi as test_lib/learnocaml_callback.cmi)
29+
(test_lib.cmi as test_lib/test_lib.cmi))
30+
)

src/ppx-metaquot/dune

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,23 @@
2020
(libraries ppx_tools compiler-libs)
2121
)
2222

23-
;; (library
24-
;; (name learnocaml_recorder)
25-
;; (wrapped false)
26-
;; (modules Recorder)
27-
;; (libraries ppxlib))
28-
2923
(library
30-
(name learnocaml_ppx_metaquot)
24+
(name grader_ppx)
3125
(wrapped false)
3226
(libraries learnocaml_ppx_metaquot_lib ty fun_ty ocaml-migrate-parsetree ppxlib)
33-
(modules Ppx_autoregister Ppx_metaquot_grader)
27+
(modules Ppx_autoregister Grader_ppx)
3428
(kind ppx_rewriter)
3529
)
3630

3731
(executable
38-
(name ppx_metaquot_main)
39-
(modules ppx_metaquot_main)
40-
(libraries learnocaml_ppx_metaquot))
32+
(name grader_ppx_main)
33+
(modules grader_ppx_main)
34+
(libraries grader_ppx))
4135

4236
(install
4337
(section libexec)
4438
(package learn-ocaml)
45-
(files
46-
(ppx_metaquot_main.exe as grading_ppx/learnocaml-ppx-grader))
39+
(files (grader_ppx_main.exe as test_lib/grader-ppx))
4740
)
4841

4942
(library

src/ppx-metaquot/grader_ppx_main.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let () =
2+
Migrate_parsetree.Driver.run_main ~exit_on_error:true ()

src/ppx-metaquot/ppx_metaquot_main.ml

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/repo/learnocaml_precompile_exercise.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
open Lwt.Infix
44

55
(* FIXME: make these configurable *)
6-
let grading_cmis_dir, grading_ppx_dir =
6+
let grading_cmis_dir =
77
let prefix = Filename.dirname (Filename.dirname (Sys.executable_name)) in
88
let ( / ) = Filename.concat in
9-
ref (prefix/"lib"/"learn-ocaml"/"test_lib"),
10-
ref (prefix/"lib"/"learn-ocaml"/"grading_ppx")
9+
ref (prefix/"lib"/"learn-ocaml"/"test_lib")
1110

1211
let run ?dir cmd args =
1312
Lwt_process.exec ?cwd:dir ("", Array.of_list (cmd::args)) >>= function
@@ -85,7 +84,7 @@ let precompile ~exercise_dir =
8584
jsoo ~dir [] ~source:"exercise.cma" ~target:"exercise.js");
8685
(ocamlc ~dir (["-c";
8786
"-I"; "+compiler-libs";
88-
"-ppx"; Filename.concat !grading_ppx_dir "learnocaml-ppx-grader"]
87+
"-ppx"; Filename.concat !grading_cmis_dir "grader-ppx --as-ppx"]
8988
@ grader_flags)
9089
~opn:["Learnocaml_callback"; "Prelude"; "Prepare"; "Test_lib.Open_me"]
9190
~source:["test.ml"]

0 commit comments

Comments
 (0)