From 55176eb333334dab90d4c91b8fd32e46ef4b3d5e Mon Sep 17 00:00:00 2001 From: David Sancho Date: Mon, 19 Oct 2020 12:15:57 +0200 Subject: [PATCH] fix: Run ppx as main, not standalone --- bin/Bin.re | 18 +++++++++++++++++- test/dune | 8 ++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/bin/Bin.re b/bin/Bin.re index 49f3834..8eda5ff 100644 --- a/bin/Bin.re +++ b/bin/Bin.re @@ -1 +1,17 @@ -let () = Ppxlib.Driver.standalone(); +let argv = + switch (Sys.argv |> Array.to_list) { + | [program, ...rest] => + switch (List.rev(rest)) { + | [output_file, input_file, ...args] => + List.concat([ + [program], + List.rev(args), + [input_file, "-o", output_file, "--dump-ast"], + ]) + |> Array.of_list + | _ => Sys.argv + } + | _ => Sys.argv + }; + +let () = Migrate_parsetree.Driver.run_main(~argv, ()); diff --git a/test/dune b/test/dune index b4985e6..e68825f 100644 --- a/test/dune +++ b/test/dune @@ -9,7 +9,7 @@ ; expect the process to fail, capturing stderr (with-stderr-to %{targets} - (bash "! ./%{pp} -no-color -impl %{input}") + (bash "! ./%{pp} %{input}") ) ) ) @@ -36,7 +36,7 @@ ; expect the process to fail, capturing stderr (with-stderr-to %{targets} - (bash "! ./%{pp} -no-color -impl %{input}") + (bash "! ./%{pp} %{input}") ) ) ) @@ -63,7 +63,7 @@ ; expect the process to fail, capturing stderr (with-stderr-to %{targets} - (bash "! ./%{pp} -no-color -impl %{input}") + (bash "! ./%{pp} %{input}") ) ) ) @@ -90,7 +90,7 @@ ; expect the process to fail, capturing stderr (with-stderr-to %{targets} - (bash "! ./%{pp} -no-color -impl %{input}") + (bash "! ./%{pp} %{input}") ) ) )