Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
  • Loading branch information
aalekseyev committed Aug 2, 2019
1 parent efa9868 commit e26d134
Showing 1 changed file with 59 additions and 4 deletions.
63 changes: 59 additions & 4 deletions test/blackbox-tests/test-cases/corrections/run.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
$ echo '(lang dune 2.0)' > dune-project
$ echo file-contents > text-file


It's OK if there's no correction:

$ cat > dune <<EOF
Expand Down Expand Up @@ -30,6 +29,14 @@ and dune correctly complains
differ.
[1]

Promotion works fine:

$ dune promote
Promoting _build/default/text-file-corrected to text-file.
$ cat text-file
corrected-contents-1
$ echo file-contents > text-file

When correction is no longer produced, dune no longer complains.
(relies on stale artifact deletion, it seems)

Expand All @@ -42,11 +49,33 @@ When correction is no longer produced, dune no longer complains.
> )
> EOF
$ echo new-contents > text-file

$ dune build @correction1

Promotion should work when sandboxing is used:

$ cat > dune <<EOF
> (alias (name correction1)
> (deps)
> (action
> (progn
> (bash "echo another-correction > text-file-corrected")
> (diff? text-file text-file-corrected)))
> )
> EOF

$ dune build @correction1 --sandbox copy
File "text-file", line 1, characters 0-0:
Error: Files
_build/.sandbox/150b972ad59fdd3e13294c94880afcfd/default/text-file and
_build/.sandbox/150b972ad59fdd3e13294c94880afcfd/default/text-file-corrected
differ.
[1]

$ dune promote
Skipping promotion of _build/default/text-file-corrected to text-file as the file is missing.

Dependency on the second argument of diff? is *not* automatically added.
This is fine if we think of it as an intermediate file rather than dep.
This is fine because we think of it as an intermediate file rather than dep.

$ cat > dune <<EOF
> (alias (name correction1)
Expand All @@ -61,7 +90,7 @@ This is fine if we think of it as an intermediate file rather than dep.

$ dune build @correction1

But dune looks at this file if it exists. This is clearly a bug.
But dune looks at this file if it exists. This is a bit of a bug.
One fix is to not look at it, and flag its existence as an error.

$ dune build text-file-corrected
Expand All @@ -75,3 +104,29 @@ One fix is to not look at it, and flag its existence as an error.
Error: Files _build/default/text-file and _build/default/text-file-corrected
differ.
[1]

Sandboxing doesn't necessarily help either because dune thinks
[diff?] is not worth sandboxing.

$ dune build text-file-corrected
$ dune build @correction1 --sandbox copy
File "text-file", line 1, characters 0-0:
Error: Files _build/default/text-file and _build/default/text-file-corrected
differ.
[1]

Sandboxing does help if the command producing the
correction is non-trivial.

$ cat > dune <<EOF
> (alias (name correction1)
> (deps)
> (action
> (progn
> (bash "true")
> (diff? text-file text-file-corrected)))
> )
> EOF

$ dune build @correction1 --sandbox copy

0 comments on commit e26d134

Please sign in to comment.