From 5a991533a656de2faafdbcf0cce2b1026e43565e Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Sun, 3 Sep 2023 18:17:18 +0200 Subject: [PATCH 1/8] Migrate snapshot to cram --- .github/workflows/opam.yml | 3 + Makefile | 11 +- ppx/dune | 14 + ...reactjs_jsx_ppx.ml => reason_react_ppx.ml} | 0 ppx/src/dune | 6 - ppx/{test => }/standalone.ml | 4 +- ppx/test/component.t/input.re | 79 + ppx/test/component.t/run.t | 211 + ppx/test/dune | 52 +- ppx/test/external.t/input.re | 5 + ppx/test/external.t/run.t | 22 + ppx/test/fragment.t/input.re | 6 + ppx/test/fragment.t/run.t | 20 + ppx/test/functor.t/input.re | 10 + ppx/test/functor.t/run.t | 20 + .../{merlin => }/issue-429.t/component.re | 0 ppx/test/{merlin => }/issue-429.t/run.t | 0 .../input.re} | 1 + ppx/test/location.t/run.t | 3371 ++++++++++++++++ ppx/test/lower.t/input.re | 54 + ppx/test/lower.t/run.t | 198 + ppx/test/merlin/dune | 3 - ppx/test/output_locations.expected | 3432 ----------------- ppx/test/ppx.sh | 12 + ppx/test/ppx_with_refmt.sh | 12 + ppx/test/{merlin => }/simple.t/component.re | 0 ppx/test/{merlin => }/simple.t/run.t | 0 ppx/test/upper.t/input.re | 28 + ppx/test/upper.t/run.t | 58 + .../{merlin => }/uppercase.t/component.re | 0 ppx/test/{merlin => }/uppercase.t/run.t | 0 31 files changed, 4143 insertions(+), 3489 deletions(-) create mode 100644 ppx/dune rename ppx/{src/reactjs_jsx_ppx.ml => reason_react_ppx.ml} (100%) delete mode 100644 ppx/src/dune rename ppx/{test => }/standalone.ml (59%) create mode 100644 ppx/test/component.t/input.re create mode 100644 ppx/test/component.t/run.t create mode 100644 ppx/test/external.t/input.re create mode 100644 ppx/test/external.t/run.t create mode 100644 ppx/test/fragment.t/input.re create mode 100644 ppx/test/fragment.t/run.t create mode 100644 ppx/test/functor.t/input.re create mode 100644 ppx/test/functor.t/run.t rename ppx/test/{merlin => }/issue-429.t/component.re (100%) rename ppx/test/{merlin => }/issue-429.t/run.t (100%) rename ppx/test/{input_locations.re => location.t/input.re} (99%) create mode 100644 ppx/test/location.t/run.t create mode 100644 ppx/test/lower.t/input.re create mode 100644 ppx/test/lower.t/run.t delete mode 100644 ppx/test/merlin/dune delete mode 100644 ppx/test/output_locations.expected create mode 100755 ppx/test/ppx.sh create mode 100755 ppx/test/ppx_with_refmt.sh rename ppx/test/{merlin => }/simple.t/component.re (100%) rename ppx/test/{merlin => }/simple.t/run.t (100%) create mode 100644 ppx/test/upper.t/input.re create mode 100644 ppx/test/upper.t/run.t rename ppx/test/{merlin => }/uppercase.t/component.re (100%) rename ppx/test/{merlin => }/uppercase.t/run.t (100%) diff --git a/.github/workflows/opam.yml b/.github/workflows/opam.yml index 065df9a31..91c3a2aac 100644 --- a/.github/workflows/opam.yml +++ b/.github/workflows/opam.yml @@ -68,6 +68,9 @@ jobs: - name: Test run: make test + - name: Jest + run: make jest + - name: Save cache when not Windows uses: actions/cache/save@v3 if: steps.opam-cache.outputs.cache-hit != 'true' && runner.os != 'Windows' diff --git a/Makefile b/Makefile index bcb5c73db..f2c192652 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,17 @@ dev: ## Build in watch mode clean: ## Clean artifacts @$(DUNE) clean +.PHONY: jest +jest: ## Run the jest unit tests + @npx jest + +.PHONY: jest-watch +jest-watch: ## Run the jest unit tests in watch mode + @npx jest --watch + .PHONY: test -test: ## Run the unit tests +test: ## Run the runtests from dune (snapshot) @$(DUNE) build @runtest - @npx jest .PHONY: test-watch test-watch: ## Run the unit tests in watch mode diff --git a/ppx/dune b/ppx/dune new file mode 100644 index 000000000..5deec4f0a --- /dev/null +++ b/ppx/dune @@ -0,0 +1,14 @@ +(library + (name reason_react_ppx) + (modules reason_react_ppx) + (public_name reason-react-ppx) + (flags :standard -w -9) + (kind ppx_rewriter) + (libraries ppxlib)) + +(executable + (name standalone) + (modules standalone) + (package reason-react-ppx) + (public_name reason-react-ppx.standalone) + (libraries reason-react-ppx ppxlib)) diff --git a/ppx/src/reactjs_jsx_ppx.ml b/ppx/reason_react_ppx.ml similarity index 100% rename from ppx/src/reactjs_jsx_ppx.ml rename to ppx/reason_react_ppx.ml diff --git a/ppx/src/dune b/ppx/src/dune deleted file mode 100644 index 02e03c625..000000000 --- a/ppx/src/dune +++ /dev/null @@ -1,6 +0,0 @@ -(library - (name reason_react_ppx) - (kind ppx_rewriter) - (public_name reason-react-ppx) - (flags :standard -w -9) - (libraries ppxlib)) diff --git a/ppx/test/standalone.ml b/ppx/standalone.ml similarity index 59% rename from ppx/test/standalone.ml rename to ppx/standalone.ml index 273cf475e..6f7ee4867 100644 --- a/ppx/test/standalone.ml +++ b/ppx/standalone.ml @@ -1,4 +1,2 @@ -open Ppxlib - (* To run as a standalone binary, run the registered drivers *) -let () = Driver.standalone () +let () = Ppxlib.Driver.standalone () diff --git a/ppx/test/component.t/input.re b/ppx/test/component.t/input.re new file mode 100644 index 000000000..832e95bb1 --- /dev/null +++ b/ppx/test/component.t/input.re @@ -0,0 +1,79 @@ +module React_component_with_props = { + [@react.component] + let make = (~lola) => { +
{React.string(lola)}
; + }; +}; + +let react_component_with_props = ; + +module Upper_case_with_fragment_as_root = { + [@react.component] + let make = (~name="") => + <> +
{React.string("First " ++ name)}
+ {React.string("2nd " ++ name)} + ; +}; + +module Using_React_memo = { + [@react.component] + let make = + React.memo((~a) => +
{Printf.sprintf("`a` is %s", a) |> React.string}
+ ); +}; + +module Using_memo_custom_compare_Props = { + [@react.component] + let make = + React.memoCustomCompareProps( + (~a) =>
{Printf.sprintf("`a` is %d", a) |> React.string}
, + (prevPros, nextProps) => false, + ); +}; + +module Forward_Ref = { + [@react.component] + let make = + React.forwardRef((~children, ~buttonRef) => { + + }); +}; + +module Onclick_handler_button = { + [@react.component] + let make = (~name, ~isDisabled=?) => { + let onClick = event => Js.log(event); +