This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(package utop)))
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
This test makes sure that the utop subcommand does not load optional libraries.
|
||||
|
||||
$ mkdir testutop
|
||||
$ cat <<EOF > testutop/dune
|
||||
> (library
|
||||
> (name testutop)
|
||||
> (optional)
|
||||
> (libraries does_not_exist))
|
||||
> EOF
|
||||
$ echo 'let run () = print_endline "this will never run"' > testutop/testutop.ml
|
||||
$ echo "(lang dune 2.0)" > dune-project
|
||||
$ echo 'let () = print_endline "No Error"' > init_test.ml
|
||||
|
||||
$ dune utop testutop -- init_test.ml
|
||||
No Error
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
dune utop should read libraries in (subdir ..)
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.6)
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (data_only_dirs foo)
|
||||
> (subdir foo
|
||||
> (library
|
||||
> (modules foolib)
|
||||
> (name foolib)))
|
||||
> EOF
|
||||
|
||||
$ mkdir foo
|
||||
$ cat >foo/foolib.ml <<EOF
|
||||
> let hw () = print_endline "foolib"
|
||||
> EOF
|
||||
|
||||
$ cat >foo.ml <<EOF
|
||||
> Foolib.hw ()
|
||||
> EOF
|
||||
|
||||
$ dune utop . -- foo.ml
|
||||
foolib
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 2.6)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(library
|
||||
(name forutop_impl_2)
|
||||
(implements forutop))
|
||||
|
|
@ -0,0 +1 @@
|
|||
let run () = print_endline "shouldn't be selected"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(library
|
||||
(name forutop_impl)
|
||||
(implements forutop))
|
||||
|
|
@ -0,0 +1 @@
|
|||
let run () = print_endline "selected by default impl"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
(name forutop)
|
||||
(virtual_modules forutop)
|
||||
(default_implementation forutop_impl))
|
||||
|
|
@ -0,0 +1 @@
|
|||
val run : unit -> unit
|
||||
|
|
@ -0,0 +1 @@
|
|||
Forutop.run ();;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$ dune utop . init_forutop.ml
|
||||
selected by default impl
|
||||
|
|
@ -0,0 +1 @@
|
|||
(library (name mylib))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.1)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
By default, dune utop tries to make a toplevel for the current directory:
|
||||
|
||||
$ echo 'Stdlib.exit 0;;' | dune utop . -- -init "" | grep -v 'version'
|
||||
Enter "#help;;" for help.
|
||||
|
||||
Init file not found: "".
|
||||
#
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.1)
|
||||
|
|
@ -0,0 +1 @@
|
|||
(library (name private_lib_a))
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
Utop will load libs recursively:
|
||||
|
||||
$ echo 'Stdlib.exit 0;;' | dune utop . -- -init "" | grep -v 'version'
|
||||
Enter "#help;;" for help.
|
||||
|
||||
Init file not found: "".
|
||||
#
|
||||
|
||||
|
||||
The message where the library path does not exist is different:
|
||||
|
||||
$ dune utop does-not-exist . -- -init ""
|
||||
Error: cannot find directory: does-not-exist
|
||||
[1]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executable
|
||||
(name foo)
|
||||
(libraries bar))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
module Bar = Bar
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 2.5)
|
||||
|
|
@ -0,0 +1 @@
|
|||
let run () = print_endline "loaded external library successfully"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(library
|
||||
(name bar))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
let () =
|
||||
Bar.run ();
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Running dune utop in a project with only executables loads external libraries
|
||||
$ dune utop bin -- load_executable_libraries.ml
|
||||
loaded external library successfully
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 2.5)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
(name fooppx)
|
||||
(kind ppx_rewriter)
|
||||
(libraries ppxlib))
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
open Ppxlib
|
||||
|
||||
let rules =
|
||||
let extension =
|
||||
Extension.declare "foo" Expression Ast_pattern.__ (fun ~loc ~path:_ _ ->
|
||||
Ast_builder.Default.estring ~loc "PPX extension")
|
||||
in
|
||||
[ Context_free.Rule.extension extension ]
|
||||
|
||||
let () = Ppxlib.Driver.register_transformation "rules" ~rules
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Running dune utop with directory containing a PPX rewriter
|
||||
$ dune utop ppx -- use_ppx.ml
|
||||
PPX extension
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
let () =
|
||||
Printf.printf "%s\n" [%foo];
|
||||
exit 0
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.0)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(library
|
||||
(name forutop))
|
||||
|
|
@ -0,0 +1 @@
|
|||
let run () = print_endline "hello in utop"
|
||||
|
|
@ -0,0 +1 @@
|
|||
Forutop.run ();;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$ dune utop forutop -- init_forutop.ml
|
||||
hello in utop
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 3.0)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(library
|
||||
(name forutop)
|
||||
(foreign_stubs
|
||||
(language c)
|
||||
(names forutop_stubs)))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
external hello_in_utop: unit -> string = "hello_in_utop"
|
||||
let run () = print_endline (hello_in_utop ())
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#include <caml/alloc.h>
|
||||
|
||||
value hello_in_utop(value v_unit)
|
||||
{
|
||||
return caml_copy_string("hello in utop");
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
Forutop.run ();;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$ dune utop forutop -- init_forutop.ml
|
||||
hello in utop
|
||||
Loading…
Add table
Add a link
Reference in a new issue