-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jsondocck improvements #82311
Jsondocck improvements #82311
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
r? @jyn514 |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you post an example of what the error looks like if a @set
command is written incorrectly or an @is
command is false?
// @count - "$.index[*][?(@.name=='l3')].inner.items[*]" 1 | ||
// @set l3_id = - "$.index[*][?(@.name=='l3')].id" | ||
// @has - "$.index[*][?(@.name=='l1')].inner.items[*]" $l3_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$
already has a meaning in JSONPath, it means the root. I guess that shouldn't overlap here because you're testing a JSON value, it's not part of the path syntax? What happens if you want to match a string with $
in it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$foo
-> Variable foo
,
"$foo"
-> String $foo
Because json can only start with "
, {
, or [
, it is unambiguous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this should be documented
Co-authored-by: Joshua Nelson <[email protected]>
test // @set var = failing.json "foo.bar.baz"
// @is failing.json root "not_root" the relavent output
It's the same as anything, as currently the only way we report errors is returning (This is not tecnicly true) as some errors are panics, eg variable reassignment, lookup of variable not in hashmap |
@rustbot modify labels: -S-waiting-on-author +S-waiting-on-review |
@rustbot modify labels: -S-waiting-on-author +S-waiting-on-review |
@bors r+ Thanks! |
📌 Commit 4c949a4 has been approved by |
I know this was already approved, but +1 from me. I appreciate the ability to check both 'any match' and 'exactly 1 matches' easily |
…s, r=jyn514 Jsondocck improvements Adds 2 new commands, ``@is`` and ``@set`.` ``@is`` works like ``@has`,` except instead of checking if any value matches, it checks that there is exactly one value, and it matches. This allows more precise testing. ``@set`` gets a value, and saves it to be used later. This makes it possible to check that an item appears in the correct module. Once this lands, the rest of the test suite can be upgraded to use these. cc `@CraftSpider` `@rustbot` modify labels: +T-rustdoc +A-rustdoc-json +A-testsuite
Rollup of 10 pull requests Successful merges: - rust-lang#81629 (Point out implicit deref coercions in borrow) - rust-lang#82113 (Improve non_fmt_panic lint.) - rust-lang#82258 (Implement -Z hir-stats for nested foreign items) - rust-lang#82296 (Support `pub` on `macro_rules`) - rust-lang#82297 (Consider auto derefs before warning about write only fields) - rust-lang#82305 (Remove many RefCells from DocContext) - rust-lang#82308 (Lower condition of `if` expression before it's "then" block) - rust-lang#82311 (Jsondocck improvements) - rust-lang#82362 (Fix mir-cfg dumps) - rust-lang#82391 (disable atomic_max/min tests in Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Adds 2 new commands,
@is
and@set
.@is
works like@has
, except instead of checking if any value matches, it checks that there is exactly one value, and it matches. This allows more precise testing.@set
gets a value, and saves it to be used later. This makes it possible to check that an item appears in the correct module.Once this lands, the rest of the test suite can be upgraded to use these.
cc @CraftSpider
@rustbot modify labels: +T-rustdoc +A-rustdoc-json +A-testsuite