Source file mutaml_common.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
open Ppx_yojson_conv_lib.Yojson_conv.Primitives
type defaults =
{
ppx_output_prefix : string;
output_file_prefix : string;
mutaml_mut_file : string;
mutaml_report_file : string;
}
let defaults =
{
ppx_output_prefix = Filename.concat "_build" "default";
output_file_prefix = "_mutations";
mutaml_mut_file = "mutaml-mut-files.txt";
mutaml_report_file = "mutaml-report.json"
}
let full_ppx_path ppx_output_prefix fname =
if Filename.is_implicit fname
then Filename.concat ppx_output_prefix fname
else fname
let full_path fname =
if Filename.is_implicit fname
then Filename.concat defaults.output_file_prefix fname
else fname
let make_mut_id file_name number =
Printf.sprintf "%s:%i" Filename.(remove_extension file_name) number
let output_file_name file_name number =
let file_name = Printf.sprintf "%s-mutant%i.output" file_name number in
full_path file_name
let fail_and_exit s =
print_endline s;
exit 1
module Loc =
struct
type position = Lexing.position =
{ pos_fname : string
; pos_lnum : int
; pos_bol : int
; pos_cnum : int
}
and location = Location.t = {
loc_start : position;
loc_end : position;
loc_ghost : bool;
} [@@deriving yojson]
end
(** A common type to represent mutations *)
type mutant =
{
number : int;
repl : string option;
loc : Loc.location;
} [@@deriving yojson]
(** A common type to represent test results *)
type test_result =
{
status : int;
mutant : mutant;
} [@@deriving yojson]