Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/changes/changed/13510.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
- Start sandboxing the execution of tests defined with the `test` and `tests`
stanzas (#13510, @rgrinberg)
stanzas (#13510, #13617, @rgrinberg)
13 changes: 8 additions & 5 deletions src/dune_rules/test_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,18 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
|> Rules.Produce.Alias.add_deps runtest_alias)
in
let expander = Expander.add_bindings expander ~bindings:extra_bindings in
let sandbox =
if Dune_project.dune_version project >= (3, 22)
then Sandbox_config.needs_sandboxing
else Sandbox_config.no_special_requirements
in
match test_kind ~dir:(Expander.dir expander) dir_contents s ext with
| `Regular ->
let action =
let chdir = Expander.dir expander in
Action_unexpanded.expand_no_targets
run_action
Sandbox_config.no_special_requirements
sandbox
~loc
~expander
~chdir
Expand All @@ -161,12 +166,10 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
~loc
~expander
~deps
~targets:Targets_spec.Infer
~targets:Infer
~targets_dir:dir
run_action
(if Dune_project.dune_version project >= (3, 22)
then Sandbox_config.needs_sandboxing
else Sandbox_config.no_special_requirements)
sandbox
in
Action_builder.With_targets.add action ~file_targets:[ diff.file2 ]
|> Action_builder.With_targets.map_build ~f:(fun action ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Demonstrate that test stanza is now sandbox

$ make_dune_project 3.22
$ dune runtest dir/foo
foo.exe
Loading