Skip to content

Commit e05409a

Browse files
committed
Auto merge of #81063 - CraftSpider:jsondocck, r=jyn514
Add JsonDocCk Tool for rustdoc-json Implements a new test system for rustdoc JSON output, jsondocck. Modeled after htmldocck, this tool reads directives in the test file and checks them against the output. These directives use JSONPath, a pair to XPath for json. This obsoletes the old strict subset tool, allowing both finer-grained control of what is tested and better errors on failure. Not sure on the changes to Cargo.lock, I can back that out if needed. r? `@jyn514`
2 parents 14265f9 + ba6803e commit e05409a

24 files changed

+504
-816
lines changed

Cargo.lock

+37-4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ version = "0.4.7"
101101
source = "registry+https://github.com/rust-lang/crates.io-index"
102102
checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034"
103103

104+
[[package]]
105+
name = "array_tool"
106+
version = "1.0.3"
107+
source = "registry+https://github.com/rust-lang/crates.io-index"
108+
checksum = "8f8cb5d814eb646a863c4f24978cff2880c4be96ad8cde2c0f0678732902e271"
109+
104110
[[package]]
105111
name = "arrayref"
106112
version = "0.3.6"
@@ -1630,6 +1636,32 @@ version = "0.11.15"
16301636
source = "registry+https://github.com/rust-lang/crates.io-index"
16311637
checksum = "92c245af8786f6ac35f95ca14feca9119e71339aaab41e878e7cdd655c97e9e5"
16321638

1639+
[[package]]
1640+
name = "jsondocck"
1641+
version = "0.1.0"
1642+
dependencies = [
1643+
"getopts",
1644+
"jsonpath_lib",
1645+
"lazy_static",
1646+
"regex",
1647+
"serde",
1648+
"serde_json",
1649+
"shlex",
1650+
]
1651+
1652+
[[package]]
1653+
name = "jsonpath_lib"
1654+
version = "0.2.6"
1655+
source = "registry+https://github.com/rust-lang/crates.io-index"
1656+
checksum = "61352ec23883402b7d30b3313c16cbabefb8907361c4eb669d990cbb87ceee5a"
1657+
dependencies = [
1658+
"array_tool",
1659+
"env_logger 0.7.1",
1660+
"log",
1661+
"serde",
1662+
"serde_json",
1663+
]
1664+
16331665
[[package]]
16341666
name = "jsonrpc-client-transports"
16351667
version = "14.2.1"
@@ -2854,9 +2886,9 @@ dependencies = [
28542886

28552887
[[package]]
28562888
name = "regex"
2857-
version = "1.3.9"
2889+
version = "1.4.3"
28582890
source = "registry+https://github.com/rust-lang/crates.io-index"
2859-
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
2891+
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
28602892
dependencies = [
28612893
"aho-corasick",
28622894
"memchr",
@@ -2876,9 +2908,9 @@ dependencies = [
28762908

28772909
[[package]]
28782910
name = "regex-syntax"
2879-
version = "0.6.18"
2911+
version = "0.6.22"
28802912
source = "registry+https://github.com/rust-lang/crates.io-index"
2881-
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
2913+
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
28822914

28832915
[[package]]
28842916
name = "remote-test-client"
@@ -4578,6 +4610,7 @@ version = "1.0.59"
45784610
source = "registry+https://github.com/rust-lang/crates.io-index"
45794611
checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95"
45804612
dependencies = [
4613+
"indexmap",
45814614
"itoa",
45824615
"ryu",
45834616
"serde",

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ members = [
3131
"src/tools/rustdoc-themes",
3232
"src/tools/unicode-table-generator",
3333
"src/tools/expand-yaml-anchors",
34+
"src/tools/jsondocck",
3435
]
3536

3637
exclude = [

src/bootstrap/test.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,13 @@ note: if you're sure you want to do this, please open an issue as to why. In the
10111011
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
10121012
}
10131013

1014+
if mode == "rustdoc-json" {
1015+
// Use the beta compiler for jsondocck
1016+
let json_compiler = compiler.with_stage(0);
1017+
cmd.arg("--jsondocck-path")
1018+
.arg(builder.ensure(tool::JsonDocCk { compiler: json_compiler, target }));
1019+
}
1020+
10141021
if mode == "run-make" && suite.ends_with("fulldeps") {
10151022
cmd.arg("--rust-demangler-path").arg(builder.tool_exe(Tool::RustDemangler));
10161023
}

src/bootstrap/tool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ bootstrap_tool!(
367367
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
368368
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
369369
LintDocs, "src/tools/lint-docs", "lint-docs";
370+
JsonDocCk, "src/tools/jsondocck", "jsondocck";
370371
);
371372

372373
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]

src/test/rustdoc-json/check_missing_items.py renamed to src/etc/check_missing_items.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# `index` or `paths`. It DOES NOT check that the structure of the produced json is actually in
55
# any way correct, for example an empty map would pass.
66

7+
# FIXME: Better error output
8+
79
import sys
810
import json
911

src/test/rustdoc-json/compare.py

-132
This file was deleted.

0 commit comments

Comments
 (0)