Skip to content

Commit

Permalink
Merge pull request ocsigen#128 from ocaml-wasm/env-var
Browse files Browse the repository at this point in the history
Use environment variable to disable some tests when testing Wasm_of_ocaml
  • Loading branch information
vouillon authored Nov 6, 2024
2 parents 1a7305e + aa1c9c9 commit 9d6df66
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 196 deletions.
110 changes: 55 additions & 55 deletions compiler/tests-compiler/dune.inc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiler/tests-compiler/gen-rules/gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let () =
(library
;; %s%s.ml
(name %s_%d)
(enabled_if (and %s (<> %%{profile} wasm) (<> %%{profile} wasm-effects)))
(enabled_if (and %s %%{env:js-enabled=}))
(modules %s)
(libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper)
(inline_tests
Expand Down
30 changes: 6 additions & 24 deletions compiler/tests-dynlink-js/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
(executable
(name main)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(modules main)
(libraries js_of_ocaml)
(link_flags
Expand Down Expand Up @@ -40,10 +37,7 @@

(rule
(target main.js)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(action
(run %{bin:js_of_ocaml} --linkall %{read-strings:effects_flags.txt} -o
%{target} %{dep:main.bc})))
Expand Down Expand Up @@ -73,10 +67,7 @@

(rule
(target main.out)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(deps plugin.js plugin2.js)
(action
(with-outputs-to
Expand All @@ -85,10 +76,7 @@

(rule
(target main.out2)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(deps plugin.js plugin2.js)
(action
(with-outputs-to
Expand All @@ -97,18 +85,12 @@

(rule
(alias runtest)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(action
(diff main.out.expected main.out)))

(rule
(alias runtest)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(action
(diff main.out.expected main.out2)))
20 changes: 4 additions & 16 deletions compiler/tests-dynlink/dune
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
(executable
(name main)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(modules main)
(libraries dynlink js_of_ocaml-compiler.dynlink)
(modes byte))

(rule
(target main.js)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(deps plugin.cmo export)
(action
(run %{bin:js_of_ocaml} --dynlink --export export --pretty -o %{target}
Expand All @@ -26,10 +20,7 @@

(rule
(target main.out)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(deps plugin.cmo)
(action
(with-outputs-to
Expand All @@ -38,9 +29,6 @@

(rule
(alias runtest)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(action
(diff main.out.expected main.out)))
8 changes: 2 additions & 6 deletions compiler/tests-io/dune
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
(action
(copy cat.bc.wasm.js cat.bc.js))
(enabled_if
(or
(= %{profile} wasm)
(= %{profile} wasm-effects))))
(not %{env:js-enabled=})))

(rule
(target md5-native.stdout)
Expand Down Expand Up @@ -83,6 +81,4 @@
(action
(copy md5.bc.wasm.js md5.bc.js))
(enabled_if
(or
(= %{profile} wasm)
(= %{profile} wasm-effects))))
(not %{env:js-enabled=})))
8 changes: 2 additions & 6 deletions compiler/tests-jsoo/bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@
(action
(copy error1.bc.wasm.js error1.bc.js))
(enabled_if
(or
(= %{profile} wasm)
(= %{profile} wasm-effects))))
(not %{env:js-enabled=})))

(rule
(target error2.js.actual)
Expand Down Expand Up @@ -118,6 +116,4 @@
(action
(copy error2.bc.wasm.js error2.bc.js))
(enabled_if
(or
(= %{profile} wasm)
(= %{profile} wasm-effects))))
(not %{env:js-enabled=})))
22 changes: 15 additions & 7 deletions compiler/tests-jsoo/lib-effects/dune
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
(env
(using-effects)
(wasm)
(wasm-effects)
(_
(js_of_ocaml
(flags
(:standard --enable effects))
;; separate compilation doesn't work when using
;; features such as 'effects' or 'use-js-string'
;; because dune doesn't know that it should compile
;; multiple versions of the dependencies
(compilation_mode whole_program))))

(library
(name jsoo_testsuite_effect)
(enabled_if
(and
(>= %{ocaml_version} 5)
(or
(= %{profile} using-effects)
(= %{profile} wasm-effects))))
(>= %{ocaml_version} 5))
(inline_tests
;; This requires the unreleased dune 3.7 to work
(enabled_if true)
(modes js wasm best))
(preprocess
(pps ppx_expect)))
5 changes: 1 addition & 4 deletions compiler/tests-num/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
(name main)
(modules main test_nats test test_big_ints test_ratios test_nums test_io)
(libraries num)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(modes
js
(best exe))
Expand Down
9 changes: 2 additions & 7 deletions compiler/tests-ocaml/lib-hashtbl/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@
(rule
(action
(copy hfun.expected-js hfun.expected))
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects))))
(enabled_if %{env:js-enabled=}))

(rule
(action
(copy hfun.expected-wasm hfun.expected))
(enabled_if
(or
(= %{profile} wasm)
(= %{profile} wasm-effects))))
(not %{env:js-enabled=})))
22 changes: 5 additions & 17 deletions compiler/tests-toplevel/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
(executables
(names test_toplevel)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(libraries js_of_ocaml-compiler.dynlink compiler-libs.toplevel)
(flags
(:standard -linkall))
Expand All @@ -13,20 +10,13 @@

(rule
(targets test_toplevel.js)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(action
(run %{bin:js_of_ocaml} --toplevel %{dep:test_toplevel.bc} -o %{targets})))

(rule
(target test_toplevel.bc.js.actual)
(enabled_if
(and
(>= %{ocaml_version} 5.2)
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(action
(with-stdout-to
%{target}
Expand All @@ -37,8 +27,7 @@
(enabled_if
(and
(>= %{ocaml_version} 5.2)
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
%{env:js-enabled=}))
(action
(with-stdout-to
%{target}
Expand All @@ -49,8 +38,7 @@
(enabled_if
(and
(>= %{ocaml_version} 5.2)
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
%{env:js-enabled=}))
(action
(progn
(diff test_toplevel.expected test_toplevel.bc.js.actual)
Expand Down
23 changes: 18 additions & 5 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
(wasm_of_ocaml
(enabled_if false))
(flags
(:standard -w +a-4-40-41-42-44-48-58-66-70)))
(:standard -w +a-4-40-41-42-44-48-58-66-70))
(env-vars
(js-enabled true)))
(using-effects
(wasm_of_ocaml
(enabled_if false))
Expand All @@ -12,14 +14,18 @@
(flags
(:standard --enable effects))
(build_runtime_flags
(:standard --enable effects))))
(:standard --enable effects)))
(env-vars
(js-enabled true)))
(wasm
(binaries
(tools/node_wrapper.sh as node))
(js_of_ocaml
(enabled_if false))
(wasm_of_ocaml
(compilation_mode separate)))
(compilation_mode separate))
(env-vars
(js-enabled false)))
(wasm-effects
(binaries
(tools/node_wrapper.sh as node))
Expand All @@ -28,14 +34,21 @@
(wasm_of_ocaml
(compilation_mode separate)
(flags
(:standard --enable effects))))
(:standard --enable effects)))
(env-vars
(js-enabled false)))
(bench_no_debug
(flags
(:standard \ -g))
(ocamlc_flags
(:standard \ -g))
(link_flags
(:standard \ -g))))
(:standard \ -g))
(env-vars
(js-enabled true)))
(_
(env-vars
(js-enabled true))))

(rule
(targets version.ml.in)
Expand Down
5 changes: 1 addition & 4 deletions examples/namespace/dune
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@

(rule
(alias runtest)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(action
(diff %{dep:for-node.expected} %{dep:for-node.actual})))
10 changes: 2 additions & 8 deletions examples/separate_compilation/dune
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,12 @@

(rule
(alias runtest)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(action
(diff bin.expected bin.actual)))

(alias
(name default)
(enabled_if
(and
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
(enabled_if %{env:js-enabled=})
(deps myruntime.js stdlib.cma.js std_exit.js module2.js module1.js bin.js
index.html))
6 changes: 2 additions & 4 deletions ppx/ppx_deriving_json/tests/dune
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
(enabled_if
(and
(>= %{ocaml_version} 5.1)
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
%{env:js-enabled=}))
;; (package js_of_ocaml-ppx)
(action
(diff ppx.mlt ppx.mlt.corrected)))
Expand All @@ -37,8 +36,7 @@
(enabled_if
(and
(>= %{ocaml_version} 5.1)
(<> %{profile} wasm)
(<> %{profile} wasm-effects)))
%{env:js-enabled=}))
;; (package js_of_ocaml-ppx)
(action
(diff gen.mlt gen.mlt.corrected)))
Loading

0 comments on commit 9d6df66

Please sign in to comment.