This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin dune-glob))
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
open Dune_action_plugin.V1
|
||||
module Glob = Dune_glob.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let+ listing =
|
||||
read_directory_with_glob ~glob:Glob.universal ~path:(Path.of_string "some_dir")
|
||||
in
|
||||
String.concat "; " listing |> Printf.printf "Directory listing: [%s]"
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (data_only_dirs some_dir)
|
||||
> \
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ mkdir some_dir
|
||||
$ touch some_dir/some_file1
|
||||
$ touch some_dir/some_file2
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
Directory listing: [some_file1; some_file2]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let+ data = read_file ~path:(Path.of_string "some_file") in
|
||||
print_endline data
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
This test checks that 'dynamic-run' will not be reexecuted if
|
||||
dependencies do not change (have the same digest) even if
|
||||
they were forced to rebuild.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (target some_file)
|
||||
> (deps (universe))
|
||||
> (action
|
||||
> (progn
|
||||
> (echo "Building some_file!\n")
|
||||
> (with-stdout-to %{target} (echo "Hello from some_file!")))))
|
||||
> \
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
Building some_file!
|
||||
Hello from some_file!
|
||||
|
||||
$ dune runtest
|
||||
Building some_file!
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune_action_plugin dune_glob))
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
open Dune_action_plugin.V1
|
||||
module Glob = Dune_glob.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let glob = Glob.of_string "some_file*" in
|
||||
let+ listing = read_directory_with_glob ~path:(Path.of_string "some_dir") ~glob in
|
||||
String.concat "\n" listing |> print_endline
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ mkdir some_dir
|
||||
|
||||
$ cat > some_dir/dune << EOF
|
||||
> (rule
|
||||
> (target some_file)
|
||||
> (action
|
||||
> (progn
|
||||
> (echo "Building some_file!\n")
|
||||
> (with-stdout-to %{target} (echo "")))))
|
||||
> \
|
||||
> (rule
|
||||
> (target another_file)
|
||||
> (action
|
||||
> (progn
|
||||
> (echo "SHOULD NOT BE PRINTED!")
|
||||
> (with-stdout-to %{target} (echo "")))))
|
||||
> \
|
||||
> (rule
|
||||
> (target some_file_but_different)
|
||||
> (action
|
||||
> (progn
|
||||
> (echo "Building some_file_but_different!\n")
|
||||
> (with-stdout-to %{target} (echo "")))))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
Building some_file!
|
||||
Building some_file_but_different!
|
||||
some_file
|
||||
some_file_but_different
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin dune-glob))
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
open Dune_action_plugin.V1
|
||||
module Glob = Dune_glob.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let+ _ = read_directory_with_glob ~glob:Glob.universal ~path:(Path.of_string ".")
|
||||
and+ _ = write_file ~path:(Path.of_string "some_file") ~data:"Hello from some_file!" in
|
||||
()
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (target some_file)
|
||||
> (action
|
||||
> (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune build some_file 2>&1 | awk '/Internal error/,/unable to serialize/'
|
||||
Internal error, please report upstream including the contents of _build/log.
|
||||
Description:
|
||||
("unable to serialize exception",
|
||||
|
||||
^ This is not great. There is no actual dependency cycle, dune is just
|
||||
interpreting glob dependency too coarsely (it builds all files instead
|
||||
of just bringing the directory listing up to date).
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo1 foo2)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let path = Path.of_string "some_file1"
|
||||
let action = read_file ~path |> stage ~f:(fun data -> write_file ~path ~data)
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let path = Path.of_string "some_file2"
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
write_file ~path ~data:"Hello from some_file2!"
|
||||
|> stage ~f:(fun () ->
|
||||
let+ data = read_file ~path in
|
||||
print_endline data)
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (target some_file1)
|
||||
> (action
|
||||
> (dynamic-run ./foo1.exe)))
|
||||
> \
|
||||
> (rule
|
||||
> (target some_file2)
|
||||
> (action
|
||||
> (dynamic-run ./foo2.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo1.exe ./
|
||||
$ cp ./bin/foo2.exe ./
|
||||
|
||||
$ dune build some_file1
|
||||
Error: Dependency cycle between:
|
||||
_build/default/some_file1
|
||||
[1]
|
||||
|
||||
$ dune build some_file2
|
||||
Error: Dependency cycle between:
|
||||
_build/default/some_file2
|
||||
[1]
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let switch = read_file ~path:(Path.of_string "foo_or_bar") in
|
||||
stage switch ~f:(fun file ->
|
||||
let+ data = read_file ~path:(Path.of_string file) in
|
||||
print_endline data)
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names client)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
This test checks that in case the dependency of multi staged computation changes,
|
||||
only the dependencies up to this stage are rebuilt.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (deps bar_source)
|
||||
> (target bar)
|
||||
> (action
|
||||
> (progn
|
||||
> (echo "Building bar!\n")
|
||||
> (copy %{deps} %{target}))))
|
||||
> \
|
||||
> (rule
|
||||
> (deps foo_source)
|
||||
> (target foo)
|
||||
> (action
|
||||
> (progn
|
||||
> (echo "Building foo!\n")
|
||||
> (copy %{deps} %{target}))))
|
||||
> \
|
||||
> (rule
|
||||
> (deps foo_or_bar_source)
|
||||
> (target foo_or_bar)
|
||||
> (action
|
||||
> (progn
|
||||
> (echo "Building foo_or_bar!\n")
|
||||
> (copy %{deps} %{target}))))
|
||||
> \
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./client.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/client.exe ./
|
||||
|
||||
$ printf "foo" > foo_or_bar_source
|
||||
$ printf "Hello from foo!" > foo_source
|
||||
$ printf "SHOULD NOT BE PRINTED!" > bar_source
|
||||
|
||||
$ dune runtest
|
||||
Building foo_or_bar!
|
||||
Building foo!
|
||||
Hello from foo!
|
||||
|
||||
$ printf "bar" > foo_or_bar_source
|
||||
$ printf "SHOULD NOT BE PRINTED!" > foo_source
|
||||
$ printf "Hello from bar!" > bar_source
|
||||
|
||||
$ dune runtest
|
||||
Building foo_or_bar!
|
||||
Building bar!
|
||||
Hello from bar!
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(cram
|
||||
(applies_to :whole_subtree)
|
||||
(alias run_dynamic)
|
||||
(deps
|
||||
(package dune)))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let () = run (return ())
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
Check that multiple 'dynamic-run' commands within single action are
|
||||
detected and error is printed even if the rule is not executed.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (target some_file)
|
||||
> (action
|
||||
> (progn
|
||||
> (dynamic-run ./foo.exe some_arg)
|
||||
> (dynamic-run ./foo.exe another_arg))))
|
||||
> \
|
||||
> (alias
|
||||
> (name runtest)
|
||||
> (action
|
||||
> (echo "SHOULD NOT BE PRINTED")))
|
||||
> EOF
|
||||
|
||||
$ cp ../bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
File "dune", lines 4-6, characters 2-84:
|
||||
4 | (progn
|
||||
5 | (dynamic-run ./foo.exe some_arg)
|
||||
6 | (dynamic-run ./foo.exe another_arg))))
|
||||
Error: Multiple 'dynamic-run' commands within single action are not
|
||||
supported.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune_action_plugin))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let () = run (return (print_endline "Hello from foo!"))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
This test checks that executable that uses 'dynamic-run'
|
||||
|
||||
but requires no dependencies can be successfully run.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
Hello from foo!
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let+ data = read_file ~path:(Path.of_string "some_absent_dependency") in
|
||||
print_endline data
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
This test checks that executable that uses 'dynamic-run'
|
||||
and requires dependency that can not be build fails.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest 2>&1 | awk '/Internal error/,/unable to serialize/'
|
||||
Internal error, please report upstream including the contents of _build/log.
|
||||
Description:
|
||||
("unable to serialize exception",
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let+ data = read_file ~path:(Path.of_string "some_dependency") in
|
||||
print_endline data
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
This test checks that 'dynamic-run' can work
|
||||
when we 'chdir' into different directory.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action
|
||||
> (chdir some_dir
|
||||
> (dynamic-run ./foo.exe))))
|
||||
> EOF
|
||||
|
||||
$ mkdir some_dir
|
||||
|
||||
$ cat > some_dir/dune << EOF
|
||||
> (rule
|
||||
> (target some_dependency)
|
||||
> (action
|
||||
> (with-stdout-to %{target} (echo "Hello from some_dependency!"))))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./some_dir
|
||||
$ dune runtest
|
||||
Hello from some_dependency!
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let+ data = read_file ~path:(Path.of_string "some_dependency") in
|
||||
print_endline data
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
This test checks that executable that uses 'dynamic-run'
|
||||
and requires one dependency can be successfully run.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (target some_dependency)
|
||||
> (action (with-stdout-to %{target} (echo "Hello from some_dependency!"))))
|
||||
> \
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
Hello from some_dependency!
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin dune-glob))
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
open Dune_action_plugin.V1
|
||||
module Glob = Dune_glob.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let+ listing =
|
||||
read_directory_with_glob ~glob:Glob.universal ~path:(Path.of_string "some_dir")
|
||||
in
|
||||
String.concat "\n" listing |> print_endline
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
This test checks that executable that uses 'dynamic-run'
|
||||
and depends on directory listing forces all targets in that
|
||||
directory to be build.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ mkdir some_dir
|
||||
|
||||
$ cat > some_dir/dune << EOF
|
||||
> (rule
|
||||
> (target some_file1)
|
||||
> (action (with-stdout-to %{target} (echo ""))))
|
||||
> \
|
||||
> (rule
|
||||
> (target some_file2)
|
||||
> (action (with-stdout-to %{target} (echo ""))))
|
||||
> \
|
||||
> (rule
|
||||
> (target some_file3)
|
||||
> (action (with-stdout-to %{target} (echo ""))))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
dune
|
||||
some_file1
|
||||
some_file2
|
||||
some_file3
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action =
|
||||
write_file ~path:(Path.of_string "some_target") ~data:"Hello from some_target!"
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (target some_target)
|
||||
> (action
|
||||
> (dynamic-run ./foo.exe)))
|
||||
> \
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (cat some_target)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
Hello from some_target!
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action = write_file ~path:(Path.of_string "bar") ~data:"Hello from bar!"
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
File "dune", lines 1-3, characters 0-57:
|
||||
1 | (rule
|
||||
2 | (alias runtest)
|
||||
3 | (action (dynamic-run ./foo.exe)))
|
||||
bar is written despite not being declared as a target in dune file. To fix, add it to target list in dune file.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(executables
|
||||
(names foo))
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = print_endline "Hello from foo!"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
This test checks that dune can gracefully handle situation when user provides
|
||||
ordinary executable instead of one linked against dune-action-plugin.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./foo.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
Hello from foo!
|
||||
File "dune", lines 1-3, characters 0-57:
|
||||
1 | (rule
|
||||
2 | (alias runtest)
|
||||
3 | (action (dynamic-run ./foo.exe)))
|
||||
Error: Executable 'foo.exe' declared as using dune-action-plugin (declared
|
||||
with 'dynamic-run' tag) failed to respond to dune.
|
||||
|
||||
If you don't use dynamic dependency discovery in your executable you may
|
||||
consider changing 'dynamic-run' to 'run' in your rule definition.
|
||||
[1]
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action =
|
||||
read_file ~path:(Path.of_string "some_source")
|
||||
|> stage ~f:(fun data -> write_file ~path:(Path.of_string "some_copy") ~data)
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (target some_source)
|
||||
> (action (with-stdout-to %{target} (echo "Hello there!\n"))))
|
||||
> \
|
||||
> (rule
|
||||
> (target some_copy)
|
||||
> (action
|
||||
> (dynamic-run ./foo.exe)))
|
||||
> \
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action
|
||||
> (progn
|
||||
> (cat some_source)
|
||||
> (cat some_copy))))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/foo.exe ./
|
||||
|
||||
$ dune runtest
|
||||
Hello there!
|
||||
Hello there!
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names foo)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action =
|
||||
write_file ~path:(Path.of_string "../some_file") ~data:"Hello from some_file!"
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (target some_file)
|
||||
> (action
|
||||
> (chdir some_dir
|
||||
> (dynamic-run ./foo.exe))))
|
||||
> \
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (cat some_file)))
|
||||
> EOF
|
||||
|
||||
$ mkdir some_dir
|
||||
|
||||
$ cp ./bin/foo.exe ./some_dir/
|
||||
|
||||
$ dune runtest
|
||||
Hello from some_file!
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
open Dune_action_plugin.V1
|
||||
|
||||
let action =
|
||||
let open Dune_action_plugin.V1.O in
|
||||
let switch = read_file ~path:(Path.of_string "foo_or_bar") in
|
||||
stage switch ~f:(fun file ->
|
||||
let+ data = read_file ~path:(Path.of_string file) in
|
||||
print_endline data)
|
||||
;;
|
||||
|
||||
let () = run action
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executables
|
||||
(names client)
|
||||
(libraries dune-action-plugin))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(deps
|
||||
(glob_files bin/*.exe)))
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
In this test client choose what to depend
|
||||
on based on dependency from the previous stage.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 2.0)
|
||||
> (using action-plugin 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (target bar)
|
||||
> (action
|
||||
> (progn
|
||||
> (echo "Building bar!\n")
|
||||
> (with-stdout-to %{target} (echo "Hello from bar!")))))
|
||||
> \
|
||||
> (rule
|
||||
> (target foo)
|
||||
> (action
|
||||
> (progn
|
||||
> (echo "SHOULD NOT BE PRINTED!\n")
|
||||
> (with-stdout-to %{target} (echo "Hello from foo!")))))
|
||||
> \
|
||||
> (rule
|
||||
> (target foo_or_bar)
|
||||
> (action (with-stdout-to %{target} (echo "bar"))))
|
||||
> \
|
||||
> (rule
|
||||
> (alias runtest)
|
||||
> (action (dynamic-run ./client.exe)))
|
||||
> EOF
|
||||
|
||||
$ cp ./bin/client.exe ./
|
||||
|
||||
$ dune runtest
|
||||
Building bar!
|
||||
Hello from bar!
|
||||
Loading…
Add table
Add a link
Reference in a new issue