This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,231 @@
|
|||
rules with dependencies outside the build dir are allowed
|
||||
|
||||
$ mkdir -p a/b
|
||||
|
||||
$ cat >a/b/dune-project <<EOF
|
||||
> (lang dune 2.8)
|
||||
> EOF
|
||||
|
||||
### absolute path
|
||||
|
||||
## Test absolute
|
||||
$ cat >a/b/dune <<EOF
|
||||
> (rule
|
||||
> (alias test)
|
||||
> (action (with-stdin-from "$PWD/external.txt" (run cat -))))
|
||||
> EOF
|
||||
|
||||
$ cat >external.txt <<EOF
|
||||
> txt1
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt1
|
||||
Leaving directory 'a/b'
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
Leaving directory 'a/b'
|
||||
|
||||
$ cat >external.txt <<EOF
|
||||
> txt2
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt2
|
||||
Leaving directory 'a/b'
|
||||
|
||||
## Test copy files absolute
|
||||
$ cat >a/b/dune <<EOF
|
||||
> (rule
|
||||
> (alias test)
|
||||
> (action (with-stdin-from "external.txt" (run cat -))))
|
||||
> (copy_files "$PWD/external.txt")
|
||||
> EOF
|
||||
|
||||
$ cat >external.txt <<EOF
|
||||
> txt1
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt1
|
||||
Leaving directory 'a/b'
|
||||
|
||||
# Check that nothing is done when nothing change
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
Leaving directory 'a/b'
|
||||
|
||||
$ cat >external.txt <<EOF
|
||||
> txt2
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt2
|
||||
Leaving directory 'a/b'
|
||||
|
||||
### 1 level below
|
||||
|
||||
## Test relative 1 level below
|
||||
$ cat >a/b/dune <<EOF
|
||||
> (rule
|
||||
> (alias test)
|
||||
> (action (with-stdin-from "../external.txt" (run cat -))))
|
||||
> EOF
|
||||
|
||||
$ cat >a/external.txt <<EOF
|
||||
> txt1
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt1
|
||||
Leaving directory 'a/b'
|
||||
|
||||
# Check that nothing is done when nothing change
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
Leaving directory 'a/b'
|
||||
|
||||
$ cat >a/external.txt <<EOF
|
||||
> txt2
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt2
|
||||
Leaving directory 'a/b'
|
||||
|
||||
## Test copy files 1 level below
|
||||
$ cat >a/b/dune <<EOF
|
||||
> (rule
|
||||
> (alias test)
|
||||
> (action (with-stdin-from "external.txt" (run cat -))))
|
||||
> (copy_files ../external.txt)
|
||||
> EOF
|
||||
|
||||
$ cat >a/external.txt <<EOF
|
||||
> txt1
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt1
|
||||
Leaving directory 'a/b'
|
||||
|
||||
# Check that nothing is done when nothing change
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
Leaving directory 'a/b'
|
||||
|
||||
$ cat >a/external.txt <<EOF
|
||||
> txt2
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt2
|
||||
Leaving directory 'a/b'
|
||||
|
||||
### 2 level below
|
||||
|
||||
## Test relative 2 level below
|
||||
$ cat >a/b/dune <<EOF
|
||||
> (rule
|
||||
> (alias test)
|
||||
> (action (with-stdin-from "../../external.txt" (run cat -))))
|
||||
> EOF
|
||||
|
||||
$ rm -f a/external.txt
|
||||
|
||||
$ cat >external.txt <<EOF
|
||||
> txt1
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt1
|
||||
Leaving directory 'a/b'
|
||||
|
||||
# Check that nothing is done when nothing change
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
Leaving directory 'a/b'
|
||||
|
||||
$ cat >external.txt <<EOF
|
||||
> txt2
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt2
|
||||
Leaving directory 'a/b'
|
||||
|
||||
## Test copy files 2 level below
|
||||
$ cat >a/b/dune <<EOF
|
||||
> (rule
|
||||
> (alias test)
|
||||
> (action (with-stdin-from "external.txt" (run cat -))))
|
||||
> (copy_files ../../external.txt)
|
||||
> EOF
|
||||
|
||||
$ cat >external.txt <<EOF
|
||||
> txt1
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt1
|
||||
Leaving directory 'a/b'
|
||||
|
||||
# Check that nothing is done when nothing change
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
Leaving directory 'a/b'
|
||||
|
||||
$ cat >external.txt <<EOF
|
||||
> txt2
|
||||
> EOF
|
||||
|
||||
$ dune build --root=a/b @test
|
||||
Entering directory 'a/b'
|
||||
txt2
|
||||
Leaving directory 'a/b'
|
||||
|
||||
## Test dune exec absolute
|
||||
$ cat >a/script.sh <<EOF
|
||||
> #!/bin/sh
|
||||
> echo "txt1"
|
||||
> EOF
|
||||
|
||||
$ chmod u+x a/script.sh
|
||||
|
||||
$ dune exec --root=a/b -- $PWD/a/script.sh
|
||||
Entering directory 'a/b'
|
||||
Leaving directory 'a/b'
|
||||
txt1
|
||||
|
||||
## Test dune exec 1 level below
|
||||
$ dune exec --root=a/b -- ../script.sh
|
||||
Entering directory 'a/b'
|
||||
Leaving directory 'a/b'
|
||||
txt1
|
||||
|
||||
## Test dune exec 2 level below
|
||||
$ mv a/script.sh .
|
||||
|
||||
$ dune exec --root=a/b -- ../../script.sh
|
||||
Entering directory 'a/b'
|
||||
Leaving directory 'a/b'
|
||||
txt1
|
||||
|
||||
# Regression test for #5572
|
||||
$ dune exec --root=a/b -- ../
|
||||
Entering directory 'a/b'
|
||||
Error: Program '../' not found!
|
||||
Leaving directory 'a/b'
|
||||
[1]
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
let () = Printexc.record_backtrace true
|
||||
|
||||
let digest =
|
||||
let raw = Sys.getcwd () |> Filename.dirname |> Filename.basename in
|
||||
let idx =
|
||||
let store_path = Sys.getenv "DUNE_PWD_STORE" in
|
||||
match open_in store_path with
|
||||
| exception Sys_error _ ->
|
||||
let out = open_out_gen [ Open_append; Open_creat ] 0 store_path in
|
||||
Printf.fprintf out "%s\n" raw;
|
||||
close_out out;
|
||||
1
|
||||
| store ->
|
||||
let rec loop i =
|
||||
match input_line store with
|
||||
| line -> if line = raw then i else loop (i + 1)
|
||||
| exception End_of_file ->
|
||||
close_in store;
|
||||
let out = open_out_gen [ Open_append; Open_creat ] 0 store_path in
|
||||
Printf.fprintf out "%s\n" raw;
|
||||
close_out out;
|
||||
i
|
||||
in
|
||||
let index = loop 1 in
|
||||
close_in store;
|
||||
index
|
||||
in
|
||||
Printf.sprintf "$%d" idx
|
||||
|
||||
let () =
|
||||
print_endline "running...";
|
||||
let out = open_out "target" in
|
||||
output_string out "target";
|
||||
close_out out;
|
||||
Printf.printf "digest: %s\n" digest
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
----------------------------------------------------------------------------------
|
||||
Test that rule digest doesn't depend on irrelevant details of the dune file
|
||||
|
||||
$ export DUNE_PWD_STORE="$(mktemp)"
|
||||
|
||||
$ echo "(lang dune 3.0)" > dune-project
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (rule
|
||||
> (target target)
|
||||
> (mode promote)
|
||||
> (deps (sandbox always) pwd.ml)
|
||||
> (action (run ocaml pwd.ml)))
|
||||
> EOF
|
||||
|
||||
$ dune build target
|
||||
running...
|
||||
digest: $1
|
||||
|
||||
Let's add a comment to the dune file. It shouldn't affect the rule digest.
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> ; hello
|
||||
> (rule
|
||||
> (target target)
|
||||
> (mode promote)
|
||||
> (deps (sandbox always) pwd.ml)
|
||||
> (action (run ocaml pwd.ml)))
|
||||
> EOF
|
||||
|
||||
... and it doesn't.
|
||||
|
||||
$ rm _build/default/target target
|
||||
$ dune build @default
|
||||
running...
|
||||
digest: $1
|
||||
|
||||
Now the same but with an alias.
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (rule
|
||||
> (alias default)
|
||||
> (deps (sandbox always) pwd.ml)
|
||||
> (action (run ocaml pwd.ml)))
|
||||
> EOF
|
||||
|
||||
$ dune build @default
|
||||
running...
|
||||
digest: $2
|
||||
|
||||
Let's add a comment to the dune file. Dune does not re-run the rule because it
|
||||
has the same digest:
|
||||
|
||||
$ changelocation() {
|
||||
> sed -i.bak '1s/^/;; spurious location change\n/' dune
|
||||
> }
|
||||
|
||||
$ changelocation
|
||||
|
||||
Now we make sure that failed rules re-run when the location changes:
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (rule
|
||||
> (alias foo)
|
||||
> (action (system "echo failing; exit 1")))
|
||||
> EOF
|
||||
|
||||
$ dune build @foo
|
||||
File "dune", lines 1-3, characters 0-61:
|
||||
1 | (rule
|
||||
2 | (alias foo)
|
||||
3 | (action (system "echo failing; exit 1")))
|
||||
failing
|
||||
[1]
|
||||
|
||||
$ changelocation
|
||||
|
||||
This should re-run the action
|
||||
|
||||
$ dune build @foo
|
||||
File "dune", lines 2-4, characters 0-61:
|
||||
2 | (rule
|
||||
3 | (alias foo)
|
||||
4 | (action (system "echo failing; exit 1")))
|
||||
failing
|
||||
[1]
|
||||
|
||||
$ dune build @default
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(cram
|
||||
(applies_to digest)
|
||||
(deps %{bin:sed} %{bin:mktemp}))
|
||||
Loading…
Add table
Add a link
Reference in a new issue