Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 23336db

Browse files
committed
move ppx tests to own folder, remove "none" as default arg value, cleanup
1 parent 739a1df commit 23336db

File tree

9 files changed

+10
-15
lines changed

9 files changed

+10
-15
lines changed

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ lib/rescript.exe: $(CLI_FILES)
5050

5151
build-native: lib/refmt.exe lib/rescript.exe depend
5252

53-
build-ppx: src/reactjs_jsx_ppx.cmx
54-
5553
bootstrap: build-native
5654
ocaml unix.cma ./scripts/bspack.ml -bs-main Res_cli -I src -o ./lib/rescript.ml
5755
./lib/rescript.exe -parse ml -print ns ./lib/Rescript.ml > ./lib/Rescript2.ml
@@ -97,4 +95,4 @@ clean:
9795
rm -rf lib/rescript.exe
9896
rm -rf lib/test.exe
9997
git clean -dfx src
100-
.PHONY: clean test roundtrip-test termination dce exception reanalyze bootstrap build-native build-ppx
98+
.PHONY: clean test roundtrip-test termination dce exception reanalyze bootstrap build-native

src/res_cli.ml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ end = struct
179179
let origin = ref ""
180180
let interface = ref false
181181
let report = ref "pretty"
182-
let ppx = ref "none"
182+
let ppx = ref ""
183183

184184
let usage = "Usage:\n rescript <options> <file>\n\n" ^
185185
"Examples:\n" ^
@@ -230,11 +230,6 @@ module CliArgProcessor = struct
230230
| _ -> false
231231
in
232232

233-
let ppx = match ppx with
234-
| "jsx" -> `Jsx
235-
| _ -> `None
236-
in
237-
238233
let Parser backend = parsingEngine in
239234
(* This is the whole purpose of the Color module above *)
240235
Color.setup None;
@@ -252,8 +247,8 @@ module CliArgProcessor = struct
252247
end
253248
else
254249
let parsetree = match ppx with
255-
| `Jsx -> Reactjs_jsx_ppx.rewrite_signature parseResult.parsetree
256-
| `None -> parseResult.parsetree
250+
| "jsx" -> Reactjs_jsx_ppx.rewrite_signature parseResult.parsetree
251+
| _ -> parseResult.parsetree
257252
in
258253
printEngine.printInterface
259254
~width ~filename ~comments:parseResult.comments parsetree
@@ -271,8 +266,8 @@ module CliArgProcessor = struct
271266
end
272267
else
273268
let parsetree = match ppx with
274-
| `Jsx -> Reactjs_jsx_ppx.rewrite_implementation parseResult.parsetree
275-
| `None -> parseResult.parsetree
269+
| "jsx" -> Reactjs_jsx_ppx.rewrite_implementation parseResult.parsetree
270+
| _ -> parseResult.parsetree
276271
in
277272
printEngine.printImplementation
278273
~width ~filename ~comments:parseResult.comments parsetree
File renamed without changes.

tests/runner.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ let makeReproducibleFilename = (txt) => {
202202
})
203203
};
204204

205-
global.runPrinter = (dirname, ppx = "none") => {
205+
global.runPrinter = (dirname, ppx = "") => {
206206
fs.readdirSync(dirname).forEach((base) => {
207207
let filename = path.join(dirname, base);
208208

@@ -225,7 +225,9 @@ Make sure the test input is syntactically valid.`;
225225
expect(result).toMatchSnapshot();
226226
}
227227

228-
if (process.env.ROUNDTRIP_TEST && ppx === "none") {
228+
// Only run roundtrip tests in ppx-free tests.
229+
// Ppxs are only applied in .res syntax, not .re, so resulting ASTs would not match
230+
if (process.env.ROUNDTRIP_TEST && ppx === "") {
229231
let intf = isInterface(filename);
230232
let sexpAst = parseFileToSexp(filename);
231233
let result2 = parseNapkinStdinToNapkin(result, intf, 80);

0 commit comments

Comments
 (0)