Skip to content

Commit c4d342e

Browse files
authored
Rollup merge of rust-lang#58330 - GuillaumeGomez:rustdoc-js-non-std, r=QuietMisdreavus,Mark-Simulacrum
Add rustdoc JS non-std tests @QuietMisdreavus: You asked it, here it is! r? @QuietMisdreavus
2 parents a0f4e6a + d6add90 commit c4d342e

28 files changed

+455
-39
lines changed

src/bootstrap/builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ impl<'a> Builder<'a> {
405405
test::Miri,
406406
test::Clippy,
407407
test::CompiletestTest,
408-
test::RustdocJS,
408+
test::RustdocJSStd,
409+
test::RustdocJSNotStd,
409410
test::RustdocTheme,
410411
// Run bootstrap close to the end as it's unlikely to fail
411412
test::Bootstrap,

src/bootstrap/test.rs

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,22 +574,22 @@ impl Step for RustdocTheme {
574574
}
575575

576576
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
577-
pub struct RustdocJS {
577+
pub struct RustdocJSStd {
578578
pub host: Interned<String>,
579579
pub target: Interned<String>,
580580
}
581581

582-
impl Step for RustdocJS {
582+
impl Step for RustdocJSStd {
583583
type Output = ();
584584
const DEFAULT: bool = true;
585585
const ONLY_HOSTS: bool = true;
586586

587587
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
588-
run.path("src/test/rustdoc-js")
588+
run.path("src/test/rustdoc-js-std")
589589
}
590590

591591
fn make_run(run: RunConfig<'_>) {
592-
run.builder.ensure(RustdocJS {
592+
run.builder.ensure(RustdocJSStd {
593593
host: run.host,
594594
target: run.target,
595595
});
@@ -598,12 +598,55 @@ impl Step for RustdocJS {
598598
fn run(self, builder: &Builder<'_>) {
599599
if let Some(ref nodejs) = builder.config.nodejs {
600600
let mut command = Command::new(nodejs);
601-
command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]);
601+
command.args(&["src/tools/rustdoc-js-std/tester.js", &*self.host]);
602602
builder.ensure(crate::doc::Std {
603603
target: self.target,
604604
stage: builder.top_stage,
605605
});
606606
builder.run(&mut command);
607+
} else {
608+
builder.info(
609+
"No nodejs found, skipping \"src/test/rustdoc-js-std\" tests"
610+
);
611+
}
612+
}
613+
}
614+
615+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
616+
pub struct RustdocJSNotStd {
617+
pub host: Interned<String>,
618+
pub target: Interned<String>,
619+
pub compiler: Compiler,
620+
}
621+
622+
impl Step for RustdocJSNotStd {
623+
type Output = ();
624+
const DEFAULT: bool = true;
625+
const ONLY_HOSTS: bool = true;
626+
627+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
628+
run.path("src/test/rustdoc-js")
629+
}
630+
631+
fn make_run(run: RunConfig<'_>) {
632+
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
633+
run.builder.ensure(RustdocJSNotStd {
634+
host: run.host,
635+
target: run.target,
636+
compiler,
637+
});
638+
}
639+
640+
fn run(self, builder: &Builder<'_>) {
641+
if builder.config.nodejs.is_some() {
642+
builder.ensure(Compiletest {
643+
compiler: self.compiler,
644+
target: self.target,
645+
mode: "js-doc-test",
646+
suite: "rustdoc-js",
647+
path: None,
648+
compare_mode: None,
649+
});
607650
} else {
608651
builder.info(
609652
"No nodejs found, skipping \"src/test/rustdoc-js\" tests"
@@ -990,12 +1033,13 @@ impl Step for Compiletest {
9901033
.arg(builder.sysroot_libdir(compiler, target));
9911034
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
9921035

993-
let is_rustdoc_ui = suite.ends_with("rustdoc-ui");
1036+
let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js");
9941037

9951038
// Avoid depending on rustdoc when we don't need it.
9961039
if mode == "rustdoc"
9971040
|| (mode == "run-make" && suite.ends_with("fulldeps"))
998-
|| (mode == "ui" && is_rustdoc_ui)
1041+
|| (mode == "ui" && is_rustdoc)
1042+
|| mode == "js-doc-test"
9991043
{
10001044
cmd.arg("--rustdoc-path")
10011045
.arg(builder.rustdoc(compiler.host));
@@ -1029,12 +1073,12 @@ impl Step for Compiletest {
10291073
cmd.arg("--nodejs").arg(nodejs);
10301074
}
10311075

1032-
let mut flags = if is_rustdoc_ui {
1076+
let mut flags = if is_rustdoc {
10331077
Vec::new()
10341078
} else {
10351079
vec!["-Crpath".to_string()]
10361080
};
1037-
if !is_rustdoc_ui {
1081+
if !is_rustdoc {
10381082
if builder.config.rust_optimize_tests {
10391083
flags.push("-O".to_string());
10401084
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/test/rustdoc-js-std/basic.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const QUERY = 'String';
2+
3+
const EXPECTED = {
4+
'others': [
5+
{ 'path': 'std::string', 'name': 'String' },
6+
{ 'path': 'std::ffi', 'name': 'CString' },
7+
{ 'path': 'std::ffi', 'name': 'OsString' },
8+
],
9+
'in_args': [
10+
{ 'path': 'std::str', 'name': 'eq' },
11+
],
12+
'returned': [
13+
{ 'path': 'std::string::String', 'name': 'add' },
14+
],
15+
};

0 commit comments

Comments
 (0)