Skip to content

Commit

Permalink
Test cases for bugs spotted in MPR7873
Browse files Browse the repository at this point in the history
This ensures that Topdirs.opt_directory works both in a compiled
toplevel both when used interactively (GPR#1041 regression) and when
called with a script argument (broken since the dawn of time)
  • Loading branch information
dra27 committed Nov 20, 2018
1 parent 2e073b5 commit 4bb27d2
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions testsuite/tests/tool-toplevel/ocamltests
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ exotic_lists.ml
pr6468.ml
pr7060.ml
pr7751.ml
pr7873.ml
strings.ml
tracing.ml
error_highlighting.ml
26 changes: 26 additions & 0 deletions testsuite/tests/tool-toplevel/pr7873.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(* TEST
files = "pr7873.sh"
* setup-ocamlc.byte-build-env
** script
script = "mkdir hello"
*** script
script = "cp ${test_source_directory}/pr7873_hello.ml hello/hello.ml"
**** ocamlc.byte
module = "hello/hello.ml"
***** ocamlc.byte
module = ""
program = "${test_build_directory}/mytop.exe"
include ocamlcommon
libraries += "ocamlbytecomp ocamltoplevel"
flags = "-I hello"
all_modules = "pr7873.ml hello.cmo topstart.cmo"
****** script
script = "sh ./pr7873.sh"
******* check-program-output
****** script
script = "sh ./pr7873.sh direct"
******* check-program-output
reference = "${test_source_directory}/pr7873a.reference"
*)

let () = Topdirs.dir_directory "hello"
2 changes: 2 additions & 0 deletions testsuite/tests/tool-toplevel/pr7873.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
42- : unit = ()

9 changes: 9 additions & 0 deletions testsuite/tests/tool-toplevel/pr7873.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ $# -gt 0 ] ; then
echo 'print_int Hello.hello' > test.ml
${ocamlrun} ./mytop.exe -noinit -nostdlib -I ${ocamlsrcdir}/stdlib test.ml
else
echo 'print_int Hello.hello;;' | ${ocamlrun} ./mytop.exe -noinit -nostdlib -I ${ocamlsrcdir}/stdlib -no-version -noprompt
fi
exit 0
1 change: 1 addition & 0 deletions testsuite/tests/tool-toplevel/pr7873_hello.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let hello = 42
1 change: 1 addition & 0 deletions testsuite/tests/tool-toplevel/pr7873a.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42

0 comments on commit 4bb27d2

Please sign in to comment.