-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cargo semver-checks
testsuite to rustdoc JSON output
#110815
Comments
Big +1 |
We could, though semver-checks isn't an official tool. I'm also fine with having an internal toggle that we can use, and we try and coordinate with semver-checks as much as possible. |
I think if we're going to have some "it's ok to break this testsuite" state we should reuse the toolstate mechanisms. We don't need to rewrite our own |
Adding support for new format versions is generally extremely straightforward. I'd be happy to give folks involved with this effort push privs on |
Yeah the mechanism seems fine, my worry is more about what we show publicly on toolstate. |
ah, gotcha - I think it should be possible to add some toggle to the toolstate website that hides semver-checks from the public site. |
Talked about this on zulip, but TLDR:
|
Actually this is a reason why I'm even more skeptical toolstate is the right tool for the job here: having I feel like "enforced by CI by easily disabled" is the best option. Toolstate is very much for cases where you expect breakage and want a dashboard of breakage, here we also want to catch unintentional breakage. For that we need CI, and the CI needs to be something you can disable when you do intend to break things. |
From a purely technical perspective, I think "enforced by CI so long as the rustdoc format version number is still X" where X is a hardcoded constant representing the largest version supported by trustfall-rustdoc-adapter / cargo-semver-checks could be done. When the version number changes, this would auto-disable that CI, and it would need to be manually re-enabled after new format versions are released. I'd be happy to open PRs for that re-enabling, and it should also be quite easy to write a bot to do it automatically as well. |
When you say rustdoc version do you mean rustdoc-json format version? But yes that would work. |
Yes, format version — edited above to add that. |
If anyone is curious about the kinds of test cases that are part of The bug in this case was in my code, not in For an example of a Rust (maybe-)bug found as a result of the same run, see #110831. It seems that "run lots of rustdoc-based queries on lots of crates then look for weird outcomes" is a viable strategy for proactive bug-finding in Rust. |
Relevant to if we ever do this: rust-lang/compiler-team#845. But I don't think this is particularly urgent. To my knowledge there's never been a regression that csc's test-suite would have caught. That said, I'd still love to have a way written down to run the csc tests against in-tree rustdoc. |
Over the last few days I've been boosting our test coverage around attributes, so that the list of attributes For both
Running with in-tree rustdoc would just require figuring out how to amend the script to invoke the in-tree rustdoc instead of the installed one. I imagine that shouldn't be difficult? |
❤ yeah, this would be.
Ah, that should make it easy.
Yeah, you create a rustup toolchain that points to your in-tree, either with https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#creating-a-rustup-toolchain or |
Nice! The script already supports calling with a custom toolchain (like |
While opening PRs to test item attribute representation in rustdoc JSON, I seem to have stumbled upon an example of something rustdoc JSON tests cannot seem to test today, but Consider the following code: /// The generated `impl Clone` has `#[automatically_derived]` applied on it.
#[derive(Clone)]
pub struct Example(i64); Ideally, we'd use a statement like the following to create a rustdoc JSON test that ensures the attribute is indeed present on the generated //@ is "$.index[*][?(@.inner.impl.trait.path=='Clone')].attrs" '["#[automatically_derived]"]'
// possibly also with an additional clause near ^ here, to make sure it's `Example`'s `impl Clone` Unfortunately, this doesn't work because of bug freestrings/jsonpath#91 — AFAICT any predicate with more than two dot operators just silently doesn't match anything. Undeterred, we might try the opposite approach: "find the item with //@ is "$.index[*][?(@.attrs[0]=='#[automatically_derived]')].inner.impl.trait.path" '"Clone"'
//@ is "$.index[*][?(@.attrs[0]=='#[automatically_derived]')].inner.impl.for.resolved_path.id" $Example This doesn't work either. I triple-checked that At this point, I got frustrated by the 3h of getting absolutely nowhere with this and gave up on writing this test in rustdoc JSON.
|
Rustdoc has a ... not-very-comprensive test suite. cargo-semver-checks has much more extensive tests. It would be really nice if we could test that we don't accidentally regress the JSON output (or the other output for that matter; I suspect most breakage affects both backends).
I think the easiest way to do this is to add a new
tests/rustdoc-semver-checks
submodule with a dependency on https://github.com/obi1kenobi/cargo-semver-checks. Then insrc/bootstrap/test.rs
, we'll add a new test suite that runscargo test
on cargo-semver-checks using the in-tree version of rustdoc to make sure there's no incompatibilities.I am not sure how this should deal with breaking changes to the JSON format - maybe we can use toolstate which allows the tests to be broken until semver-checks supports the new version?
cc @obi1kenobi @rust-lang/rustdoc
The text was updated successfully, but these errors were encountered: