@@ -9,7 +9,13 @@ module Make
9
9
struct
10
10
open Promise.Syntax
11
11
12
- type state = { root : string ; uuid : string ; suite_name : string }
12
+ type state = {
13
+ root : string ;
14
+ uuid : string ;
15
+ suite_name : string ;
16
+ has_alias : bool ;
17
+ }
18
+
13
19
type t = Inactive | Active of state
14
20
15
21
(* * Take a string path and collapse a leading [$HOME] path segment to [~]. *)
30
36
31
37
let active ~root ~uuid ~suite_name =
32
38
Platform. prepare_log_trap ~root ~uuid ~name: suite_name;
33
- Active { root; uuid; suite_name }
39
+ let has_alias = Platform. file_exists (Filename. concat root suite_name) in
40
+ Active { root; uuid; suite_name; has_alias }
34
41
35
42
let pp_path = Fmt. using maybe_collapse_home Fmt. string
36
43
@@ -63,31 +70,31 @@ struct
63
70
in
64
71
ListLabels. iter display_lines ~f: (Fmt. pf ppf " %s@\n " )
65
72
66
- let log_dir { suite_name; uuid; root } =
67
- (* We don't create symlinks on Windows. *)
68
- let via_symlink = not Sys. win32 in
73
+ let log_dir ~via_symlink { suite_name; uuid; root; has_alias } =
74
+ let via_symlink = via_symlink && has_alias in
69
75
Filename. concat root (if via_symlink then suite_name else uuid)
70
76
71
- let output_fpath t tname = Filename. concat (log_dir t) (Test_name. file tname)
77
+ let output_fpath ~via_symlink t tname =
78
+ Filename. concat (log_dir ~via_symlink t) (Test_name. file tname)
72
79
73
80
let active_or_exn = function
74
81
| Active t -> t
75
82
| Inactive -> failwith " internal error: no log location"
76
83
77
84
let pp_current_run_dir t ppf =
78
85
let t = active_or_exn t in
79
- pp_path ppf (log_dir t)
86
+ pp_path ppf (log_dir ~via_symlink: true t)
80
87
81
88
let pp_log_location t tname ppf =
82
89
let t = active_or_exn t in
83
- let path = output_fpath t tname in
90
+ let path = output_fpath ~via_symlink: true t tname in
84
91
pp_path ppf path
85
92
86
93
let recover_logs t ~tail tname =
87
94
match t with
88
95
| Inactive -> None
89
96
| Active t -> (
90
- let fpath = output_fpath t tname in
97
+ let fpath = output_fpath ~via_symlink: false t tname in
91
98
match Platform. file_exists fpath with
92
99
| false -> None
93
100
| true -> Some (fun ppf -> pp_tail tail fpath ppf))
@@ -96,7 +103,9 @@ struct
96
103
match t with
97
104
| Inactive -> f x
98
105
| Active t ->
99
- let fd = Platform. open_write_only (output_fpath t tname) in
106
+ let fd =
107
+ Platform. open_write_only (output_fpath ~via_symlink: false t tname)
108
+ in
100
109
let * () = Promise. return () in
101
110
let + a = Platform. with_redirect fd (fun () -> f x) in
102
111
Platform. close fd;
0 commit comments