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

Tests: run npm install from dune #181

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
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,5 @@ jobs:
- name: Check formatting
run: make format-check

- name: "Install npm packages for tests"
run: yarn install
working-directory: test

- name: Run tests
run: make test
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
- Install opam: https://opam.ocaml.org/doc/Install.html
- Create local switch by running `make init` (this step will take a few minutes, as it will build whole OCaml compiler)
- Build with `make build`
- Run tests with
- Install test dependencies with `(cd test; yarn)`
- `make test`
- Run tests with `make test`

It is recommended to run `git config --local core.hooksPath .githooks/` to make sure git hooks run,
otherwise you could get CI errors due to formatting.
Expand Down
5 changes: 3 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(lang dune 2.7)
(lang dune 3.7)

(using directory-targets 0.1)

(name jsoo-react)

Expand All @@ -20,7 +22,6 @@
(synopsis "Bindings to ReactJS for js_of_ocaml, including JSX ppx")
(depends
;; General system dependencies
(dune (and (>= 2) (< 4)))
(ocaml (and (>= 4.12.0) (< 5.0.0)))

(js_of_ocaml (and (>= 4.0.0) (< 5.2.0)))
Expand Down
24 changes: 13 additions & 11 deletions example/src/Main.re
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ let firstExample = {
path: "hello-world-ocaml",
title: "Hello World OCaml",
element: <HelloWorldOCaml />,
code: <Code text=[%blob "HelloWorldOCaml.ml"] />,
code:
<Code text=[%blob "../../../default/example/src/HelloWorldOCaml.ml"] />,
showTitle: true,
};
let examples = [
Expand All @@ -24,14 +25,15 @@ let examples = [
path: "hello-world-reason",
title: "Hello World Reason",
element: <HelloWorldReason />,
code: <Code text=[%blob "HelloWorldReason.re"] />,
code:
<Code text=[%blob "../../../default/example/src/HelloWorldReason.re"] />,
showTitle: true,
},
{
path: "events",
title: "Events",
element: <Events />,
code: <Code text=[%blob "Events.re"] />,
code: <Code text=[%blob "../../../default/example/src/Events.re"] />,
showTitle: true,
},
{
Expand All @@ -41,17 +43,17 @@ let examples = [
code:
<>
<p> {"EffectsAndState component:" |> s} </p>
<Code text=[%blob "EffectsAndState.re"] />
<Code text=[%blob "../../../default/example/src/EffectsAndState.re"] />
<p> {"UseEffect component:" |> s} </p>
<Code text=[%blob "UseEffect.re"] />
<Code text=[%blob "../../../default/example/src/UseEffect.re"] />
</>,
showTitle: true,
},
{
path: "refs",
title: "Refs",
element: <Refs />,
code: <Code text=[%blob "Refs.re"] />,
code: <Code text=[%blob "../../../default/example/src/Refs.re"] />,
showTitle: true,
},
{
Expand All @@ -61,7 +63,7 @@ let examples = [
<div style=React.Dom.Style.(make([|height("50vw")|]))>
<WebComponent />
</div>,
code: <Code text=[%blob "WebComponent.ml"] />,
code: <Code text=[%blob "../../../default/example/src/WebComponent.ml"] />,
showTitle: true,
},
{
Expand All @@ -76,9 +78,9 @@ let examples = [
code:
<div>
<strong> {"Interface" |> s} </strong>
<Code text=[%blob "Interface.rei"] />
<Code text=[%blob "../../../default/example/src/Interface.rei"] />
<strong> {"Implementation" |> s} </strong>
<Code text=[%blob "Interface.re"] />
<Code text=[%blob "../../../default/example/src/Interface.re"] />
</div>,
showTitle: false,
},
Expand All @@ -93,7 +95,7 @@ let examples = [
</a>
{"." |> s}
</p>,
code: <Code text=[%blob "Bindings.rei"] />,
code: <Code text=[%blob "../../../default/example/src/Bindings.rei"] />,
showTitle: false,
},
{
Expand Down Expand Up @@ -131,7 +133,7 @@ let examples = [
{":" |> s}
</p>
</>,
code: <Code text=[%blob "Code.re"] />,
code: <Code text=[%blob "../../../default/example/src/Code.re"] />,
showTitle: false,
},
];
Expand Down
3 changes: 2 additions & 1 deletion jsoo-react.opam
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: "MIT"
homepage: "https://github.com/ml-in-barcelona/jsoo-react"
bug-reports: "https://github.com/ml-in-barcelona/jsoo-react/issues"
depends: [
"dune" {>= "2.7" & >= "2" & < "4"}
"dune" {>= "3.7"}
"ocaml" {>= "4.12.0" & < "5.0.0"}
"js_of_ocaml" {>= "4.0.0" & < "5.2.0"}
"gen_js_api" {>= "1.0.8" & < "1.2.0"}
Expand All @@ -32,6 +32,7 @@ build: [
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
Expand Down
10 changes: 6 additions & 4 deletions ppx/test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@
(alias runtest)
(action
(progn
(diff pp_errors_01_external_component_multi_prim.expected
pp_errors_01_external_component_multi_prim.actual)
(diff pp_errors_02_external_component_unlabelled_arg.expected
pp_errors_02_external_component_unlabelled_arg.actual)
(diff
pp_errors_01_external_component_multi_prim.expected
pp_errors_01_external_component_multi_prim.actual)
(diff
pp_errors_02_external_component_unlabelled_arg.expected
pp_errors_02_external_component_unlabelled_arg.actual)
(diff pp_reason.expected pp_reason.result)
(diff pp_ocaml.expected pp_ocaml.result)
(diff pp_ocaml_dev.expected pp_ocaml_dev.result))))
14 changes: 8 additions & 6 deletions test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
(action
(run %{bin:gen_js_api} -o %{targets} %{deps})))

(rule
(targets
(dir node_modules))
(deps package.json)
(action
(run npm install --no-save)))

(rule
(alias runtest)
(deps
external.js
test_jsoo_react.bc.js
(source_tree node_modules))
(deps external.js test_jsoo_react.bc.js node_modules)
(action
(run node test_jsoo_react.bc.js)))

(data_only_dirs node_modules)
Loading