Skip to content

Commit 3365a8d

Browse files
authored
fix: sandbox all test stanza variants starting from 3.22 (#13617)
Instead of just expect test stanzas Signed-off-by: Rudi Grinberg <[email protected]>
1 parent d71ca24 commit 3365a8d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

doc/changes/changed/13510.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
- Start sandboxing the execution of tests defined with the `test` and `tests`
2-
stanzas (#13510, @rgrinberg)
2+
stanzas (#13510, #13617, @rgrinberg)

src/dune_rules/test_rules.ml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,18 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
135135
|> Rules.Produce.Alias.add_deps runtest_alias)
136136
in
137137
let expander = Expander.add_bindings expander ~bindings:extra_bindings in
138+
let sandbox =
139+
if Dune_project.dune_version project >= (3, 22)
140+
then Sandbox_config.needs_sandboxing
141+
else Sandbox_config.no_special_requirements
142+
in
138143
match test_kind ~dir:(Expander.dir expander) dir_contents s ext with
139144
| `Regular ->
140145
let action =
141146
let chdir = Expander.dir expander in
142147
Action_unexpanded.expand_no_targets
143148
run_action
144-
Sandbox_config.no_special_requirements
149+
sandbox
145150
~loc
146151
~expander
147152
~chdir
@@ -161,12 +166,10 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
161166
~loc
162167
~expander
163168
~deps
164-
~targets:Targets_spec.Infer
169+
~targets:Infer
165170
~targets_dir:dir
166171
run_action
167-
(if Dune_project.dune_version project >= (3, 22)
168-
then Sandbox_config.needs_sandboxing
169-
else Sandbox_config.no_special_requirements)
172+
sandbox
170173
in
171174
Action_builder.With_targets.add action ~file_targets:[ diff.file2 ]
172175
|> Action_builder.With_targets.map_build ~f:(fun action ->

test/blackbox-tests/test-cases/stanzas/tests/tests-sandboxing.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ Demonstrate that test stanza is now sandbox
2323

2424
$ make_dune_project 3.22
2525
$ dune runtest dir/foo
26+
foo.exe

0 commit comments

Comments
 (0)