-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Check the search-index generated by rustdoc tests #31483
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Wow. This looks like it's doing something really cool. Are the comments in the rustdoc tests the 'reference index' mentioned in the code and does the script update the tests directly to replace the reference index? Do any of the new tests capture the corner cases @lifthrasiir mentioned in the issue? Can you add some comments of search-index.py explaining what the script does, that it's run by compiletest on rustdoc tests, how to use it to update tests? |
Yes
Well yes, but only one at a time through
I'm not sure. I've found some obvious bugs but haven't looked too closely or specifically for what @lifthrasiir mentioned.
Sure, I'll do that later when I have time. There
edit: nevermind, I forgot that python itself has various ways of dealing with such long lines... |
Nice work @mitaa! This seems like it'll definitely be useful for future refactorings of the search index. I idly wonder if it would be possible to write this script in Rust as we're generally trying to move away from Python where possible, but that can always come later. Could you walk through what's necessary to add a new rustdoc test case now? I'm a little worried that it's going to get more difficult as now a python command needs to be run against the file by default. I also wonder if perhaps directives like the html checking may be more flexible instead of an exhaustive specification in all cases, but I'm not entirely sure what that would look like so it seems reasonable to start out this way. |
bc888d4
to
4efa243
Compare
I'm going to change the assignee here, since I don't think I'm the best choice. |
That is a good point.
The only new requirement is to embed a "reference-index" in the test file, or to use the compiletest directive
And then copy the emitted reference-index straight into the test-file. |
Maybe the default should be to not check the search index? That way we could still add tests specifically for it, but adding tests by default wouldn't require the need to run a few extra commands to generate the output. Also, could you make sure that the docs of the search-index.py script at the top prominently say what's supposed to be done to generate the reference index for a particular tests? |
5fc81e1
to
956a76b
Compare
I've flipped the compiletest directive @alexcrichton |
I thought about this more and if you'd prefer I'd be okay trying to rewrite this in rust. Related questions here:
|
Ah sorry for being a bit slow to get back to you on this, I mean to comment last week and then I forgot! To answer some of your questions:
I chatted with @brson about this briefly on IRC, and one interesting point was that this seems like this may end up having a high maintenance cost. Unfortunately you're probably the only one with a deep understanding of the verification script, so changes would likely have a high entry cost for others. Additionally, it's somewhat unclear if this will indeed catch regressions. I've noticed that the htmldockck script hasn't actually prevent a regression (to my knowledge), but that may just be because rustdoc doesn't see much active development so there's not a lot of churn. The search index is also a curious thing here in terms of there's a pretty significant portion of JS which has to interpret and render the index. I suspect that it'd also be very difficult to catch regressions in that logic (and not possible via this script). Overall we seemed a little unsure about whether we'd benefit from this in the long run (e.g. catch more regressions than the maintenance cost of keeping it up-to-date). I'm curious on your thoughts on this though? Do you think it'd be relatively easy to maintain over time? |
Even though I'm often in favor of more tests, I'm also uneasy about this for the reasons @alexcrichton states. Seems like it will be hard to maintain. |
This didn't quite come out as cleanly as I'd have liked, regarding implementation and actual usage. I can see that this might become a maintenance burden, so I'm fine closing this PR. The main motivation here was the impending optimization of the search-index, but I'll try testing the index locally when the time comes. Thanks! |
This adds
src/etc/search-index.py
which canA reference-index is a simplified json-format of the search-index which is used for checking against the rustdoc generated search-index by embedding it into the tests source-file.
A diff between the reference- and search-index will be displayed should they deviate.
fixes #13444