File tree Expand file tree Collapse file tree 8 files changed +94
-9
lines changed
test/blackbox-tests/test-cases/trace/action-traces Expand file tree Collapse file tree 8 files changed +94
-9
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,12 @@ let local_libraries =
105105 ; special_builtin_support = None
106106 ; root_module = None
107107 }
108+ ; { path = " otherlibs/dune-action-trace"
109+ ; main_module_name = Some " Dune_action_trace"
110+ ; include_subdirs = No
111+ ; special_builtin_support = None
112+ ; root_module = None
113+ }
108114 ; { path = " vendor/bigstringaf"
109115 ; main_module_name = Some " Bigstringaf"
110116 ; include_subdirs = No
@@ -255,12 +261,6 @@ let local_libraries =
255261 ; special_builtin_support = None
256262 ; root_module = None
257263 }
258- ; { path = " otherlibs/dune-action-trace"
259- ; main_module_name = Some " Dune_action_trace"
260- ; include_subdirs = No
261- ; special_builtin_support = None
262- ; root_module = None
263- }
264264 ; { path = " src/dune_engine"
265265 ; main_module_name = Some " Dune_engine"
266266 ; include_subdirs = No
Original file line number Diff line number Diff line change 1+ - Dune dune produces trace events in ` DUNE_ACTION_TRACE_DIR ` if this variable
2+ is set. (#13302 , @rgrinberg )
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ val clear_dir : Path.t -> unit
3232 safely use any file name there. *)
3333val temp_file : dir :Path .t -> prefix :string -> suffix :string -> Path .t
3434
35+ val temp_dir : parent_dir :Path .t -> prefix :string -> suffix :string -> Path .t
36+
3537(* * Like [temp_file], but passes the temporary file to the callback [f], and
3638 makes sure the temporary file is deleted when [f] completes. If [f] raises
3739 an exception, the exception is re-raised (and the file is still deleted). *)
Original file line number Diff line number Diff line change 33 (foreign_stubs
44 (language c)
55 (names dune_trace_stubs))
6- (libraries stdune csexp bigstringaf threads.posix spawn unix))
6+ (libraries
7+ stdune
8+ dune_action_trace
9+ csexp
10+ bigstringaf
11+ threads.posix
12+ spawn
13+ unix))
Original file line number Diff line number Diff line change @@ -11,7 +11,18 @@ let () =
1111 | None -> ()
1212 | Some t ->
1313 Out. emit t (Event. exit () );
14- Out. close t)
14+ Out. close t;
15+ (match Env. (get initial Dune_action_trace.Private. trace_dir_env_var) with
16+ | None -> ()
17+ | Some dir ->
18+ let dir = Path. of_string dir in
19+ Path. mkdir_p dir;
20+ let dst =
21+ Path. relative
22+ (Temp. temp_dir ~parent_dir: dir ~prefix: " dune" ~suffix: " trace" )
23+ " trace.csexp"
24+ in
25+ Io. copy_file ~src: t.path ~dst () ))
1526;;
1627
1728let set_global t =
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ type t =
2222 ; buf : Buffer .t
2323 ; cats : Category.Set .t
2424 ; mutex : Mutex .t
25+ ; path : Path .t
2526 }
2627
2728(* CR-someday rgrinberg: remove this once we drop support for < 5.2 *)
@@ -70,7 +71,7 @@ let create cats path =
7071 in
7172 let cats = Category.Set. of_list cats in
7273 let buf = Buffer. create (1 lsl 16 ) in
73- { fd; cats; buf; mutex = Mutex. create () }
74+ { fd; cats; buf; mutex = Mutex. create () ; path }
7475;;
7576
7677let to_buffer t sexp =
Original file line number Diff line number Diff line change 33 ; buf : Buffer .t
44 ; cats : Category.Set .t
55 ; mutex : Mutex .t
6+ ; path : Stdune.Path .t
67 }
78
89val emit : ?buffered : bool -> t -> Event .t -> unit
Original file line number Diff line number Diff line change 1+ Dune itself produces action traces
2+
3+ $ cat > dune-project<< EOF
4+ > (lang dune 3.22 )
5+ > EOF
6+
7+ $ cat > dune << EOF
8+ > (rule (with-stdout-to foo (echo bar)))
9+ > (rule
10+ > (alias foo)
11+ > (deps (source_tree . ))
12+ > (action (run dune build ./ foo)))
13+ > EOF
14+
15+ $ dune build @foo
16+
17+ $ dune trace cat | jq 'include "dune ";
18+ > select (. name == " init" )
19+ > | { args: . args | keys, keys: keys, argv: . args. argv | . [1:] }
20+ > '
21+ {
22+ "args": [
23+ "argv",
24+ "build_dir",
25+ "env",
26+ "initial_cwd",
27+ "pid",
28+ "root"
29+ ],
30+ "keys": [
31+ "args",
32+ "cat",
33+ "name",
34+ "ts"
35+ ],
36+ "argv": [
37+ "build",
38+ "@foo"
39+ ]
40+ }
41+ {
42+ "args": [
43+ "argv",
44+ "build_dir",
45+ "digest",
46+ "env",
47+ "initial_cwd",
48+ "pid",
49+ "root"
50+ ],
51+ "keys": [
52+ "args",
53+ "cat",
54+ "name",
55+ "ts"
56+ ],
57+ "argv": [
58+ "build",
59+ "./foo"
60+ ]
61+ }
You can’t perform that action at this time.
0 commit comments