fix(runtest): don't run in all contexts#13930
Conversation
rgrinberg
left a comment
There was a problem hiding this comment.
A couple of things:
-
If we're going to pick a context in a semi random way, we should document the rules for doing so. I.e. something like the "first context that occurs" in the workspace file.
-
Did we consider just improving the error message? I don't understand why we should making a decision for the user at all here and tests can certainly be defined in a context dependant way.
a49b4c3 to
7f7743f
Compare
I've reverted my changes picking a context since I was also not happy with it. I've now gone with finding tests per-(super)context.
This is technically a regression, since something that worked before is no longer working. See #13904. Therefore introducing an error message, especially since in the oxcaml case there is an obvious context to pick, seems like a bad user experience. For context, oxcaml have been running At the time of implementing |
Just so we are on the same page, could you elaborate on what you have in mind here? |
7f7743f to
8df5696
Compare
What was it doing before? I am worried that the behavior before was not reasonable, thus it could make more sense to error out now with a sensible error message instead of silently doing the wrong thing. |
|
@Leonidas-from-XIV Before we started running ml tests, we did not need to know anything about contexts. They were threaded throughout and used by the existing context handling mechanisms. Since #13064 we now have to classify ml tests, this requires a super context to do so since we use In 3.22.0 we are picking an arbitrary context in order to carry this out, this fix we will do the classification for each separate context, avoiding the need for a choice. |
8df5696 to
4d80b08
Compare
|
I don't think we should fixate on this being a regression. If the previous behavior was intentional, I was certainly unaware of it. We haven't offered backwards compatibility for any commands apart from those used for release builds. I don't think we should start now, especially over something so simple. We can fix their CI script. Instead, let's focus on providing good semantics for this command. If choosing the main context is so obvious, could you spell out the criteria? The previous implementation in this PR was hardly obvious to me. The new implementation is to run the tests in every context, which I suppose is more sensible, but is still incomplete. What happens when a test is defined in one context but not another? This can happen when a test has enabled_if on it. I guess that in your implementation, that contexts where the test is undefined should be skipped? I don't think it's working this way at the moment. I argue that running the tests in every context is also bad user experience. The automatic building of everything in every context is a reason why contexts are mostly avoided in the first place. I would instead go for something like this:
|
Right, this is the part that is missing here actually. The My previous idea of picking the first in the list would work in this case too, but would break down when using two non-default contexts. My thinking there was that "at this point, this is on the user", but that's exactly the kind of thinking that caused the issue in the first place. I think outside of an obvious choice, we should just error. Will this fix their CI? No. But at least they can rework it to be |
|
@rgrinberg The fix is to now choose This changes the tested behaviour of |
f41c1ec to
6678029
Compare
|
From the release perspective, if the decision is that the previous behavior was undefined and that this is not therefor a regression, then I don't think it belongs in the patch release. In particular, if this will not actually fix the build failures reported in #13904, then I don't think it needs to be in 3.22.1. The less that is added there the less risk, and the quicker we can actually fix the genuine regressions. With the understanding that a software regression is "a type of software bug where a feature that has worked before stops working correctly" and that a fix for such a bug would be restoring the correct behavior of the feature, is this a fix for a regression? |
|
Is there an adequate workaround for this issue? If not, I think applying this fix in the patch release makes sense as well.
…On Sat, Mar 28, 2026, at 2:49 AM, Shon Feder wrote:
*shonfeder* left a comment (ocaml/dune#13930) <#13930?email_source=notifications&email_token=AABB563BIIPVEJMLSBHEV434S44UBA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJUGY2DKMBZGAY2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4146450901>
From the release perspective, if the decision is that the previous behavior was undefined and that this is not therefor a regression, then I don't think it belongs in the patch release. In particular, if this will not actually fix the build failures reported in #13904 <#13904>, then I don't think it needs to be in 3.22.1. The less that is added there the less risk, and the quicker we can actually fix the genuine regressions.
With the understanding that a software regression <https://en.wikipedia.org/wiki/Software_regression> is "a type of software bug where a feature that has worked before stops working correctly" and that a fix for such a bug would be restoring the correct behavior of the feature, is this a fix for a regression?
—
Reply to this email directly, view it on GitHub <#13930?email_source=notifications&email_token=AABB563BIIPVEJMLSBHEV434S44UBA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJUGY2DKMBZGAY2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4146450901>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABB56Z6U267JZOSX6B5NYT4S44UBAVCNFSM6AAAAACXA35PWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCNBWGQ2TAOJQGE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
There was a problem hiding this comment.
Pull request overview
This PR fixes dune test/dune runtest context selection so that, for source-path test requests, Dune uses the default context when available, falls back to the single available context when there is exactly one, and errors out when multiple contexts exist without a default—avoiding the crash reported in #13904.
Changes:
- Update runtest request construction to avoid assuming a
"default"context exists, and to avoid running tests across all contexts for source paths. - Adjust blackbox tests to reflect the new “default-context-only” behavior for source-path invocations.
- Add a changelog entry describing the behavior change and the crash fix.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bin/runtest_common.ml |
Selects an appropriate context for source-path test requests (default → sole context → error). |
test/blackbox-tests/test-cases/runtest/runtest-cmd.t |
Updates expected output for context selection and no-default-context workspace behavior. |
test/blackbox-tests/test-cases/runtest/runtest-cmd-inline-tests.t |
Updates inline-test expectations so tests don’t run in multiple contexts by default. |
doc/changes/fixed/13930.md |
Documents the behavior change and the crash fix in the changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…wise Signed-off-by: Ali Caglayan <alizter@gmail.com>
6678029 to
17ae16a
Compare
Please include this in 3.22.1. It's easier for us to fix dune than it is to communicate workarounds to users. I don't see the risk in including this. |
|
Since it in fact fixes the behavior and doesn't still require a workaround, I think it should indeed be included! My question was at a point in the discussion where that wasn't decided, IIUC. Thanks! |
When choosing which context to find and run our tests, we always choose the default context and if that is not available a unique context. When there is no good choice we error. - Fixes ocaml#13904 - [x] Changelog
When choosing which context to find and run our tests, we always choose the default context and if that is not available a unique context. When there is no good choice we error. - Fixes ocaml#13904 - [x] Changelog Signed-off-by: Marek Kubica <marek@tarides.com>
CHANGES: ### Fixed - Restore compatibility with Windows 7 (ocaml/dune#13905, @nojb) - `dune test` now runs tests in the default context only. When there is a single context, it is treated as the default. This fixes a crash when the workspace has no context named "default". (ocaml/dune#13930, fixes ocaml/dune#13904, @Alizter) - Fix `dune trace cat --chrome-trace` to adhere to the Chrome Trace Event Format by providing timestamps and durations at microsecond granularity (ocaml/dune#13911, fixes ocaml/dune#13906, @Alizter)
When choosing which context to find and run our tests, we always choose the default context and if that is not available a unique context. When there is no good choice we error.