-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Fix bug where rustdoc-js
tester would not pick the right search.js
file if there is more than one
#145359
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
Fix bug where rustdoc-js
tester would not pick the right search.js
file if there is more than one
#145359
Conversation
r? @notriddle rustbot has assigned @notriddle. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, besides two tiny edge cases that probably don't matter:
- if another search-related js file is added, the regex may be too permissive (can just be fixed whenever it comes up, and hopefully won't be too much of a pain to debug)
- if somehow no file matches, this will give an index out of bounds error (but it should also give a stack trace pointing right to the code that needs updating)
Also considered if this could hit editor temporary files, but since the regex checks prefix and suffix, it never should.
src/tools/rustdoc-js/tester.js
Outdated
@@ -452,7 +467,7 @@ function loadSearchJS(doc_folder, resource_suffix) { | |||
}; | |||
|
|||
const staticFiles = path.join(doc_folder, "static.files"); | |||
const searchJs = fs.readdirSync(staticFiles).find(f => f.match(/search.*\.js$/)); | |||
const searchJs = mostRecentMatch(staticFiles, /search.*\.js$/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const searchJs = mostRecentMatch(staticFiles, /search.*\.js$/); | |
const searchJs = mostRecentMatch(staticFiles, /search-[0-9a-f]{8}.*\.js$/); |
What do you think about making the regex a bit stricter in case we add another search-related js module at some point? The .*
is still needed because of --resource-suffix
, but maybe it would be a bit more reliable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, applied it.
3c76b67
to
97400fd
Compare
This PR was rebased onto a different master commit! Check out the changes with our |
I added a check for the number of matching files and it emits an exception if it's 0. @bors delegate=lolbinarycat |
✌️ @lolbinarycat, you can now approve this pull request! If @GuillaumeGomez told you to " |
This comment has been minimized.
This comment has been minimized.
97400fd
to
826ebde
Compare
@bors r+ |
…ch.js, r=lolbinarycat Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one It happened to me quite a few times recently when I worked on the search index: 1. I make a change in search.js 2. I run `rustdoc-js` tests 3. nothing changes So my solution was to simply remove the folder, but it's really suboptimal. With this PR, it now picks the most recently modified file. cc ``@lolbinarycat``
…ch.js, r=lolbinarycat Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one It happened to me quite a few times recently when I worked on the search index: 1. I make a change in search.js 2. I run `rustdoc-js` tests 3. nothing changes So my solution was to simply remove the folder, but it's really suboptimal. With this PR, it now picks the most recently modified file. cc ```@lolbinarycat```
…ch.js, r=lolbinarycat Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one It happened to me quite a few times recently when I worked on the search index: 1. I make a change in search.js 2. I run `rustdoc-js` tests 3. nothing changes So my solution was to simply remove the folder, but it's really suboptimal. With this PR, it now picks the most recently modified file. cc ````@lolbinarycat````
Rollup of 19 pull requests Successful merges: - #140956 (`impl PartialEq<{str,String}> for {Path,PathBuf}`) - #141744 (Stabilize `ip_from`) - #144804 (Don't warn on never to any `as` casts as unreachable) - #144983 (Rehome 37 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`) - #145025 (run spellcheck as a tidy extra check in ci) - #145041 (rework GAT borrowck limitation error) - #145243 (take attr style into account in diagnostics) - #145359 (Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one) - #145429 (Couple of codegen_fn_attrs improvements) - #145452 (Do not strip binaries in bootstrap everytime if they are unchanged) - #145486 (Fix `unicode_data.rs` mention message) - #145489 (library: Migrate from `cfg_if` to `cfg_select`) - #145493 (remove `should_render` in `PrintAttribute` derive) - #145500 (Port must_use to the new target checking) - #145505 (Simplify span caches) - #145511 (Rust build fails on OpenBSD after using file_lock feature) - #145516 (Weekly `cargo update`) - #145533 (Reorder `lto` options from most to least optimizing) - #145550 (Avoid using `()` in `derive(From)` output.) r? `@ghost` `@rustbot` modify labels: rollup
…ch.js, r=lolbinarycat Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one It happened to me quite a few times recently when I worked on the search index: 1. I make a change in search.js 2. I run `rustdoc-js` tests 3. nothing changes So my solution was to simply remove the folder, but it's really suboptimal. With this PR, it now picks the most recently modified file. cc `````@lolbinarycat`````
Rollup of 19 pull requests Successful merges: - #140956 (`impl PartialEq<{str,String}> for {Path,PathBuf}`) - #141744 (Stabilize `ip_from`) - #142681 (Remove the `#[no_sanitize]` attribute in favor of `#[sanitize(xyz = "on|off")]`) - #142871 (Trivial improve doc for transpose ) - #144252 (Do not copy .rmeta files into the sysroot of the build compiler during check of rustc/std) - #144476 (rustdoc-search: search backend with partitioned suffix tree) - #144567 (Fix RISC-V Test Failures in ./x test for Multiple Codegen Cases) - #144804 (Don't warn on never to any `as` casts as unreachable) - #144960 ([RTE-513] Ignore sleep_until test on SGX) - #145013 (overhaul `&mut` suggestions in borrowck errors) - #145041 (rework GAT borrowck limitation error) - #145243 (take attr style into account in diagnostics) - #145405 (cleanup: use run_in_tmpdir in run-make/rustdoc-scrape-examples-paths) - #145432 (cg_llvm: Small cleanups to `owned_target_machine`) - #145484 (Remove `LlvmArchiveBuilder` and supporting code/bindings) - #145557 (Fix uplifting in `Assemble` step) - #145563 (Remove the `From` derive macro from prelude) - #145565 (Improve context of bootstrap errors in CI) - #145584 (interpret: avoid forcing all integer newtypes into memory during clear_provenance) Failed merges: - #145359 (Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one) - #145573 (Add an experimental unsafe(force_target_feature) attribute.) r? `@ghost` `@rustbot` modify labels: rollup
Merge conflict. |
…` file if there is more than one
826ebde
to
2ebe679
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
@bors r=lolbinarycat rollup |
…ch.js, r=lolbinarycat Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one It happened to me quite a few times recently when I worked on the search index: 1. I make a change in search.js 2. I run `rustdoc-js` tests 3. nothing changes So my solution was to simply remove the folder, but it's really suboptimal. With this PR, it now picks the most recently modified file. cc `@lolbinarycat`
…ch.js, r=lolbinarycat Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one It happened to me quite a few times recently when I worked on the search index: 1. I make a change in search.js 2. I run `rustdoc-js` tests 3. nothing changes So my solution was to simply remove the folder, but it's really suboptimal. With this PR, it now picks the most recently modified file. cc ``@lolbinarycat``
Rollup of 13 pull requests Successful merges: - #139357 (Fix parameter order for `_by()` variants of `min` / `max`/ `minmax` in `std::cmp`) - #140314 (Rustdoc: typecheck scrape-examples.js) - #140794 (mention lint group in default level lint note) - #145006 (Clarify EOF handling for `BufRead::skip_until`) - #145252 (Demote x86_64-apple-darwin to Tier 2 with host tools) - #145359 (Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one) - #145381 (Implement feature `int_lowest_highest_one` for integer and NonZero types) - #145417 (std_detect: RISC-V platform guide documentation) - #145531 (Add runtime detection for APX-F and AVX10) - #145619 (`std_detect`: Use `rustc-std-workspace-*` to pull in `compiler-builtins`) - #145622 (Remove the std workspace patch for `compiler-builtins`) - #145623 (Pretty print the name of an future from calling async closure) - #145626 (add a fallback implementation for the `prefetch_*` intrinsics ) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #145359 - GuillaumeGomez:correctly-pick-search.js, r=lolbinarycat Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one It happened to me quite a few times recently when I worked on the search index: 1. I make a change in search.js 2. I run `rustdoc-js` tests 3. nothing changes So my solution was to simply remove the folder, but it's really suboptimal. With this PR, it now picks the most recently modified file. cc ```@lolbinarycat```
It happened to me quite a few times recently when I worked on the search index:
rustdoc-js
testsSo my solution was to simply remove the folder, but it's really suboptimal. With this PR, it now picks the most recently modified file.
cc @lolbinarycat