Skip to content

Commit

Permalink
test: preprocessor directory
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Sherratt <[email protected]>
  • Loading branch information
gridbugs authored and rgrinberg committed Feb 21, 2023
1 parent 93a70eb commit b6d2872
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 3.7)
(package (name foo))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
printf 'let () = print_endline "foo (from the rewrite.sh script in the project root directory)"'
23 changes: 23 additions & 0 deletions test/blackbox-tests/test-cases/preprocessor-directory.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
This test exercises the logic for choosing the directory from which to invoke
the preprocessor command. There are two rewrite.sh scripts in this test: one in
the root directory which rewrites the source to print "foo ..." and one in the
src directory which writes the source to print "bar ...".

Initially the project uses dune lang 3.7 so the preprocessor command is invoked
from the project root:
$ cat dune-project
(lang dune 3.7)
(package (name foo))
$ dune exec ./src/foo.exe
foo (from the rewrite.sh script in the project root directory)

Change the versiono of the dune language to 3.8:
$ sed -i.bak 's/(lang dune 3.7)/(lang dune 3.8)/' dune-project

Now the preprocessor should be invoked from the src directory because the dune
file which specifies the preprocessor is located there:
$ cat dune-project
(lang dune 3.8)
(package (name foo))
$ dune exec ./src/foo.exe
bar (from the rewrite.sh script in the src directory)
11 changes: 11 additions & 0 deletions test/blackbox-tests/test-cases/preprocessor-directory.t/src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; An executable which invokes a rewriter to exercise the logic for choosing the
; directory in which to invoke the rewriter. This project has two files named
; "rewrite.sh". One next to this dune file, and one in the project root. This
; project is designed to work in both the case where the rewriter is invoked
; from the project root (the behaviour in dune <= 3.7) and from the directory
; containing the dune file that specifies the preprocessing logic.
(executable
(public_name foo)
(preprocessor_deps rewrite.sh ../rewrite.sh)
(preprocess
(pps ppx_inline_test -- -pp ./rewrite.sh)))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
printf 'let () = print_endline "bar (from the rewrite.sh script in the src directory)"'

0 comments on commit b6d2872

Please sign in to comment.