From 272f4c201d1d3e0d42f126e0cc9138d50a700e91 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 31 Jan 2026 17:26:34 -0800 Subject: [PATCH 1/9] build: remove circular dependency between reason-react{,-ppx} at test time --- flake.nix | 11 ++++++++--- ppx/test/dune | 1 - .../components-destructured-error.t/component.re | 0 .../components-destructured-error.t/run.t | 0 {ppx/test => test/blackbox-tests}/hover.t | 0 .../blackbox-tests}/issue-429.t/component.re | 0 {ppx/test => test/blackbox-tests}/issue-429.t/run.t | 0 .../blackbox-tests}/key-as-prop-error.t/component.re | 0 .../blackbox-tests}/key-as-prop-error.t/run.t | 0 {ppx/test => test/blackbox-tests}/keys.t/component.re | 0 {ppx/test => test/blackbox-tests}/keys.t/run.t | 0 .../test => test/blackbox-tests}/optional-arg-check.t | 0 {ppx/test => test/blackbox-tests}/react.t | 0 .../blackbox-tests}/simple.t/component.re | 0 {ppx/test => test/blackbox-tests}/simple.t/run.t | 0 .../blackbox-tests}/uppercase.t/component.re | 0 {ppx/test => test/blackbox-tests}/uppercase.t/run.t | 0 17 files changed, 8 insertions(+), 4 deletions(-) rename {ppx/test => test/blackbox-tests}/components-destructured-error.t/component.re (100%) rename {ppx/test => test/blackbox-tests}/components-destructured-error.t/run.t (100%) rename {ppx/test => test/blackbox-tests}/hover.t (100%) rename {ppx/test => test/blackbox-tests}/issue-429.t/component.re (100%) rename {ppx/test => test/blackbox-tests}/issue-429.t/run.t (100%) rename {ppx/test => test/blackbox-tests}/key-as-prop-error.t/component.re (100%) rename {ppx/test => test/blackbox-tests}/key-as-prop-error.t/run.t (100%) rename {ppx/test => test/blackbox-tests}/keys.t/component.re (100%) rename {ppx/test => test/blackbox-tests}/keys.t/run.t (100%) rename {ppx/test => test/blackbox-tests}/optional-arg-check.t (100%) rename {ppx/test => test/blackbox-tests}/react.t (100%) rename {ppx/test => test/blackbox-tests}/simple.t/component.re (100%) rename {ppx/test => test/blackbox-tests}/simple.t/run.t (100%) rename {ppx/test => test/blackbox-tests}/uppercase.t/component.re (100%) rename {ppx/test => test/blackbox-tests}/uppercase.t/run.t (100%) diff --git a/flake.nix b/flake.nix index 8f5ffac7f..228d9d89d 100644 --- a/flake.nix +++ b/flake.nix @@ -52,9 +52,12 @@ ]; }; - # Due to a Reason version mismatch, the generated OCaml PPX diff - # looks different - doCheck = false; + doCheck = true; + nativeCheckInputs = [ + reason + merlin + pkgs.jq + ]; propagatedBuildInputs = [ ppxlib_gt_0_37 ]; }; @@ -81,6 +84,8 @@ nativeBuildInputs = [ melange reason + merlin + pkgs.jq ]; propagatedBuildInputs = [ melange diff --git a/ppx/test/dune b/ppx/test/dune index 1e0a153a6..5dc5639d6 100644 --- a/ppx/test/dune +++ b/ppx/test/dune @@ -1,7 +1,6 @@ (cram (package reason-react-ppx) (deps - (package reason-react) %{bin:reason-react-ppx} %{bin:refmt} %{bin:dune} diff --git a/ppx/test/components-destructured-error.t/component.re b/test/blackbox-tests/components-destructured-error.t/component.re similarity index 100% rename from ppx/test/components-destructured-error.t/component.re rename to test/blackbox-tests/components-destructured-error.t/component.re diff --git a/ppx/test/components-destructured-error.t/run.t b/test/blackbox-tests/components-destructured-error.t/run.t similarity index 100% rename from ppx/test/components-destructured-error.t/run.t rename to test/blackbox-tests/components-destructured-error.t/run.t diff --git a/ppx/test/hover.t b/test/blackbox-tests/hover.t similarity index 100% rename from ppx/test/hover.t rename to test/blackbox-tests/hover.t diff --git a/ppx/test/issue-429.t/component.re b/test/blackbox-tests/issue-429.t/component.re similarity index 100% rename from ppx/test/issue-429.t/component.re rename to test/blackbox-tests/issue-429.t/component.re diff --git a/ppx/test/issue-429.t/run.t b/test/blackbox-tests/issue-429.t/run.t similarity index 100% rename from ppx/test/issue-429.t/run.t rename to test/blackbox-tests/issue-429.t/run.t diff --git a/ppx/test/key-as-prop-error.t/component.re b/test/blackbox-tests/key-as-prop-error.t/component.re similarity index 100% rename from ppx/test/key-as-prop-error.t/component.re rename to test/blackbox-tests/key-as-prop-error.t/component.re diff --git a/ppx/test/key-as-prop-error.t/run.t b/test/blackbox-tests/key-as-prop-error.t/run.t similarity index 100% rename from ppx/test/key-as-prop-error.t/run.t rename to test/blackbox-tests/key-as-prop-error.t/run.t diff --git a/ppx/test/keys.t/component.re b/test/blackbox-tests/keys.t/component.re similarity index 100% rename from ppx/test/keys.t/component.re rename to test/blackbox-tests/keys.t/component.re diff --git a/ppx/test/keys.t/run.t b/test/blackbox-tests/keys.t/run.t similarity index 100% rename from ppx/test/keys.t/run.t rename to test/blackbox-tests/keys.t/run.t diff --git a/ppx/test/optional-arg-check.t b/test/blackbox-tests/optional-arg-check.t similarity index 100% rename from ppx/test/optional-arg-check.t rename to test/blackbox-tests/optional-arg-check.t diff --git a/ppx/test/react.t b/test/blackbox-tests/react.t similarity index 100% rename from ppx/test/react.t rename to test/blackbox-tests/react.t diff --git a/ppx/test/simple.t/component.re b/test/blackbox-tests/simple.t/component.re similarity index 100% rename from ppx/test/simple.t/component.re rename to test/blackbox-tests/simple.t/component.re diff --git a/ppx/test/simple.t/run.t b/test/blackbox-tests/simple.t/run.t similarity index 100% rename from ppx/test/simple.t/run.t rename to test/blackbox-tests/simple.t/run.t diff --git a/ppx/test/uppercase.t/component.re b/test/blackbox-tests/uppercase.t/component.re similarity index 100% rename from ppx/test/uppercase.t/component.re rename to test/blackbox-tests/uppercase.t/component.re diff --git a/ppx/test/uppercase.t/run.t b/test/blackbox-tests/uppercase.t/run.t similarity index 100% rename from ppx/test/uppercase.t/run.t rename to test/blackbox-tests/uppercase.t/run.t From bace7a74ba2982d4a1227fc8b6b61b179b7b7b13 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 31 Jan 2026 17:42:52 -0800 Subject: [PATCH 2/9] fix interpreter --- ppx/test/ppx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppx/test/ppx.sh b/ppx/test/ppx.sh index 773d601db..f2b28c92d 100755 --- a/ppx/test/ppx.sh +++ b/ppx/test/ppx.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eo pipefail From 4f75a4cdcfb997c529e8d08119cb6c9d176c1a7f Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 31 Jan 2026 17:55:45 -0800 Subject: [PATCH 3/9] wut --- ppx/test/dune | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ppx/test/dune b/ppx/test/dune index 5dc5639d6..4a57840b6 100644 --- a/ppx/test/dune +++ b/ppx/test/dune @@ -6,4 +6,6 @@ %{bin:dune} %{bin:jq} %{bin:ocamlmerlin} + %{bin:bash} + %{bin:/usr/bin/env} ppx.sh)) From 1398c5b966d7b8536a23798ae8c9a69ea1e75b8e Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 31 Jan 2026 19:03:49 -0800 Subject: [PATCH 4/9] huh --- ppx/test/dune | 1 - ppx/test/ppx.sh | 2 -- 2 files changed, 3 deletions(-) diff --git a/ppx/test/dune b/ppx/test/dune index 4a57840b6..01cbb7fa9 100644 --- a/ppx/test/dune +++ b/ppx/test/dune @@ -7,5 +7,4 @@ %{bin:jq} %{bin:ocamlmerlin} %{bin:bash} - %{bin:/usr/bin/env} ppx.sh)) diff --git a/ppx/test/ppx.sh b/ppx/test/ppx.sh index f2b28c92d..32db6906a 100755 --- a/ppx/test/ppx.sh +++ b/ppx/test/ppx.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - set -eo pipefail function usage() { From 42daf9ec0ff96a6592d00143490e56df456c9eb5 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 31 Jan 2026 19:10:29 -0800 Subject: [PATCH 5/9] wip --- ppx/test/ppx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppx/test/ppx.sh b/ppx/test/ppx.sh index 32db6906a..261fb5917 100755 --- a/ppx/test/ppx.sh +++ b/ppx/test/ppx.sh @@ -1,4 +1,4 @@ -set -eo pipefail +set -e function usage() { echo "Usage: $(basename "$0") --output re [file.re]" From 9f2f85ee447484b841f6a6a5b8003554b33f8af1 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 31 Jan 2026 19:17:57 -0800 Subject: [PATCH 6/9] wtf --- ppx/test/ppx.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ppx/test/ppx.sh b/ppx/test/ppx.sh index 261fb5917..57ac38c4d 100755 --- a/ppx/test/ppx.sh +++ b/ppx/test/ppx.sh @@ -1,3 +1,5 @@ +#!/bin/sh + set -e function usage() { From e41db8f29c4fbbdb4ae1d680a822959bb5e10f3a Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 31 Jan 2026 19:30:03 -0800 Subject: [PATCH 7/9] bash --- ppx/test/component-without-make.t/run.t | 2 +- ppx/test/component.t/run.t | 2 +- ppx/test/external.t/run.t | 2 +- ppx/test/fragment.t/run.t | 2 +- ppx/test/functor.t/run.t | 2 +- ppx/test/lower.t/run.t | 2 +- ppx/test/record-props-error.t/run.t | 2 +- ppx/test/record-props.t/run.t | 2 +- ppx/test/signature-optional.t/run.t | 2 +- ppx/test/signature.t/run.t | 2 +- ppx/test/upper.t/run.t | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ppx/test/component-without-make.t/run.t b/ppx/test/component-without-make.t/run.t index 90a1a36e9..576d08342 100644 --- a/ppx/test/component-without-make.t/run.t +++ b/ppx/test/component-without-make.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ ../ppx.sh --output ml input.re + $ bash ../ppx.sh --output ml input.re module X_as_main_function = struct external xProps : ?key:string -> unit -> < > Js.t = ""[@@mel.obj ] diff --git a/ppx/test/component.t/run.t b/ppx/test/component.t/run.t index e4abb74f5..84667e2ab 100644 --- a/ppx/test/component.t/run.t +++ b/ppx/test/component.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ ../ppx.sh --output ml input.re + $ bash ../ppx.sh --output ml input.re module React_component_with_props = struct external makeProps : diff --git a/ppx/test/external.t/run.t b/ppx/test/external.t/run.t index 311e16b9c..ae02e5da2 100644 --- a/ppx/test/external.t/run.t +++ b/ppx/test/external.t/run.t @@ -1,4 +1,4 @@ - $ ../ppx.sh --output re input.re + $ bash ../ppx.sh --output re input.re module External = { [@mel.obj] external componentProps: diff --git a/ppx/test/fragment.t/run.t b/ppx/test/fragment.t/run.t index be148546c..0a0a5df49 100644 --- a/ppx/test/fragment.t/run.t +++ b/ppx/test/fragment.t/run.t @@ -1,4 +1,4 @@ - $ ../ppx.sh --output re input.re + $ bash ../ppx.sh --output re input.re let fragment = foo => [@bla] React.jsx( diff --git a/ppx/test/functor.t/run.t b/ppx/test/functor.t/run.t index f9eeca3ad..6bcc0fff2 100644 --- a/ppx/test/functor.t/run.t +++ b/ppx/test/functor.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ ../ppx.sh --output ml input.re + $ bash ../ppx.sh --output ml input.re module type X_int = sig val x : int end module Func(M:X_int) = struct diff --git a/ppx/test/lower.t/run.t b/ppx/test/lower.t/run.t index fcb12ab62..b2f30e430 100644 --- a/ppx/test/lower.t/run.t +++ b/ppx/test/lower.t/run.t @@ -1,4 +1,4 @@ - $ ../ppx.sh --output re input.re + $ bash ../ppx.sh --output re input.re let lower = ReactDOM.jsx("div", ([@merlin.hide] ReactDOM.domProps)()); let lower_empty_attr = ReactDOM.jsx("div", ([@merlin.hide] ReactDOM.domProps)(~className="", ())); diff --git a/ppx/test/record-props-error.t/run.t b/ppx/test/record-props-error.t/run.t index d2440098d..89451bc80 100644 --- a/ppx/test/record-props-error.t/run.t +++ b/ppx/test/record-props-error.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ ../ppx.sh --output ml input.re + $ bash ../ppx.sh --output ml input.re File "output.ml", line 5, characters 68-76: 5 | no_props ^^^^^^^^ diff --git a/ppx/test/record-props.t/run.t b/ppx/test/record-props.t/run.t index fee6dc40a..85cfbe84a 100644 --- a/ppx/test/record-props.t/run.t +++ b/ppx/test/record-props.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ ../ppx.sh --output ml input.re + $ bash ../ppx.sh --output ml input.re module Record_props = struct external makeProps : diff --git a/ppx/test/signature-optional.t/run.t b/ppx/test/signature-optional.t/run.t index 9e1097f91..bee9e2336 100644 --- a/ppx/test/signature-optional.t/run.t +++ b/ppx/test/signature-optional.t/run.t @@ -1,4 +1,4 @@ - $ ../ppx.sh --output ml input.re + $ bash ../ppx.sh --output ml input.re module Greeting : sig external makeProps : diff --git a/ppx/test/signature.t/run.t b/ppx/test/signature.t/run.t index f398d249f..f3c3c4f39 100644 --- a/ppx/test/signature.t/run.t +++ b/ppx/test/signature.t/run.t @@ -1,4 +1,4 @@ - $ ../ppx.sh --output re input.re + $ bash ../ppx.sh --output re input.re module Example = { [@mel.obj] external makeProps: diff --git a/ppx/test/upper.t/run.t b/ppx/test/upper.t/run.t index a5ed6a84c..d9eb5583a 100644 --- a/ppx/test/upper.t/run.t +++ b/ppx/test/upper.t/run.t @@ -1,4 +1,4 @@ - $ ../ppx.sh --output re input.re + $ bash ../ppx.sh --output re input.re let upper = React.jsx(Upper.make, Upper.makeProps()); let upper_prop = React.jsx(Upper.make, Upper.makeProps(~count, ())); let upper_children_single = foo => From a6b25f0e625c33cc123d889f8722f865b48ef9f9 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sun, 1 Feb 2026 13:18:21 -0800 Subject: [PATCH 8/9] test redirection --- ppx/test/component-without-make.t/run.t | 2 +- ppx/test/dune | 3 ++- ppx/test/ppx.sh | 4 +--- ppx/test/run-ppx.sh | 6 ++++++ 4 files changed, 10 insertions(+), 5 deletions(-) create mode 100755 ppx/test/run-ppx.sh diff --git a/ppx/test/component-without-make.t/run.t b/ppx/test/component-without-make.t/run.t index 576d08342..15a1fab0a 100644 --- a/ppx/test/component-without-make.t/run.t +++ b/ppx/test/component-without-make.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ bash ../ppx.sh --output ml input.re + $ ../run-ppx.sh --output ml input.re module X_as_main_function = struct external xProps : ?key:string -> unit -> < > Js.t = ""[@@mel.obj ] diff --git a/ppx/test/dune b/ppx/test/dune index 01cbb7fa9..129e2c645 100644 --- a/ppx/test/dune +++ b/ppx/test/dune @@ -7,4 +7,5 @@ %{bin:jq} %{bin:ocamlmerlin} %{bin:bash} - ppx.sh)) + ppx.sh + run-ppx.sh)) diff --git a/ppx/test/ppx.sh b/ppx/test/ppx.sh index 57ac38c4d..32db6906a 100755 --- a/ppx/test/ppx.sh +++ b/ppx/test/ppx.sh @@ -1,6 +1,4 @@ -#!/bin/sh - -set -e +set -eo pipefail function usage() { echo "Usage: $(basename "$0") --output re [file.re]" diff --git a/ppx/test/run-ppx.sh b/ppx/test/run-ppx.sh new file mode 100755 index 000000000..4144c936f --- /dev/null +++ b/ppx/test/run-ppx.sh @@ -0,0 +1,6 @@ + +root_path=$PWD + +bash "$(dirname "$0")/ppx.sh" "$@" + +cd "$root_path" From d70bb6daf64f60e06d4aa28597972665cd3e11bb Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sun, 1 Feb 2026 13:27:38 -0800 Subject: [PATCH 9/9] invert --- ppx/test/component-without-make.t/run.t | 2 +- ppx/test/component.t/run.t | 2 +- ppx/test/external.t/run.t | 2 +- ppx/test/fragment.t/run.t | 2 +- ppx/test/functor.t/run.t | 2 +- ppx/test/lower.t/run.t | 2 +- ppx/test/ppx.sh | 26 ++----------------------- ppx/test/record-props-error.t/run.t | 2 +- ppx/test/record-props.t/run.t | 2 +- ppx/test/run-ppx.sh | 25 +++++++++++++++++++++--- ppx/test/signature-optional.t/run.t | 2 +- ppx/test/signature.t/run.t | 2 +- ppx/test/upper.t/run.t | 2 +- 13 files changed, 35 insertions(+), 38 deletions(-) diff --git a/ppx/test/component-without-make.t/run.t b/ppx/test/component-without-make.t/run.t index 15a1fab0a..90a1a36e9 100644 --- a/ppx/test/component-without-make.t/run.t +++ b/ppx/test/component-without-make.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ ../run-ppx.sh --output ml input.re + $ ../ppx.sh --output ml input.re module X_as_main_function = struct external xProps : ?key:string -> unit -> < > Js.t = ""[@@mel.obj ] diff --git a/ppx/test/component.t/run.t b/ppx/test/component.t/run.t index 84667e2ab..e4abb74f5 100644 --- a/ppx/test/component.t/run.t +++ b/ppx/test/component.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ bash ../ppx.sh --output ml input.re + $ ../ppx.sh --output ml input.re module React_component_with_props = struct external makeProps : diff --git a/ppx/test/external.t/run.t b/ppx/test/external.t/run.t index ae02e5da2..311e16b9c 100644 --- a/ppx/test/external.t/run.t +++ b/ppx/test/external.t/run.t @@ -1,4 +1,4 @@ - $ bash ../ppx.sh --output re input.re + $ ../ppx.sh --output re input.re module External = { [@mel.obj] external componentProps: diff --git a/ppx/test/fragment.t/run.t b/ppx/test/fragment.t/run.t index 0a0a5df49..be148546c 100644 --- a/ppx/test/fragment.t/run.t +++ b/ppx/test/fragment.t/run.t @@ -1,4 +1,4 @@ - $ bash ../ppx.sh --output re input.re + $ ../ppx.sh --output re input.re let fragment = foo => [@bla] React.jsx( diff --git a/ppx/test/functor.t/run.t b/ppx/test/functor.t/run.t index 6bcc0fff2..f9eeca3ad 100644 --- a/ppx/test/functor.t/run.t +++ b/ppx/test/functor.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ bash ../ppx.sh --output ml input.re + $ ../ppx.sh --output ml input.re module type X_int = sig val x : int end module Func(M:X_int) = struct diff --git a/ppx/test/lower.t/run.t b/ppx/test/lower.t/run.t index b2f30e430..fcb12ab62 100644 --- a/ppx/test/lower.t/run.t +++ b/ppx/test/lower.t/run.t @@ -1,4 +1,4 @@ - $ bash ../ppx.sh --output re input.re + $ ../ppx.sh --output re input.re let lower = ReactDOM.jsx("div", ([@merlin.hide] ReactDOM.domProps)()); let lower_empty_attr = ReactDOM.jsx("div", ([@merlin.hide] ReactDOM.domProps)(~className="", ())); diff --git a/ppx/test/ppx.sh b/ppx/test/ppx.sh index 32db6906a..dd0078ab2 100755 --- a/ppx/test/ppx.sh +++ b/ppx/test/ppx.sh @@ -1,25 +1,3 @@ -set -eo pipefail -function usage() { - echo "Usage: $(basename "$0") --output re [file.re]" - echo " $(basename "$0") --output ml [file.re]" -} - -if [ -z "$3" ]; then - usage - exit -fi - -refmt --parse re --print ml "$3" > output.ml -reason-react-ppx --impl output.ml -o temp.ml - -if [ "$2" == "ml" ]; then - cat temp.ml - exit -elif [ "$2" == "re" ]; then - refmt --parse ml --print re temp.ml - exit -else - usage - exit -fi +root_path=$PWD +bash "$(dirname "$0")/run-ppx.sh" "$@" diff --git a/ppx/test/record-props-error.t/run.t b/ppx/test/record-props-error.t/run.t index 89451bc80..d2440098d 100644 --- a/ppx/test/record-props-error.t/run.t +++ b/ppx/test/record-props-error.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ bash ../ppx.sh --output ml input.re + $ ../ppx.sh --output ml input.re File "output.ml", line 5, characters 68-76: 5 | no_props ^^^^^^^^ diff --git a/ppx/test/record-props.t/run.t b/ppx/test/record-props.t/run.t index 85cfbe84a..fee6dc40a 100644 --- a/ppx/test/record-props.t/run.t +++ b/ppx/test/record-props.t/run.t @@ -1,6 +1,6 @@ Since we generate invalid syntax for the argument of the make fn `(Props : <>)` We need to output ML syntax here, otherwise refmt could not parse it. - $ bash ../ppx.sh --output ml input.re + $ ../ppx.sh --output ml input.re module Record_props = struct external makeProps : diff --git a/ppx/test/run-ppx.sh b/ppx/test/run-ppx.sh index 4144c936f..32db6906a 100755 --- a/ppx/test/run-ppx.sh +++ b/ppx/test/run-ppx.sh @@ -1,6 +1,25 @@ +set -eo pipefail -root_path=$PWD +function usage() { + echo "Usage: $(basename "$0") --output re [file.re]" + echo " $(basename "$0") --output ml [file.re]" +} -bash "$(dirname "$0")/ppx.sh" "$@" +if [ -z "$3" ]; then + usage + exit +fi -cd "$root_path" +refmt --parse re --print ml "$3" > output.ml +reason-react-ppx --impl output.ml -o temp.ml + +if [ "$2" == "ml" ]; then + cat temp.ml + exit +elif [ "$2" == "re" ]; then + refmt --parse ml --print re temp.ml + exit +else + usage + exit +fi diff --git a/ppx/test/signature-optional.t/run.t b/ppx/test/signature-optional.t/run.t index bee9e2336..9e1097f91 100644 --- a/ppx/test/signature-optional.t/run.t +++ b/ppx/test/signature-optional.t/run.t @@ -1,4 +1,4 @@ - $ bash ../ppx.sh --output ml input.re + $ ../ppx.sh --output ml input.re module Greeting : sig external makeProps : diff --git a/ppx/test/signature.t/run.t b/ppx/test/signature.t/run.t index f3c3c4f39..f398d249f 100644 --- a/ppx/test/signature.t/run.t +++ b/ppx/test/signature.t/run.t @@ -1,4 +1,4 @@ - $ bash ../ppx.sh --output re input.re + $ ../ppx.sh --output re input.re module Example = { [@mel.obj] external makeProps: diff --git a/ppx/test/upper.t/run.t b/ppx/test/upper.t/run.t index d9eb5583a..a5ed6a84c 100644 --- a/ppx/test/upper.t/run.t +++ b/ppx/test/upper.t/run.t @@ -1,4 +1,4 @@ - $ bash ../ppx.sh --output re input.re + $ ../ppx.sh --output re input.re let upper = React.jsx(Upper.make, Upper.makeProps()); let upper_prop = React.jsx(Upper.make, Upper.makeProps(~count, ())); let upper_children_single = foo =>