Skip to content
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

Merged
merged 7 commits into from
Mar 12, 2019
Merged

Conversation

GuillaumeGomez
Copy link
Member

@QuietMisdreavus: You asked it, here it is!

r? @QuietMisdreavus

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 9, 2019
Copy link
Member

@QuietMisdreavus QuietMisdreavus left a 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]);
Copy link
Member

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.

Copy link
Member Author

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!

Copy link
Member Author

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);
Copy link
Member

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.

@QuietMisdreavus QuietMisdreavus added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 19, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:091c19d0:start=1550966806933647647,finish=1550966809206830415,duration=2273182768
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:02:30]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:02:32] error[E0308]: mismatched types
[00:02:32]    --> src/bootstrap/test.rs:653:53
[00:02:32]     |
[00:02:32] 653 |                         if path.extension() == Some("rs") {
[00:02:32]     |                                                     ^^^^ expected struct `std::ffi::OsStr`, found str
[00:02:32]     = note: expected type `&std::ffi::OsStr`
[00:02:32]                found type `&'static str`
[00:02:32] 
[00:02:32] 
[00:02:32] error[E0277]: the trait bound `std::option::Option<&std::ffi::OsStr>: std::convert::AsRef<std::path::Path>` is not satisfied
[00:02:32]    --> src/bootstrap/test.rs:654:43
[00:02:32]     |
[00:02:32] 654 |                             let out = out.join(path.file_stem());
[00:02:32]     |                                           ^^^^ the trait `std::convert::AsRef<std::path::Path>` is not implemented for `std::option::Option<&std::ffi::OsStr>`
[00:02:32] 
[00:02:32] error[E0599]: no method named `to_os_string` found for type `std::option::Option<&std::ffi::OsStr>` in the current scope
[00:02:32]    --> src/bootstrap/test.rs:659:63
[00:02:32]     |
[00:02:32] 659 |                             tests_to_run.push(out.file_stem().to_os_string());
[00:02:32] 
[00:02:34] error: aborting due to 3 previous errors
[00:02:34] 
[00:02:34] Some errors occurred: E0277, E0308, E0599.
---
[00:02:36]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:02:38] error[E0308]: mismatched types
[00:02:38]    --> src/bootstrap/test.rs:653:53
[00:02:38]     |
[00:02:38] 653 |                         if path.extension() == Some("rs") {
[00:02:38]     |                                                     ^^^^ expected struct `std::ffi::OsStr`, found str
[00:02:38]     = note: expected type `&std::ffi::OsStr`
[00:02:38]                found type `&'static str`
[00:02:38] 
[00:02:38] 
[00:02:38] error[E0277]: the trait bound `std::option::Option<&std::ffi::OsStr>: std::convert::AsRef<std::path::Path>` is not satisfied
[00:02:38]    --> src/bootstrap/test.rs:654:43
[00:02:38]     |
[00:02:38] 654 |                             let out = out.join(path.file_stem());
[00:02:38]     |                                           ^^^^ the trait `std::convert::AsRef<std::path::Path>` is not implemented for `std::option::Option<&std::ffi::OsStr>`
[00:02:38] 
[00:02:38] error[E0599]: no method named `to_os_string` found for type `std::option::Option<&std::ffi::OsStr>` in the current scope
[00:02:38]    --> src/bootstrap/test.rs:659:63
[00:02:38]     |
[00:02:38] 659 |                             tests_to_run.push(out.file_stem().to_os_string());
[00:02:38] 
[00:02:39] error: aborting due to 3 previous errors
[00:02:39] 
[00:02:39] Some errors occurred: E0277, E0308, E0599.
---
[00:02:42]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:02:44] error[E0308]: mismatched types
[00:02:44]    --> src/bootstrap/test.rs:653:53
[00:02:44]     |
[00:02:44] 653 |                         if path.extension() == Some("rs") {
[00:02:44]     |                                                     ^^^^ expected struct `std::ffi::OsStr`, found str
[00:02:44]     = note: expected type `&std::ffi::OsStr`
[00:02:44]                found type `&'static str`
[00:02:44] 
[00:02:44] 
[00:02:44] error[E0277]: the trait bound `std::option::Option<&std::ffi::OsStr>: std::convert::AsRef<std::path::Path>` is not satisfied
[00:02:44]    --> src/bootstrap/test.rs:654:43
[00:02:44]     |
[00:02:44] 654 |                             let out = out.join(path.file_stem());
[00:02:44]     |                                           ^^^^ the trait `std::convert::AsRef<std::path::Path>` is not implemented for `std::option::Option<&std::ffi::OsStr>`
[00:02:44] 
[00:02:44] error[E0599]: no method named `to_os_string` found for type `std::option::Option<&std::ffi::OsStr>` in the current scope
[00:02:44]    --> src/bootstrap/test.rs:659:63
[00:02:44]     |
[00:02:44] 659 |                             tests_to_run.push(out.file_stem().to_os_string());
[00:02:44] 
[00:02:46] error: aborting due to 3 previous errors
[00:02:46] 
[00:02:46] Some errors occurred: E0277, E0308, E0599.
---
[00:02:49]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:02:51] error[E0308]: mismatched types
[00:02:51]    --> src/bootstrap/test.rs:653:53
[00:02:51]     |
[00:02:51] 653 |                         if path.extension() == Some("rs") {
[00:02:51]     |                                                     ^^^^ expected struct `std::ffi::OsStr`, found str
[00:02:51]     = note: expected type `&std::ffi::OsStr`
[00:02:51]                found type `&'static str`
[00:02:51] 
[00:02:51] 
[00:02:51] error[E0277]: the trait bound `std::option::Option<&std::ffi::OsStr>: std::convert::AsRef<std::path::Path>` is not satisfied
[00:02:51]    --> src/bootstrap/test.rs:654:43
[00:02:51]     |
[00:02:51] 654 |                             let out = out.join(path.file_stem());
[00:02:51]     |                                           ^^^^ the trait `std::convert::AsRef<std::path::Path>` is not implemented for `std::option::Option<&std::ffi::OsStr>`
[00:02:51] 
[00:02:51] error[E0599]: no method named `to_os_string` found for type `std::option::Option<&std::ffi::OsStr>` in the current scope
[00:02:51]    --> src/bootstrap/test.rs:659:63
[00:02:51]     |
[00:02:51] 659 |                             tests_to_run.push(out.file_stem().to_os_string());
[00:02:51] 
[00:02:53] error: aborting due to 3 previous errors
[00:02:53] 
[00:02:53] Some errors occurred: E0277, E0308, E0599.
---
[00:02:57]    Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
[00:03:00] error[E0308]: mismatched types
[00:03:00]    --> src/bootstrap/test.rs:653:53
[00:03:00]     |
[00:03:00] 653 |                         if path.extension() == Some("rs") {
[00:03:00]     |                                                     ^^^^ expected struct `std::ffi::OsStr`, found str
[00:03:00]     = note: expected type `&std::ffi::OsStr`
[00:03:00]                found type `&'static str`
[00:03:00] 
[00:03:00] 
[00:03:00] error[E0277]: the trait bound `std::option::Option<&std::ffi::OsStr>: std::convert::AsRef<std::path::Path>` is not satisfied
[00:03:00]    --> src/bootstrap/test.rs:654:43
[00:03:00]     |
[00:03:00] 654 |                             let out = out.join(path.file_stem());
[00:03:00]     |                                           ^^^^ the trait `std::convert::AsRef<std::path::Path>` is not implemented for `std::option::Option<&std::ffi::OsStr>`
[00:03:00] 
[00:03:00] error[E0599]: no method named `to_os_string` found for type `std::option::Option<&std::ffi::OsStr>` in the current scope
[00:03:00]    --> src/bootstrap/test.rs:659:63
[00:03:00]     |
[00:03:00] 659 |                             tests_to_run.push(out.file_stem().to_os_string());
[00:03:00] 
[00:03:01] error: aborting due to 3 previous errors
[00:03:01] 
[00:03:01] Some errors occurred: E0277, E0308, E0599.

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 @TimNN. (Feature Requests)

@GuillaumeGomez
Copy link
Member Author

Is it good for you now @QuietMisdreavus ? :)

@bors
Copy link
Contributor

bors commented Feb 25, 2019

☔ The latest upstream changes (presumably #58728) made this pull request unmergeable. Please resolve the merge conflicts.

@QuietMisdreavus
Copy link
Member

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?

@GuillaumeGomez
Copy link
Member Author

No more wild rebuild. Now it's all handled by compiletest directly! Nice catch in here @QuietMisdreavus :)

@@ -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 {
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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).

@QuietMisdreavus
Copy link
Member

cc @Mark-Simulacrum for changes to compiletest (please add more people if you're not the right person!)

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a 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");
Copy link
Member

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.

Copy link
Member Author

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());
    }
}

@@ -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,
Copy link
Member

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?

Copy link
Member Author

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 {
Copy link
Member

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 {
Copy link
Member

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

Copy link
Member Author

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"))
Copy link
Member

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?

Copy link
Member Author

@GuillaumeGomez GuillaumeGomez Mar 6, 2019

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.

@GuillaumeGomez
Copy link
Member Author

I'm a little confused why we're doing this split (it seems somewhat arbitrary)...

rustdoc-js-std is based on std docs, this one isn't and will allow us to avoid breaking changes due to API updates.

@GuillaumeGomez
Copy link
Member Author

Updated.

@Mark-Simulacrum
Copy link
Member

rustbuild and compiletest changes look good.

@GuillaumeGomez
Copy link
Member Author

@bors: r=QuietMisdreavus,Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Mar 7, 2019

📌 Commit d6add90 has been approved by QuietMisdreavus,Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Mar 7, 2019

🌲 The tree is currently closed for pull requests below priority 500, this pull request will be tested once the tree is reopened

Centril added a commit to Centril/rust that referenced this pull request Mar 10, 2019
…r=QuietMisdreavus,Mark-Simulacrum

Add rustdoc JS non-std tests

@QuietMisdreavus: You asked it, here it is!

r? @QuietMisdreavus
@Centril
Copy link
Contributor

Centril commented Mar 10, 2019

Failed in #59069 (comment), @bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 10, 2019
@GuillaumeGomez
Copy link
Member Author

How can I run an appveyor instance to test it?

@Centril
Copy link
Contributor

Centril commented Mar 10, 2019

cc @Mark-Simulacrum @pietroalbini ^

@pietroalbini
Copy link
Member

We have no way to run try builds on AppVeyor.

@GuillaumeGomez
Copy link
Member Author

Ah. That makes things complicated... :-/

@GuillaumeGomez
Copy link
Member Author

Wrote a fix. Can we give it a try? :)

@GuillaumeGomez
Copy link
Member Author

cc @Centril @pietroalbini

@QuietMisdreavus
Copy link
Member

Seems reasonable to me.

@bors r=QuietMisdreavus,Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Mar 12, 2019

📌 Commit 37ab3dc has been approved by QuietMisdreavus,Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 12, 2019
bors added a commit that referenced this pull request Mar 12, 2019
…reavus,Mark-Simulacrum

Add rustdoc JS non-std tests

@QuietMisdreavus: You asked it, here it is!

r? @QuietMisdreavus
@bors
Copy link
Contributor

bors commented Mar 12, 2019

⌛ Testing commit 37ab3dc with merge d06a020...

@bors
Copy link
Contributor

bors commented Mar 12, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: QuietMisdreavus,Mark-Simulacrum
Pushing d06a020 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 12, 2019
@bors bors merged commit 37ab3dc into rust-lang:master Mar 12, 2019
@GuillaumeGomez GuillaumeGomez deleted the rustdoc-js-non-std branch March 12, 2019 20:28
@pietroalbini pietroalbini added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Apr 8, 2019
bors added a commit that referenced this pull request Apr 8, 2019
[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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants