Content-Length: 426221 | pFad | http://github.com/symfony/symfony/pull/60695

8A [JsonPath] Test against official compliance test suite by mttsch · Pull Request #60695 · symfony/symfony · GitHub
Skip to content

[JsonPath] Test against official compliance test suite #60695

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

Open
wants to merge 3 commits into
base: 7.3
Choose a base branch
from

Conversation

mttsch
Copy link
Contributor

@mttsch mttsch commented Jun 4, 2025

Close #60669

Q A
Branch? 7.3
Bug fix? no
New feature? no
Deprecations? no
Issues Fix #60669
License MIT

@mttsch
Copy link
Contributor Author

mttsch commented Jun 4, 2025

This is my first "proper" contribution to Symfony.

  1. While https://github.com/jsonpath-standard/jsonpath-compliance-test-suite/tree/main recommends embedding that repository as a submodule, I was unsure whether that approach works for the Symfony repository, thus copied the file as a Fixture.
  2. Many errors are reported due to invalid filter expressions.
  3. I did not find a proper way to validate the selector with current APIs but only to use find() because the filter expression validation happens inside of private methods called via find(). (Tokenizing is not enough.)

Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should record the info about which commit/release of the CTS we vendor, with a script we can run to fetch the latest version, updating both cts.json and the version.

Otherwise, it will be hard to manage updates when the compliance testsuite adds new tests to increase coverage (which might happen)

@mttsch
Copy link
Contributor Author

mttsch commented Jun 4, 2025

@stof As this is only one JSON file that can be also be downloaded manually without any issue, I assumed that providing the exact hash based link, see https://github.com/symfony/symfony/pull/60695/files#diff-8312c65e1b644a04bd87f0dee0894ab6712b296af12a1e191d1faaf5a1f52784R37, was sufficient.

PS: Are you talking about a similar approach to the one the Intl component uses?
PPS: Though there, the data fetching appears more complex than just downloading a file.

$this->expectException(JsonCrawlerException::class);
}

$result = (new JsonCrawler(json_encode($document)))->find($selector);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest separating the JsonCrawler instantiation from the find call, so that invalid selectors don't allow us to expect an exception in the instantiation part. This would be done by making the call $this->expectException(JsonCrawlerException::class); after instantiation but before running the selector.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@stof
Copy link
Member

stof commented Jun 4, 2025

I think we might need a constant in the test containing a list of test names we don't support yet, for which the test would get skipped in CI (maybe with an env variable to force running them when working on them locally).
This would allow us to merge that PR, preventing regressions on tests that we already pass and moving little by little into running it all (removing tests from the skip-list when we fix the issues we have) instead of being able to merge this PR only once we are 100% compliant.

@mttsch mttsch force-pushed the feature/60669-JsonPath-compliance-test-suite branch from e962cd0 to e088cc3 Compare June 4, 2025 15:59
@stof
Copy link
Member

stof commented Jun 4, 2025

I assumed that providing the exact hash based link, see https://github.com/symfony/symfony/pull/60695/files#diff-8312c65e1b644a04bd87f0dee0894ab6712b296af12a1e191d1faaf5a1f52784R37, was sufficient.

this comment in a separate location is almost guaranteed to become outdated by being forgotten when updating the JSON file.

PS: Are you talking about a similar approach to the one the Intl component uses?
PPS: Though there, the data fetching appears more complex than just downloading a file.

the fetching is indeed a lot simpler, as we just save the file as is without any processing.

See for instance https://github.com/symfony/symfony/tree/7.4/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Script/Mermaid where we have a Makefile fetching a specific reference of Mermaid (it is not a simple download of the file there, as we do a custom build). Updating to a new version involves updating the version number in the Makefile and then running make again, which guarantees that the update of the version number is not forgotten.

@mttsch
Copy link
Contributor Author

mttsch commented Jun 4, 2025

@stof I added a makefile and added a const to exclude unsupported files.

(maybe with an env variable to force running them when working on them locally)

Not sure about this part (also not done) because it can basically also be done by temporarily commenting out/removing the array contents similar to

removing tests from the skip-list when we fix the issues we have

@alexandre-daubois
Copy link
Member

It makes me think of something: if a feature is lacking to make the suite pass, should this be considered a bugfix and target 7.3 or should we target 7.4?

@stof
Copy link
Member

stof commented Jun 5, 2025

As we are currently merging them as bugfix in 7.3 (as the component is announced as implementing the RFC, not as implementing its own syntax inspired by JsonPath), I suggest merging this PR in 7.3, so that we can clean the skip-list alongside doing the fixes.

@mttsch mttsch force-pushed the feature/60669-JsonPath-compliance-test-suite branch from 9b1db26 to 7c55e76 Compare June 5, 2025 18:56
@mttsch mttsch changed the base branch from 7.4 to 7.3 June 5, 2025 18:56
@mttsch
Copy link
Contributor Author

mttsch commented Jun 5, 2025

@stof PR now targets 7.3.

Copy link
Member

@alexandre-daubois alexandre-daubois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of improvements for the components during the last days and this PR will be really helpful to iterate on the crawler. Thank you @mttsch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[JsonPath] The JsonPath component should run the official conformance testsuite
5 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/symfony/symfony/pull/60695

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy