Skip to content

Commit

Permalink
Improve some jsondocck errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aDotInTheVoid committed Mar 10, 2021
1 parent 9925ecb commit 5f24798
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/tools/jsondocck/src/main.rs
Expand Up @@ -205,7 +205,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();
let pat = string_to_value(&command.args[2], cache);
results.contains(&pat.as_ref())
let has = results.contains(&pat.as_ref());
// Give better error for when @has check fails
if !command.negated && !has {
return Err(CkError::FailedCheck(
format!(
"{} matched to {:?} but didn't have {:?}",
&command.args[1],
results,
pat.as_ref()
),
command,
));
} else {
has
}
}
_ => unreachable!(),
}
Expand Down Expand Up @@ -233,7 +247,13 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> {
assert_eq!(command.args[1], "=", "Expected an `=`");
let val = cache.get_value(&command.args[2])?;
let results = select(&val, &command.args[3]).unwrap();
assert_eq!(results.len(), 1);
assert_eq!(
results.len(),
1,
"Didn't get 1 result for `{}`: got {:?}",
command.args[3],
results
);
match results.len() {
0 => false,
1 => {
Expand Down

0 comments on commit 5f24798

Please sign in to comment.