Skip to content

Commit

Permalink
Auto merge of #81063 - CraftSpider:jsondocck, r=jyn514
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed Jan 20, 2021
2 parents 14265f9 + ba6803e commit e05409a
Show file tree
Hide file tree
Showing 24 changed files with 504 additions and 816 deletions.
41 changes: 37 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034"

[[package]]
name = "array_tool"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f8cb5d814eb646a863c4f24978cff2880c4be96ad8cde2c0f0678732902e271"

[[package]]
name = "arrayref"
version = "0.3.6"
Expand Down Expand Up @@ -1630,6 +1636,32 @@ version = "0.11.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92c245af8786f6ac35f95ca14feca9119e71339aaab41e878e7cdd655c97e9e5"

[[package]]
name = "jsondocck"
version = "0.1.0"
dependencies = [
"getopts",
"jsonpath_lib",
"lazy_static",
"regex",
"serde",
"serde_json",
"shlex",
]

[[package]]
name = "jsonpath_lib"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61352ec23883402b7d30b3313c16cbabefb8907361c4eb669d990cbb87ceee5a"
dependencies = [
"array_tool",
"env_logger 0.7.1",
"log",
"serde",
"serde_json",
]

[[package]]
name = "jsonrpc-client-transports"
version = "14.2.1"
Expand Down Expand Up @@ -2854,9 +2886,9 @@ dependencies = [

[[package]]
name = "regex"
version = "1.3.9"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
dependencies = [
"aho-corasick",
"memchr",
Expand All @@ -2876,9 +2908,9 @@ dependencies = [

[[package]]
name = "regex-syntax"
version = "0.6.18"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"

[[package]]
name = "remote-test-client"
Expand Down Expand Up @@ -4578,6 +4610,7 @@ version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95"
dependencies = [
"indexmap",
"itoa",
"ryu",
"serde",
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ members = [
"src/tools/rustdoc-themes",
"src/tools/unicode-table-generator",
"src/tools/expand-yaml-anchors",
"src/tools/jsondocck",
]

exclude = [
Expand Down
7 changes: 7 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,13 @@ note: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
}

if mode == "rustdoc-json" {
// Use the beta compiler for jsondocck
let json_compiler = compiler.with_stage(0);
cmd.arg("--jsondocck-path")
.arg(builder.ensure(tool::JsonDocCk { compiler: json_compiler, target }));
}

if mode == "run-make" && suite.ends_with("fulldeps") {
cmd.arg("--rust-demangler-path").arg(builder.tool_exe(Tool::RustDemangler));
}
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ bootstrap_tool!(
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
LintDocs, "src/tools/lint-docs", "lint-docs";
JsonDocCk, "src/tools/jsondocck", "jsondocck";
);

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# `index` or `paths`. It DOES NOT check that the structure of the produced json is actually in
# any way correct, for example an empty map would pass.

# FIXME: Better error output

import sys
import json

Expand Down
132 changes: 0 additions & 132 deletions src/test/rustdoc-json/compare.py

This file was deleted.

Loading

0 comments on commit e05409a

Please sign in to comment.