diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-11 21:48:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-11 21:48:47 +0100 |
| commit | ffa8d6b47d2b3f7e8931eae7d07f87e3585597b8 (patch) | |
| tree | caa031b9d6d47f40ee173dc7ae89ffea61e4b3e2 /src/tools | |
| parent | 15d71cff2d6286b0f281485637eace03dbe94916 (diff) | |
| parent | bf0e862903c4a799dd08dd00ffe68f9756fc6eb1 (diff) | |
| download | rust-ffa8d6b47d2b3f7e8931eae7d07f87e3585597b8.tar.gz rust-ffa8d6b47d2b3f7e8931eae7d07f87e3585597b8.zip | |
Rollup merge of #93660 - aDotInTheVoid:rustdoc-type-tests, r=CraftSpider
rustdoc-json: Add some tests for typealias item r? ```@CraftSpider``` Improves https://github.com/rust-lang/rust/issues/81359 The test's arn't pretty, and I think eventually we need a better way of doing repeated tests on a deeply nested path, without repeating the way to get to that path ```@rustbot``` modify labels: +A-rustdoc-json +T-rustdoc +A-rustdoc +A-testsuite
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/jsondocck/src/main.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/tools/jsondocck/src/main.rs b/src/tools/jsondocck/src/main.rs index b8ea10f3d22..d0f476955e1 100644 --- a/src/tools/jsondocck/src/main.rs +++ b/src/tools/jsondocck/src/main.rs @@ -231,7 +231,21 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> { let val = cache.get_value(&command.args[0])?; let results = select(&val, &command.args[1]).unwrap(); - results.len() == expected + let eq = results.len() == expected; + if !command.negated && !eq { + return Err(CkError::FailedCheck( + format!( + "`{}` matched to `{:?}` with length {}, but expected length {}", + &command.args[1], + results, + results.len(), + expected + ), + command, + )); + } else { + eq + } } CommandKind::Is => { // @has <path> <jsonpath> <value> = check *exactly one* item matched by path, and it equals value @@ -317,6 +331,6 @@ fn string_to_value<'a>(s: &str, cache: &'a Cache) -> Cow<'a, Value> { panic!("No variable: `{}`. Current state: `{:?}`", &s[1..], cache.variables) })) } else { - Cow::Owned(serde_json::from_str(s).unwrap()) + Cow::Owned(serde_json::from_str(s).expect(&format!("Cannot convert `{}` to json", s))) } } |
