Skip to content
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

[test] refactor serialization suite #4777

Merged
merged 4 commits into from
Jul 17, 2023

Conversation

line-o
Copy link
Member

@line-o line-o commented Mar 1, 2023

Description:

Refactor serialization tests for maintainability and readability.

  • combine item-separator with method tests into one
    ser:item-separator-with-method
  • simplify test cases that used eq in combination with assertXPath
  • make direct calls to function under test (serialize) in each test
  • extract fixtures to module variables
  • remove namespace from children of output:serialization-parameters
  • convert QNames keys to strings for exist-db specific options
  • convert string constructors to CDATA sections
  • make HTML5 test data real world examples
  • use unprefixed form of built-ins
  • fix formatting

Reference:

has to wait for

Type of tests:

XQSuite

@line-o
Copy link
Member Author

line-o commented Mar 1, 2023

If this PR gets merged first, then #4773 can be closed.

@line-o line-o requested review from a team, reinhapa and joewiz March 1, 2023 09:42
@line-o line-o force-pushed the test/refactor-serialization branch from c7aff62 to 1004a29 Compare March 6, 2023 23:06
@line-o line-o requested a review from a team March 6, 2023 23:19
@line-o
Copy link
Member Author

line-o commented Mar 7, 2023

This PR was rebased on current develop HEAD and does not include #4773 anymore

@line-o line-o requested a review from joewiz March 13, 2023 20:32
@line-o
Copy link
Member Author

line-o commented Mar 13, 2023

we have a problem with the docker images it seems (although this is completely unrelated to my changes):

DOCKER> Unable to build image [existdb/existdb:7.0.0-SNAPSHOT] :
"failed to export image: 
  failed to create image:
  failed to get layer sha256:89dbfd2aac2fd2efd0e12805e343c3a1139557ea1930ad204bdb7387b89fe3c4:
  layer does not exist"

@duncdrum do you have an idea what this is about or what might be the reason? Is this just a temporary hiccup and I should try again in a moment?

@adamretter adamretter self-requested a review March 13, 2023 21:25
Copy link
Member

@adamretter adamretter left a comment

Choose a reason for hiding this comment

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

Please consider that the following change is not equivalent:

Before this PR we had:

map { xs:QName("exist:output-doctype"): fn:false() }

But now you have:

map { "exist:output-doctype": false() })

Whilst the end result may be the same, we added the functionality and designed the tests to specifically test for the QName, this should not be removed please.

@duncdrum
Copy link
Contributor

@line-o no clue could be a hickup. I would recommend a local build of the image, but that only works on intel so …

@joewiz
Copy link
Member

joewiz commented Mar 13, 2023

I see that not all such QName constructions were removed - e.g., https://github.com/eXist-db/exist/pull/4777/files#diff-41536ff061981a585744759c566780f801e29b78405dd79d158d466f3272905dR374. I agree that it would be best to restore the others to their original form with the xs:QName construction. Perhaps the versions without the xs:QName construction could be preserved too as variations to ensure that both forms continue to work (as they do today).

@line-o
Copy link
Member Author

line-o commented Mar 20, 2023

I would be in favour of adding one test that uses constructed QNames to ensure this form will continue to work.
I believe that using QNames as keys is the less common form to provide options to fn:serialize since all other options
do not use them but plain strings.

@sonarcloud
Copy link

sonarcloud bot commented Mar 20, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@adamretter
Copy link
Member

I believe that using QNames as keys is the less common form

Not for us. Please keep our QName tests, we worked hard to add this and ensure that it works for several groups of users. If you wish to add additional tests for strings as well, I have no objection, but please do not remove our tests!

@line-o line-o force-pushed the test/refactor-serialization branch from 65ad971 to b0ff9b3 Compare March 28, 2023 15:11
@line-o
Copy link
Member Author

line-o commented Mar 28, 2023

@adamretter all exist-specific serialization option keys are now tested as xs:string and xs:QName. Please re-review if that addresses your concerns.

@line-o line-o requested a review from adamretter March 28, 2023 17:32
@line-o
Copy link
Member Author

line-o commented Mar 28, 2023

@adamretter out of curiosity: is it possible to use QNames for the other keys in the map as well?

@line-o
Copy link
Member Author

line-o commented Mar 29, 2023

@dizzzz could you remove the build cache for this PR so that we can re-run the tests?

- combine item-separator with method tests into one
  `ser:item-separator-with-method`
- simplify test cases that used eq in combination with assertXPath
- make direct calls to function under test (serialize) in each test
- extract fixtures to module variables
- remove namespace from children of output:serialization-parameters
- convert QNames keys to strings for exist-db specific options
- convert string constructors to CDATA sections
- make HTML5 test data real world examples
- use unprefixed form of built-ins
- fix formatting
eXist-db specific extensions to serialization options can also be set using the
QName instead of plain strings.
Add one test per option using the non-default value.
The value for each serialization option is now paremeterized.
@line-o line-o force-pushed the test/refactor-serialization branch from b0ff9b3 to 6735560 Compare April 25, 2023 09:36
@sonarcloud
Copy link

sonarcloud bot commented Apr 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@line-o
Copy link
Member Author

line-o commented Jun 21, 2023

@adamretter Your concerns were addressed 2 months ago, would you please re-review this PR

@line-o
Copy link
Member Author

line-o commented Jul 17, 2023

I will bring this PR up on the community call today.

@reinhapa reinhapa merged commit fcf1a96 into eXist-db:develop Jul 17, 2023
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants