Skip to content

Commit 1ccb583

Browse files
authored
Wasm_of_ocaml: fix the execution of tests in a sandbox (#11304)
* Wasm: test sandboxing Signed-off-by: Jérôme Vouillon <[email protected]>
1 parent ad2ef5e commit 1ccb583

File tree

10 files changed

+36
-2
lines changed

10 files changed

+36
-2
lines changed

Diff for: doc/changes/11304.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Wasm_of_ocaml: fix the execution of tests in a sandbox. (#11304, @vouillon)

Diff for: src/dune_rules/inline_tests.ml

+9-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,15 @@ include Sub_system.Register_end_point (struct
296296
| Error _ -> Action_builder.return action
297297
| Ok p -> Action_builder.path p >>> Action_builder.return action)
298298
and+ () = deps
299-
and+ () = Action_builder.path exe in
299+
and+ () = Action_builder.path exe
300+
and+ () =
301+
match mode with
302+
| Native | Best | Byte | Jsoo JS -> Action_builder.return ()
303+
| Jsoo Wasm ->
304+
Action_builder.path
305+
(Path.build
306+
(Path.Build.relative inline_test_dir (name ^ Js_of_ocaml.Ext.wasm_dir)))
307+
in
300308
Action.chdir (Path.build dir) action
301309
in
302310
let flags partition : string list Action_builder.t =

Diff for: src/dune_rules/test_rules.ml

+8-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,14 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
104104
| None -> t.deps
105105
| Some _ ->
106106
Bindings.Unnamed (Dep_conf.File (String_with_vars.make_text loc test_exe))
107-
:: t.deps
107+
::
108+
(match runtest_mode with
109+
| `js Wasm ->
110+
Bindings.Unnamed
111+
(Dep_conf.File
112+
(String_with_vars.make_text loc (s ^ Js_of_ocaml.Ext.wasm_dir)))
113+
:: t.deps
114+
| `js JS | `exe | `bc -> t.deps)
108115
in
109116
let add_alias ~loc ~action =
110117
(* CR rgrinberg: why are we going through the stanza api? *)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(lang dune 3.17)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(library
2+
(name inline_test)
3+
(modules inline_test)
4+
(inline_tests
5+
(modes wasm)
6+
(backend inline_test_backend)))
7+
8+
(library
9+
(name inline_test_backend)
10+
(modules inline_test_backend)
11+
(inline_tests.backend (generate_runner (echo ""))))

Diff for: test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/inline_test.ml

Whitespace-only changes.

Diff for: test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/inline_test_backend.ml

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Run tests and inline tests within a sandbox in copy mode
2+
3+
$ dune runtest --sandbox=copy
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(test
2+
(modes wasm)
3+
(name test))

Diff for: test/blackbox-tests/test-cases/wasmoo/sandboxing.t/test/test.ml

Whitespace-only changes.

0 commit comments

Comments
 (0)