Fail to promote over a non-existing file
Expected Behavior
The testsuite demonstrate that this is possible in test/blackbox-tests/test-cases/promote/non-existent.t/run.t
My reproduction looks very similar to this test but fail with an error.
Actual Behavior
dune build @bench:
File "dune", line 3, characters 0-55:
3 | (rule
4 | (alias bench)
5 | (action
6 | (diff promoted x.gen)))
Error: Unable to resolve symlink _build/default/promoted
Reproduction
The reproduction is at https://gist.github.com/Julow/961080a45a58b964fd1bca7892445034
Specifications
- Dune 3.8.2
If I replace the dune files at test/blackbox-tests/test-cases/promote/non-existent.t/ with mines, it's able to promote.
The problem persists with --sandbox none.
Also running into this. It would be very convenient for dune to be able to promote over nonexistent files.
The test uses (lang dune 2.8) which might be why it works there, but some newer dune lang might change the behavior.
I just checked that the test passes with both lang versions 3.7 (the version used in the repro) and 3.15.
Hi,
I encounter the same problem with the last version of dune (3.20.2). Trying to use diff against a non existing file leads to the error Error: Unable to resolve symlink _build/default/XXX. Is there a workaround?
Thanks in advance,
Christophe
I just create an empty file in the expected location eg touch XXX. Arguably, dune should just do this if it can't find the file.
I've managed to reproduce this issue. The main reason we hadn't done this sooner is because INSIDE_DUNE, an internal env variable we set when testing dune needs to be unset for the behaviour to become apparent. In that case we default to git diff which most users see, however git diff does not like symbolic links so there is some work on resolving these in the code. This however doesn't make any sense when the file (target of the symlink) simply doesn't exist.
In my test however, it appears the promotion was still being registered even though dune was complaining about the symlink not being resolvable.
A fix can be found in #12615.
Hi @Alizter and @yawaramin ,
Thanks for your answers. I am currently using dune and diff to check a tool output for thousands of test cases representing regression tests, and in the vast majority of the test cases the output should be empty, hence the use of a "non existing result file". I could of course create an empty file for each test case.
@tofgarion are you able to check if my fix in #12615 fixes your issue?
The current behavior is also in conflict with explicitly documented behavior in https://dune.readthedocs.io/en/stable/concepts/promotion.html#diffing, it seems:
If
<file1>doesn’t exist, it will compare with the empty file.
@nomeata Its partially correct since if you use a different --diff= program it will work. I will update the docs in the fix too #12615.
Indeed! With
dune runtest --diff-command "diff -Nur"
it seems to work. Thanks!
Actually after reviewing the doc, it doesn't need updating. But I am pushing the fix forward so that dune's behaviour actually matches the doc in all cases.