Skip to content

diff? error: Rule failed to generate the following targets #2990

@anton-trunov

Description

@anton-trunov

Please consider the following self-contained example in the form of a dune file:

(executable
 (name print)
 (modules print))

(rule
 (with-stdout-to print.ml
  (echo "let () = print_endline \"MESSAGE\"")))

(rule
 (alias runtest)
 (action
  (progn
   (with-stdout-to output.expected (echo "MESSAGE\n"))
   (with-stdout-to output.actual (run ./print.exe))
   (diff? output.expected output.actual))))

When I run dune runtest it generates the following error message which I find confusing:

$ dune runtest
File "dune", line 9, characters 0-195:
 9 | (rule
10 |  (alias runtest)
11 |  (action
12 |    (progn
13 |     (with-stdout-to output.expected (echo "MESSAGE\n"))
14 |     (with-stdout-to output.actual (run ./print.exe))
15 |     (diff? output.expected output.actual))))
Error: Rule failed to generate the following targets:
- output.actual

According to the manual,

(diff? ) is similar to (diff ) except that should be produced by a part of the same action rather than be a dependency, is optional and will be consumed by diff?.

In this case (please correct me if I'm wrong) is produced as a part of the same action, so I would expect no error. Changing (diff? ... to (diff ... works as expected. Perhaps it's a documentation issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions