diff --git a/src/dune/action_unexpanded.ml b/src/dune/action_unexpanded.ml index 4965508a23ec..8a53f0592593 100644 --- a/src/dune/action_unexpanded.ml +++ b/src/dune/action_unexpanded.ml @@ -380,6 +380,8 @@ end = struct val ( +<+ ) : outcome -> target -> outcome val ( + program -> outcome + + val ( +<- ) : outcome -> path -> outcome end module Make @@ -420,7 +422,7 @@ end = struct | Digest_files l -> List.fold_left l ~init:acc ~f:( +< ) | Diff { optional; file1; file2; mode = _ } -> if optional then - acc +< file1 + acc +< file1 +<- file2 else acc +< file1 +< file2 | Merge_files_into (sources, _extras, target) -> @@ -466,6 +468,14 @@ end = struct let ( +<+ ) acc fn = { acc with deps = Path.Set.add acc.deps (Path.build fn) } + let ( +<- ) acc fn = + match Path.as_in_build_dir fn with + | Some target -> + { acc with + targets = Path.Build.Set.remove acc.targets target + } + | None -> acc + let ( + acc +< p @@ -494,6 +504,15 @@ end = struct { acc with deps = Path.Set.add acc.deps (Path.build fn) } | Unexpanded _ -> acc + let ( +<- ) acc (fn : _ String_with_vars.Partial.t) = + match fn with + | Expanded fn -> ( + match Path.as_in_build_dir fn with + | Some target -> + { acc with targets = Path.Build.Set.remove acc.targets target } + | None -> acc ) + | Unexpanded _ -> acc + let ( + { acc with deps = Path.Set.add acc.deps fn } @@ -522,6 +541,15 @@ end = struct { acc with deps = Path.Set.add acc.deps (Path.build fn) } | Unexpanded _ -> acc + let ( +<- ) acc (fn : _ String_with_vars.Partial.t) = + match fn with + | Expanded fn -> ( + match Path.as_in_build_dir fn with + | Some target -> + { acc with targets = Path.Build.Set.remove acc.targets target } + | None -> acc ) + | Unexpanded _ -> acc + let ( + { acc with deps = Path.Set.add acc.deps fn } @@ -584,6 +612,12 @@ end = struct let ( +<+ ) acc _ = acc let ( + t <> fn) } end) let unexpanded_targets t = (Unexp.infer t).targets diff --git a/test/blackbox-tests/dune.inc b/test/blackbox-tests/dune.inc index 42a1fef864f2..2e367fcc3629 100644 --- a/test/blackbox-tests/dune.inc +++ b/test/blackbox-tests/dune.inc @@ -1034,6 +1034,14 @@ test-cases/github2848 (progn (run dune-cram run run.t) (diff? run.t run.t.corrected))))) +(rule + (alias github2990) + (deps (package dune) (source_tree test-cases/github2990)) + (action + (chdir + test-cases/github2990 + (progn (run dune-cram run run.t) (diff? run.t run.t.corrected))))) + (rule (alias github3046) (deps (package dune) (source_tree test-cases/github3046)) @@ -2584,6 +2592,7 @@ (alias github2629) (alias github2681) (alias github2848) + (alias github2990) (alias github3046) (alias github3180) (alias github3412) @@ -2871,6 +2880,7 @@ (alias github2629) (alias github2681) (alias github2848) + (alias github2990) (alias github3046) (alias github3180) (alias github3412) diff --git a/test/blackbox-tests/test-cases/github2990/dune b/test/blackbox-tests/test-cases/github2990/dune new file mode 100644 index 000000000000..350ebef29b9f --- /dev/null +++ b/test/blackbox-tests/test-cases/github2990/dune @@ -0,0 +1,15 @@ +(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)))) diff --git a/test/blackbox-tests/test-cases/github2990/dune-project b/test/blackbox-tests/test-cases/github2990/dune-project new file mode 100644 index 000000000000..5bbef0b4909b --- /dev/null +++ b/test/blackbox-tests/test-cases/github2990/dune-project @@ -0,0 +1 @@ +(lang dune 2.5) diff --git a/test/blackbox-tests/test-cases/github2990/run.t b/test/blackbox-tests/test-cases/github2990/run.t new file mode 100644 index 000000000000..63e4ebbb0bf6 --- /dev/null +++ b/test/blackbox-tests/test-cases/github2990/run.t @@ -0,0 +1,3 @@ +Test for problem in #2990 + + $ dune runtest