Skip to content

Commit

Permalink
feature: sandbox inline tests rules
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>

ps-id: cd4104b4-b31e-4be7-8e6a-e949548b3e3c
  • Loading branch information
rgrinberg committed Aug 18, 2022
1 parent cb043e7 commit 90bbd55
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
- Allow rules producing directory targets to create symlinks (#6077, fixes
#5945, @rgrinberg)

- Inline tests are now sandboxed by default (#6079, @rgrinberg)

3.4.1 (26-07-2022)
------------------

Expand Down
5 changes: 2 additions & 3 deletions src/dune_rules/dep_conf_eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,10 @@ let named ~expander l =
| Unnamed dep -> add_sandbox_config acc dep
| Named (_, l) -> List.fold_left l ~init:acc ~f:add_sandbox_config) )

let unnamed ~expander l =
let unnamed ?(sandbox = Sandbox_config.no_special_requirements) ~expander l =
let expander = prepare_expander expander in
( List.fold_left l ~init:(Action_builder.return ()) ~f:(fun acc x ->
let+ () = acc
and+ _x = to_action_builder (dep expander x) in
())
, List.fold_left l ~init:Sandbox_config.no_special_requirements
~f:add_sandbox_config )
, List.fold_left l ~init:sandbox ~f:add_sandbox_config )
3 changes: 2 additions & 1 deletion src/dune_rules/dep_conf_eval.mli
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ val package_install : context:Build_context.t -> pkg:Package.t -> Alias.t

(** Evaluates unnamed dependency specifications. *)
val unnamed :
expander:Expander.t
?sandbox:Sandbox_config.t
-> expander:Expander.t
-> Dep_conf.t list
-> unit Action_builder.t * Sandbox_config.t

Expand Down
10 changes: 9 additions & 1 deletion src/dune_rules/inline_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,15 @@ include Sub_system.Register_end_point (struct
Path.build (Path.Build.relative inline_test_dir (name ^ ext))
in
let open Action_builder.O in
let deps, sandbox = Dep_conf_eval.unnamed info.deps ~expander in
let deps, sandbox =
let sandbox =
let project = Scope.project scope in
if Dune_project.dune_version project < (3, 5) then
Sandbox_config.no_special_requirements
else Sandbox_config.needs_sandboxing
in
Dep_conf_eval.unnamed ~sandbox info.deps ~expander
in
let+ () = deps
and+ () = Action_builder.paths source_files
and+ () = Action_builder.path exe
Expand Down

0 comments on commit 90bbd55

Please sign in to comment.