Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm_of_ocaml: fix the execution of tests in a sandbox #11304

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion src/dune_rules/inline_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,15 @@ include Sub_system.Register_end_point (struct
| Error _ -> Action_builder.return action
| Ok p -> Action_builder.path p >>> Action_builder.return action)
and+ () = deps
and+ () = Action_builder.path exe in
and+ () = Action_builder.path exe
and+ () =
match mode with
| Native | Best | Byte | Jsoo JS -> Action_builder.return ()
| Jsoo Wasm ->
Action_builder.path
(Path.build
(Path.Build.relative inline_test_dir (name ^ Js_of_ocaml.Ext.wasm_dir)))
in
Action.chdir (Path.build dir) action
in
let flags partition : string list Action_builder.t =
Expand Down
9 changes: 8 additions & 1 deletion src/dune_rules/test_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
| None -> t.deps
| Some _ ->
Bindings.Unnamed (Dep_conf.File (String_with_vars.make_text loc test_exe))
:: t.deps
::
(match runtest_mode with
| `js Wasm ->
Bindings.Unnamed
(Dep_conf.File
(String_with_vars.make_text loc (s ^ Js_of_ocaml.Ext.wasm_dir)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this tested at all? This should be accessible via %{deps} in some fields now I imagine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a test that does not pass without this change. Is it enough?

:: t.deps
| `js JS | `exe | `bc -> t.deps)
in
let add_alias ~loc ~action =
(* CR rgrinberg: why are we going through the stanza api? *)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 3.17)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(library
(name inline_test)
(modules inline_test)
(inline_tests
(modes wasm)
(backend inline_test_backend)))

(library
(name inline_test_backend)
(modules inline_test_backend)
(inline_tests.backend (generate_runner (echo ""))))
3 changes: 3 additions & 0 deletions test/blackbox-tests/test-cases/wasmoo/sandboxing.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Run tests and inline tests within a sandbox in copy mode

$ dune runtest --sandbox=copy
3 changes: 3 additions & 0 deletions test/blackbox-tests/test-cases/wasmoo/sandboxing.t/test/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(test
(modes wasm)
(name test))
Empty file.
Loading