Skip to content

test: make censor disambiguate digests - #14430

Merged
Alizter merged 1 commit into
ocaml:mainfrom
Alizter:push-nwnkytqqvovv
May 5, 2026
Merged

Alizter merged 1 commit into
ocaml:mainfrom
Alizter:push-nwnkytqqvovv

Conversation

@Alizter

@Alizter Alizter commented May 5, 2026 •

Copy link
Copy Markdown
Collaborator

We cleanup all our censor-style helpers into a single one that works for all cases and disambiguates between distinct matches.

This reveals some erroneous censorship that we have partaken in with various tests.

  • finish updating various tests
  • document in hacking.rst

@Alizter
Alizter requested review from Leonidas-from-XIV and rgrinberg and removed request for Leonidas-from-XIV May 5, 2026 14:52
@Alizter
Alizter force-pushed the push-nwnkytqqvovv branch 3 times, most recently from 2c01b6f to bbfa420 Compare May 5, 2026 18:31
@Alizter
Alizter marked this pull request as ready for review May 5, 2026 18:31
@Alizter
Alizter requested a review from Leonidas-from-XIV May 5, 2026 18:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates the blackbox test output “censoring” helpers into a single censor pipeline that can normalize paths/digests more robustly, including disambiguating multiple distinct digest occurrences, and updates affected cram expectations and documentation accordingly.

Changes:

  • Add a new dune_cmd sed action/subcommand (subst-unique) to replace each distinct match with a stable, uniquely numbered label when needed.
  • Replace specialized helpers (censor_ppx, censor_cinaps, strip_sandbox) with a single censor implementation in the blackbox test setup script.
  • Update many cram test expectations to reflect disambiguated $DIGEST1/$DIGEST2/... outputs and the new unified censoring behavior; document it in hacking.rst.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/blackbox-tests/utils/dune_cmd.ml Introduces Sed.Subst_unique + subst-unique subcommand for disambiguating multiple distinct substitutions.
test/blackbox-tests/setup-script.sh Reworks censor to normalize $PWD, digests, and cinaps paths; removes old helper functions.
doc/hacking.rst Documents the new censor behavior and the $DIGEST1/$DIGEST2/... convention.
test/blackbox-tests/test-cases/top-module/load-with-ppx.t Switches from censor_ppx to unified censor and updates expected paths.
test/blackbox-tests/test-cases/pkg/withenv-path.t Updates PATH expectations to reflect disambiguated digests and new censoring.
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-platform-dependant-dependencies.t Updates expected package directory names to use $DIGEST1/$DIGEST2.
test/blackbox-tests/test-cases/pkg/opam-var/opam-var-switch.t Updates sandbox/package path expectations to match new censor output.
test/blackbox-tests/test-cases/pkg/dep-section-variables.t Updates expected sandbox/package paths and removes strip_sandbox usage.
test/blackbox-tests/test-cases/pkg/default-exported-env.t Updates exported env var output expectations using unified censor.
test/blackbox-tests/test-cases/pkg/absolute-paths-in-sections.t Updates expected --prefix outputs to match new censor normalization.
test/blackbox-tests/test-cases/merlin/multiple-ppx-stanzas-github1946.t/run.t Switches to censor and updates expected .ppx/$DIGEST* paths.
test/blackbox-tests/test-cases/merlin/merlin-tests.t/run.t Switches to censor and updates expected absolute paths to $PWD/....
test/blackbox-tests/test-cases/melange/merlin.t Switches to censor and updates expected .ppx paths.
test/blackbox-tests/test-cases/melange/dune Adds an inline note in enabled_if stanza.
test/blackbox-tests/test-cases/dune-cache/trim.t Updates expected cache DB filenames to use $DIGEST1/$DIGEST2/....
test/blackbox-tests/test-cases/dune-build-info-in-ppx-github3336.t/run.t Switches to censor for .ppx executable listing.
test/blackbox-tests/test-cases/describe/describe.t Updates many digest placeholders to disambiguated $DIGEST* labels.
test/blackbox-tests/test-cases/describe/describe-workspace-pp.t Updates many digest placeholders to disambiguated $DIGEST* labels.
test/blackbox-tests/test-cases/cram/junction-cleanup.t Uses censor instead of strip_sandbox and updates expected sandbox path text.
test/blackbox-tests/test-cases/cinaps/multiple-cinaps.t Switches to censor and updates expected cinaps path normalization.
test/blackbox-tests/test-cases/cinaps/link-flags.t Switches to censor and updates expected cinaps path normalization.

Comment thread test/blackbox-tests/utils/dune_cmd.ml Resolved
Comment thread doc/hacking.rst Resolved
@Alizter
Alizter merged commit aee08b0 into ocaml:main May 5, 2026
33 checks passed
@Alizter
Alizter deleted the push-nwnkytqqvovv branch May 5, 2026 20:51
@Leonidas-from-XIV Leonidas-from-XIV changed the title test: make censor disambuate digests test: make censor disambiguate digests May 6, 2026
Alizter added a commit that referenced this pull request May 21, 2026
Resolve `%{bin:...}` to the build artifact path (`Original_path`)
instead of the install staging area. When `%{bin:...}` appears in `(deps
...)`, a bin-layout directory is created under
`_build/install/<context>/.binaries/<digest>/` with correctly-named
symlinks, and added to `PATH`.

The legacy staging paths (`_build/install/default/bin`, `lib`, etc.)
remain on the root env for now. They cannot be removed until `(deps
(package ...))` provides its own scoped layout (the install-layout PR
#14373), since actions using `(package ...)` deps still rely on the
staging area for `PATH` and `OCAMLPATH` visibility.

Env binaries (from `(env (binaries ...))`) are excluded from the
bin-layout since they already use `.bin/` on `PATH`.

`Dep_conf_eval.unnamed` and `Dep_conf_eval.named` now return a single
`Env.t Action_builder.t` whose evaluation both registers deps and
produces the env (previously a tuple with a separate `unit
Action_builder.t` for deps registration). Build-tracking-only callers
(`lib_flags`, `simple_rules`) discard the env via
`Action_builder.ignore`.

`(include FILE)` inside `(deps ...)` propagates the recursive call's
`bin_env` via a new `Include_result` variant on `dep_evaluation_result`;
`named_paths_builder` folds the include `bin_env`s into the final
`bin_env` via `Env_path.extend_env_concat_path`. Without this, the
action's `PATH` would not get a bin-layout dir for include-d bin pforms.

The change is not gated by lang version: #3324 affects every lang
version, so gating would leave the bug unfixed for pre-3.24 projects.
The user-visible realignments are confined to in-`_build` paths and the
migration cost is small enough to not warrant a per-project opt-in.

- Fixes #3324
- Depends on #14430 (merged)
- Depends on #14431 (merged)
- [x] changelog
- [x] documentation

## Known limitations (deferred to follow-up)

- dune's sandbox does not relocate the `PATH` environment variable. The
bin-layout dir on `PATH` points at the un-sandboxed `_build/`. This
works locally because absolute paths are still readable from inside the
sandbox, but would break under remote action execution. Tracked by
`test/blackbox-tests/test-cases/bin-pform/sandbox.t`.
- `Bin_layout.Key.reverse_table` grows unboundedly in long-running
`--watch` sessions (one entry per unique sorted bin set). Pattern
inherited from `Ppx_driver.Key`. Bounded by the number of distinct bin
sets the workspace evaluates; unlikely to be a real problem.
@Alizter Alizter added this to the 3.24.0 milestone Jul 8, 2026
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.

3 participants