Skip to content

Add doc ui tests #53319

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@ version.texi

no_llvm_build

**node_modules/
**doc-ui/.lock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, do these need to be this much of a blanket ignore? Perhaps we can isolate it to some subpath?

(Very much not important if you don't feel like dealing with it).

1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ impl<'a> Builder<'a> {
test::Clippy,
test::RustdocJS,
test::RustdocTheme,
test::DocUI,
// Run bootstrap close to the end as it's unlikely to fail
test::Bootstrap,
// Run run-make last, since these won't pass without make on Windows
Expand Down
64 changes: 64 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,70 @@ impl Step for RustdocJS {
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct DocUI {
pub host: Interned<String>,
pub target: Interned<String>,
}

impl Step for DocUI {
type Output = ();
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun) -> ShouldRun {
run.path("src/test/doc-ui")
}

fn make_run(run: RunConfig) {
run.builder.ensure(DocUI {
host: run.host,
target: run.target,
});
}

fn run(self, builder: &Builder) {
if let Some(ref nodejs) = builder.config.nodejs {
let mut found_puppeteer = false;
// Check if puppeteer is installed locally.
if let Ok(output) = Command::new("npm")
.args(&["ls", "puppeteer", "puppeteer-core"])
.current_dir("src/tools/doc-ui")
.output() {
found_puppeteer = String::from_utf8_lossy(&output.stdout).contains("puppeteer");
}
if !found_puppeteer {
// Check if puppeteer is installed "globally".
if let Ok(output) = Command::new("npm")
.args(&["ls", "-g", "puppeteer", "puppeteer-core"])
.output() {
found_puppeteer = String::from_utf8_lossy(&output.stdout).contains("puppeteer");
}
}
if !found_puppeteer {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the condition is inverted here, you're running the script only if puppeteer was not found?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is inverted, good find!

let mut command = Command::new(nodejs);
command.args(&["src/tools/doc-ui/script.js",
&*self.host,
&builder.top_stage.to_string()]);
builder.ensure(::doc::Std {
target: self.target,
stage: builder.top_stage,
});
builder.run(&mut command);
} else {
builder.info(&format!(
"No puppeteer found (maybe try installing it with `npm install puppeteer`?), \
skipping \"src/test/doc-ui\" tests"
));
}
} else {
builder.info(&format!(
"No nodejs found, skipping \"src/test/doc-ui\" tests"
));
}
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustdocUi {
pub host: Interned<String>,
Expand Down
Binary file added src/test/doc-ui/images/struct-syntax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/test/doc-ui/lib/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub struct Foo {
pub damn: u32,
pub foo: Option<i8>,
}
13 changes: 13 additions & 0 deletions src/test/doc-ui/struct-syntax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

var TEST = {
"path": "struct.Foo.html",
};
Loading