Skip to content

test(clean): demonstrate that clean rejects source directories (#2288) - #15300

Merged
rgrinberg merged 1 commit into
mainfrom
test-2288-clean-rejects-source-dirs
Jun 24, 2026
Merged

rgrinberg merged 1 commit into
mainfrom
test-2288-clean-rejects-source-dirs

Conversation

@rgrinberg

Copy link
Copy Markdown
Member

Reproduces #2288: dune clean does not accept source directories (or package
names) the way dune build/dune runtest do — it only accepts paths inside
the build directory (a capability added in #13875).

This adds a test to clean.t documenting the current behaviour:

  • dune build sub accepts the source directory
  • dune clean sub fails with Error: sub is not inside the build directory
  • dune clean . fails likewise

No behaviour change — the test pins the status quo so it will flip to the
desired output if/when dune clean learns to accept source directories.

🤖 Generated with Claude Code

Document the limitation from #2288: unlike `dune build`, `dune clean` does
not accept a source directory (or package name) — it only accepts paths
inside the build directory. `dune build sub` works, but `dune clean sub` and
`dune clean .` fail with "<path> is not inside the build directory".

This pins the current behaviour; the expected output will flip once `dune
clean` learns to accept source directories.

Signed-off-by: Rudi Grinberg <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@rgrinberg
rgrinberg merged commit 56b3225 into main Jun 24, 2026
27 of 29 checks passed
@rgrinberg
rgrinberg deleted the test-2288-clean-rejects-source-dirs branch June 24, 2026 12:00
@Alizter Alizter added this to the 3.25.0 milestone Jul 8, 2026
rgrinberg added a commit that referenced this pull request Nov 8, 2026
Fixes #2288.

`dune clean PATH` previously only accepted paths inside the build
directory
(e.g. `_build/default/foo`); passing a source directory failed with
`<path> is
not inside the build directory`. This makes `dune clean` accept source
directories (and the project root) too, mirroring how `dune build PATH`
accepts
a source directory.

A source path is resolved against every build context and the
corresponding
artifacts are removed (`_build/<context>/<path>`). For example:

```
$ dune clean foo   # removes _build/<context>/foo for every context
$ dune clean .     # cleans each build context
```

Paths already inside `_build` keep their previous behaviour, and `dune
clean`
with no arguments still removes the whole build directory.

Implementation notes:

- Arguments are partitioned: those already in `_build` are removed
directly (no
engine startup, as before); source paths are mapped across
`Context.DB.all`.
- Reading the contexts needs the engine, so when a source path is given
the
  command now starts a server-less scheduler (`go_without_rpc_server`).

The `clean.t` test added in #15300 (which demonstrated the rejection) is
updated to assert the new behaviour.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Rudi Grinberg <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants