Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
548978f
add lib module to `src/tool/compiletest`
onur-ozkan May 9, 2023
c36b209
create new tool rustdoc-gui-test
onur-ozkan May 20, 2023
6a34732
derive `Default` trait for `compiletest::common::Config`
onur-ozkan May 20, 2023
02ea750
add compiletest headers to rustdoc-gui tests
onur-ozkan May 20, 2023
f28a63b
implement and use tools/rustdoc-gui-test in bootstrap
onur-ozkan May 20, 2023
462a96c
[RFC-2011] Expand more expressions
c410-f3r May 25, 2023
b084c52
Generate docs for bootstrap itself
jyn514 May 26, 2023
be44860
fix for `Self` not respecting tuple Ctor privacy
fee1-dead May 5, 2023
e7fa993
do not prefer substs relate during coherence
lcnr May 26, 2023
b6b9611
remove unnecessary `.ok()` calls
lcnr May 26, 2023
39f337a
Make errors from `x doc` less verbose
jyn514 May 26, 2023
c7cec29
add rustdoc-gui-test tool in triagebot.toml
onur-ozkan May 20, 2023
ad77bc8
print const and type errors in braces not square brackets
BoxyUwU May 26, 2023
c71b92f
Rollup merge of #111245 - fee1-dead-contrib:temp-fix-tuple-struct-fie…
compiler-errors May 26, 2023
05f1b00
Rollup merge of #111348 - ozkanonur:remove-hardcoded-rustdoc-flags, r…
compiler-errors May 26, 2023
e6b85ab
Rollup merge of #111928 - c410-f3r:dqewdas, r=eholk
compiler-errors May 26, 2023
a40a67f
Rollup merge of #111976 - jyn514:doc-bootstrap, r=ozkanonur
compiler-errors May 26, 2023
a7d7ad3
Rollup merge of #111977 - jyn514:doc-errors, r=est31
compiler-errors May 26, 2023
a7a33e0
Rollup merge of #111987 - lcnr:alias-relate-coherence, r=BoxyUwU
compiler-errors May 26, 2023
a2f69a4
Rollup merge of #111991 - BoxyUwU:change_error_term_display, r=compil…
compiler-errors May 26, 2023
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
9 changes: 9 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4379,6 +4379,15 @@ dependencies = [
"tracing-tree",
]

[[package]]
name = "rustdoc-gui-test"
version = "0.1.0"
dependencies = [
"compiletest",
"getopts",
"walkdir",
]

[[package]]
name = "rustdoc-json-types"
version = "0.1.0"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ members = [
"src/tools/generate-copyright",
"src/tools/suggest-tests",
"src/tools/generate-windows-sys",
"src/tools/rustdoc-gui-test",
]

exclude = [
Expand Down
6 changes: 4 additions & 2 deletions library/test/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ pub enum ShouldPanic {
}

/// Whether should console output be colored or not
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Default, Debug)]
pub enum ColorConfig {
#[default]
AutoColor,
AlwaysColor,
NeverColor,
}

/// Format of the test results output
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub enum OutputFormat {
/// Verbose output
Pretty,
/// Quiet output
#[default]
Terse,
/// JSON output
Json,
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@ impl<'a> Builder<'a> {
tool::Miri,
tool::CargoMiri,
llvm::Lld,
llvm::CrtBeginEnd
llvm::CrtBeginEnd,
tool::RustdocGUITest,
),
Kind::Check | Kind::Clippy | Kind::Fix => describe!(
check::Std,
Expand Down
116 changes: 28 additions & 88 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,28 +944,6 @@ fn get_browser_ui_test_version(npm: &Path) -> Option<String> {
.or_else(|| get_browser_ui_test_version_inner(npm, true))
}

fn compare_browser_ui_test_version(installed_version: &str, src: &Path) {
match fs::read_to_string(
src.join("src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version"),
) {
Ok(v) => {
if v.trim() != installed_version {
eprintln!(
"⚠️ Installed version of browser-ui-test (`{}`) is different than the \
one used in the CI (`{}`)",
installed_version, v
);
eprintln!(
"You can install this version using `npm update browser-ui-test` or by using \
`npm install browser-ui-test@{}`",
v,
);
}
}
Err(e) => eprintln!("Couldn't find the CI browser-ui-test version: {:?}", e),
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustdocGUI {
pub target: TargetSelection,
Expand Down Expand Up @@ -997,94 +975,56 @@ impl Step for RustdocGUI {
}

fn run(self, builder: &Builder<'_>) {
let nodejs = builder.config.nodejs.as_ref().expect("nodejs isn't available");
let npm = builder.config.npm.as_ref().expect("npm isn't available");

builder.ensure(compile::Std::new(self.compiler, self.target));

// The goal here is to check if the necessary packages are installed, and if not, we
// panic.
match get_browser_ui_test_version(&npm) {
Some(version) => {
// We also check the version currently used in CI and emit a warning if it's not the
// same one.
compare_browser_ui_test_version(&version, &builder.build.src);
}
None => {
eprintln!(
"error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \
dependency is missing",
);
eprintln!(
"If you want to install the `{0}` dependency, run `npm install {0}`",
"browser-ui-test",
);
panic!("Cannot run rustdoc-gui tests");
}
}
let mut cmd = builder.tool_cmd(Tool::RustdocGUITest);

let out_dir = builder.test_out(self.target).join("rustdoc-gui");

// We remove existing folder to be sure there won't be artifacts remaining.
builder.clear_if_dirty(&out_dir, &builder.rustdoc(self.compiler));

let src_path = builder.build.src.join("tests/rustdoc-gui/src");
// We generate docs for the libraries present in the rustdoc-gui's src folder.
for entry in src_path.read_dir().expect("read_dir call failed") {
if let Ok(entry) = entry {
let path = entry.path();
if let Some(src) = builder.config.src.to_str() {
cmd.arg("--rust-src").arg(src);
}

if !path.is_dir() {
continue;
}
if let Some(out_dir) = out_dir.to_str() {
cmd.arg("--out-dir").arg(out_dir);
}

let mut cargo = Command::new(&builder.initial_cargo);
cargo
.arg("doc")
.arg("--target-dir")
.arg(&out_dir)
.env("RUSTC_BOOTSTRAP", "1")
.env("RUSTDOC", builder.rustdoc(self.compiler))
.env("RUSTC", builder.rustc(self.compiler))
.current_dir(path);
// FIXME: implement a `// compile-flags` command or similar
// instead of hard-coding this test
if entry.file_name() == "link_to_definition" {
cargo.env("RUSTDOCFLAGS", "-Zunstable-options --generate-link-to-definition");
} else if entry.file_name() == "scrape_examples" {
cargo.arg("-Zrustdoc-scrape-examples");
} else if entry.file_name() == "extend_css" {
cargo.env("RUSTDOCFLAGS", &format!("--extend-css extra.css"));
}
builder.run(&mut cargo);
}
if let Some(initial_cargo) = builder.config.initial_cargo.to_str() {
cmd.arg("--initial-cargo").arg(initial_cargo);
}

// We now run GUI tests.
let mut command = Command::new(&nodejs);
command
.arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
.arg("--jobs")
.arg(&builder.jobs().to_string())
.arg("--doc-folder")
.arg(out_dir.join("doc"))
.arg("--tests-folder")
.arg(builder.build.src.join("tests/rustdoc-gui"));
cmd.arg("--jobs").arg(builder.jobs().to_string());

cmd.env("RUSTDOC", builder.rustdoc(self.compiler))
.env("RUSTC", builder.rustc(self.compiler));

for path in &builder.paths {
if let Some(p) = util::is_valid_test_suite_arg(path, "tests/rustdoc-gui", builder) {
if !p.ends_with(".goml") {
eprintln!("A non-goml file was given: `{}`", path.display());
panic!("Cannot run rustdoc-gui tests");
}
if let Some(name) = path.file_name().and_then(|f| f.to_str()) {
command.arg("--file").arg(name);
cmd.arg("--goml-file").arg(name);
}
}
}

for test_arg in builder.config.test_args() {
command.arg(test_arg);
cmd.arg("--test-arg").arg(test_arg);
}
builder.run(&mut command);

if let Some(ref nodejs) = builder.config.nodejs {
cmd.arg("--nodejs").arg(nodejs);
}

if let Some(ref npm) = builder.config.npm {
cmd.arg("--npm").arg(npm);
}

let _time = util::timeit(&builder);
crate::render_tests::try_run_tests(builder, &mut cmd);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ bootstrap_tool!(
GenerateCopyright, "src/tools/generate-copyright", "generate-copyright";
SuggestTests, "src/tools/suggest-tests", "suggest-tests";
GenerateWindowsSys, "src/tools/generate-windows-sys", "generate-windows-sys";
RustdocGUITest, "src/tools/rustdoc-gui-test", "rustdoc-gui-test", is_unstable_tool = true, allow_features = "test";
);

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "compiletest"
version = "0.0.0"
edition = "2021"

[lib]
doctest = false

[dependencies]
colored = "2"
diff = "0.1.10"
Expand Down
8 changes: 7 additions & 1 deletion src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ string_enum! {
}
}

impl Default for Mode {
fn default() -> Self {
Mode::Ui
}
}

impl Mode {
pub fn disambiguator(self) -> &'static str {
// Pretty-printing tests could run concurrently, and if they do,
Expand Down Expand Up @@ -125,7 +131,7 @@ pub enum PanicStrategy {
}

/// Configuration for compiletest
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone)]
pub struct Config {
/// `true` to overwrite stderr/stdout files instead of complaining about changes in output.
pub bless: bool,
Expand Down
Loading