-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 rustdoc JS non-std tests #58330
Add rustdoc JS non-std tests #58330
Conversation
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.
I'm hesitant to do the doc compilation in the JS script, because compiletest
already has code that we can reuse to build the docs.
I also kinda want to rename the existing rustdoc-js
tests to rustdoc-js-std
, and name this new category as plain rustdoc-js
. (Eventually i'd like to ditch all the rustdoc-js
tests that depend on std, but that's a different matter.)
} | ||
|
||
function remove_docs(out_dir) { | ||
spawnSync('rm', ['-rf', out_dir]); |
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.
Will this work on Windows? The "delete files" command isn't the same.
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.
That's a good point!
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.
I'll just remove this function actually. It's pretty much useless in fact...
console.error(error_text.join("\n")); | ||
} else { | ||
// In this case, we remove the docs, no need to keep them around. | ||
remove_docs(out_folder); |
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.
Removing the built docs every time means we have to rebuild them every time, even if the test crate never changed.
This is one of the reasons i wanted to move the logic into compiletest
, because it can do that timestamp checking to build the docs only when the test (or rustdoc) has changed.
191831e
to
2f407db
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
2f407db
to
48a3297
Compare
Is it good for you now @QuietMisdreavus ? :) |
☔ The latest upstream changes (presumably #58728) made this pull request unmergeable. Please resolve the merge conflicts. |
48a3297
to
240fad0
Compare
You just moved the build logic from the JS into bootstrap itself. That still doesn't account for the fact that it's still going to rebuild every test crate every time, even if neither the test crate nor rustdoc changed between runs. (Unless i'm missing something in how bootstrap and/or rustdoc works?) As far as i know, the code that actually checks whether to rebuild a test crate for its output is in compiletest, not bootstrap. Can you look into moving the test-crate-building into there so we can reuse the conditional-rebuild logic? |
No more wild rebuild. Now it's all handled by |
@@ -2710,6 +2712,25 @@ impl<'test> TestCx<'test> { | |||
fs::remove_dir(path) | |||
} | |||
|
|||
fn run_js_doc_test(&self) { | |||
if let Some(nodejs) = &self.config.nodejs { |
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.
Is self.config
loaded from config.toml
? I'm wondering how the path to the node executable is set.
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.
I took the same code I used previously. But iirc, it is from the config.toml
file.
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.
Yep, and checked in bootstrap (this is a config "passed through" from bootstrap).
cc @Mark-Simulacrum for changes to |
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.
I'm a little confused why we're doing this split (it seems somewhat arbitrary)...
@@ -990,12 +1033,13 @@ impl Step for Compiletest { | |||
.arg(builder.sysroot_libdir(compiler, target)); | |||
cmd.arg("--rustc-path").arg(builder.rustc(compiler)); | |||
|
|||
let is_rustdoc_ui = suite.ends_with("rustdoc-ui"); | |||
let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-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.
It feels like this isn't needed? The compiletest invocation above is has the mode as js-doc-test, which you've also checked below.
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.
It's more convenient to check for instance:
let mut flags = if is_rustdoc {
Vec::new()
} else {
vec!["-Crpath".to_string()]
};
or:
if !is_rustdoc {
if builder.config.rust_optimize_tests {
flags.push("-O".to_string());
}
if builder.config.rust_debuginfo_tests {
flags.push("-g".to_string());
}
}
src/tools/compiletest/src/runtest.rs
Outdated
@@ -290,7 +291,7 @@ impl<'test> TestCx<'test> { | |||
fn should_compile_successfully(&self) -> bool { | |||
match self.config.mode { | |||
CompileFail => self.props.compile_pass, | |||
RunPass => true, | |||
RunPass | JsDocTest => true, |
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.
Instead of the |
could we combine this into separate arms?
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.
Sure!
@@ -2710,6 +2712,25 @@ impl<'test> TestCx<'test> { | |||
fs::remove_dir(path) | |||
} | |||
|
|||
fn run_js_doc_test(&self) { | |||
if let Some(nodejs) = &self.config.nodejs { |
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.
Yep, and checked in bootstrap (this is a config "passed through" from bootstrap).
@@ -2710,6 +2712,25 @@ impl<'test> TestCx<'test> { | |||
fs::remove_dir(path) | |||
} | |||
|
|||
fn run_js_doc_test(&self) { | |||
if let Some(nodejs) = &self.config.nodejs { |
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.
Can we make this call self.fatal("no nodeJS")
or some such? If we're in compiletest we should fail if we don't have a nodeJS here I think
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.
Ok!
let root = self.config.find_rust_src_root().unwrap(); | ||
let res = self.cmd2procres( | ||
Command::new(&nodejs) | ||
.arg(root.join("src/tools/rustdoc-js/tester.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.
Shouldn't this be rustdoc-js-std
?
Either way, I'm confused why we've only migrated one of the suites and not both to compiletest?
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.
The std
one doesn't require to run rustdoc
, just to run some JS. So it's not really required on this side.
|
Updated. |
rustbuild and compiletest changes look good. |
@bors: r=QuietMisdreavus,Mark-Simulacrum |
📌 Commit d6add90 has been approved by |
🌲 The tree is currently closed for pull requests below priority 500, this pull request will be tested once the tree is reopened |
…r=QuietMisdreavus,Mark-Simulacrum Add rustdoc JS non-std tests @QuietMisdreavus: You asked it, here it is! r? @QuietMisdreavus
Failed in #59069 (comment), @bors r- |
How can I run an appveyor instance to test it? |
We have no way to run try builds on AppVeyor. |
Ah. That makes things complicated... :-/ |
Wrote a fix. Can we give it a try? :) |
Seems reasonable to me. @bors r=QuietMisdreavus,Mark-Simulacrum |
📌 Commit 37ab3dc has been approved by |
…reavus,Mark-Simulacrum Add rustdoc JS non-std tests @QuietMisdreavus: You asked it, here it is! r? @QuietMisdreavus
☀️ Test successful - checks-travis, status-appveyor |
[beta] Rollup backports Cherry-picked: * #58021: Fix fallout from #57667 * #59599: Updated RELEASES.md for 1.34.0 * #59587: Remove #[doc(hidden)] from Error::type_id * #58994: Hide deprecation warnings inside derive expansions * #58015: Expand docs for `TryFrom` and `TryInto`. * #59770: ci: pin android emulator to 28.0.23 * #59704: ci: Update FreeBSD tarball downloads * #59257: Update CI configuration for building Redox libraries * #59724: Function arguments should never get promoted * #59499: Fix broken download link in the armhf-gnu image * #58330: Add rustdoc JS non-std tests * #58848: Prevent cache issues on version updates r? @ghost
@QuietMisdreavus: You asked it, here it is!
r? @QuietMisdreavus