Skip to content

Commit 4b2a1eb

Browse files
committed
Support unit tests for jsondoclint
1 parent 8681d4c commit 4b2a1eb

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ impl<'a> Builder<'a> {
644644
test::CrateLibrustc,
645645
test::CrateRustdoc,
646646
test::CrateRustdocJsonTypes,
647+
test::CrateJsonDocLint,
647648
test::Linkcheck,
648649
test::TierCheck,
649650
test::ReplacePlaceholderTest,

src/bootstrap/test.rs

+36
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,42 @@ fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool {
9090
true
9191
}
9292

93+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
94+
pub struct CrateJsonDocLint {
95+
host: TargetSelection,
96+
}
97+
98+
impl Step for CrateJsonDocLint {
99+
type Output = ();
100+
const ONLY_HOSTS: bool = true;
101+
const DEFAULT: bool = true;
102+
103+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
104+
run.path("src/tools/jsondoclint")
105+
}
106+
107+
fn make_run(run: RunConfig<'_>) {
108+
run.builder.ensure(CrateJsonDocLint { host: run.target });
109+
}
110+
111+
fn run(self, builder: &Builder<'_>) {
112+
let bootstrap_host = builder.config.build;
113+
let compiler = builder.compiler(0, bootstrap_host);
114+
115+
let cargo = tool::prepare_tool_cargo(
116+
builder,
117+
compiler,
118+
Mode::ToolBootstrap,
119+
bootstrap_host,
120+
"test",
121+
"src/tools/jsondoclint",
122+
SourceType::InTree,
123+
&[],
124+
);
125+
try_run(builder, &mut cargo.into());
126+
}
127+
}
128+
93129
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
94130
pub struct Linkcheck {
95131
host: TargetSelection,

src/tools/jsondoclint/src/json_find.rs

+3
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ fn find_selector_recursive(
7272
}
7373
}
7474
}
75+
76+
#[cfg(test)]
77+
mod tests;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[test]
2+
fn should_fail() {
3+
assert_eq!(true, false);
4+
}

0 commit comments

Comments
 (0)