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

fix(xslt): include class in XSLT code coverage data #1918

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

galtm
Copy link
Collaborator

@galtm galtm commented Apr 26, 2024

traceableUQName sometimes doesn't reflect the node that coverage-report.xsl expects to see, which can lead to nodes being marked in the XSLT coverage report as missed when they were, in fact, hit. This change causes the coverage data to include both traceableUQName and traceableClassName if not null, and causes the XSLT to be less strict about when it considers a hit to be relevant to the node it's looking at.

This pull request is not complete, as I plan to add tests and add some notes about my local qualification. It's also possible that the XSLT has some unneeded code that can be removed.

Fixes #1917.

traceableUQName is sometimes an ancestor of the
node that coverage-report.xsl expects to see (xspec#1917),
whereas traceableClassName works more reliably.
Therefore, include the class in the coverage data even
if uqname is available.
@galtm galtm added this to the v3.1 milestone Apr 26, 2024
@galtm
Copy link
Collaborator Author

galtm commented Apr 26, 2024

@cmarchand , by any chance do you know why macOS fails on Java 8?

https://github.com/xspec/xspec/actions/runs/8841495386/job/24278687107?pr=1918

Installed distributions
  Trying to resolve the latest version from remote
  Error: Could not find satisfied version for SemVer '8'. 
  Available versions: 22.0.1+8, 22.0.0+36, 21.0.3+9.0.LTS, 21.0.2+13.0.LTS, 21.0.1+12.0.LTS, 21.0.0+35.0.LTS, 20.0.2+9, 20.0.1+9, 20.0.0+36, 19.0.2+7, 19.0.1+10, 19.0.0+36, 18.0.2+101, 18.0.2+9, 18.0.1+10, 18.0.0+36, 17.0.11+9, 17.0.10+7, 17.0.9+9, 17.0.8+101, 17.0.8+7, 17.0.7+7, 17.0.6+10, 17.0.5+8, 17.0.4+101, 17.0.4+8, 17.0.3+7, 17.0.2+8, 17.0.1+12, 17.0.0+35, 11.0.23+9, 11.0.22+7.1, 11.0.22+7, 11.0.21+9, 11.0.20+101, 11.0.20+8, 11.0.19+7, 11.0.18+10, 11.0.17+8, 11.0.16+101, 11.0.16+8, 11.0.15+10

The same thing just started happening in my own fork earlier this week, when I was merely bringing it up to date with this repo.

@cmarchand
Copy link
Collaborator

I've no idea on Why ! It seems that support for Java 8 has been dropped.
Where is the script source for this build ?

@galtm
Copy link
Collaborator Author

galtm commented Apr 26, 2024

I've no idea on Why ! It seems that support for Java 8 has been dropped.
Where is the script source for this build ?

While you were entering your comment, I was creating a separate issue: #1919 . Let's continue this discussion there.

@galtm
Copy link
Collaborator Author

galtm commented Jun 4, 2024

Here are some notes about local qualification of this change.

Tests in test/end-to-end/cases-coverage/

Today, I diff'd the generated HTML reports from test/end-to-end/cases-coverage/expected/stylesheet between (a) the branch containing the tests written by @birdya22 from #1921 (comment) with some local modifications and additions, and (b) a branch with all the same test files but also the Java changes from this branch. 37 HTML reports had differences. In all cases, the changes in this PR improved the HTML reports, such as the content of a hit <xsl:text> element also being marked as hit.

Top level of test/

Around the time I first created this PR, I didn't have a lot of coverage tests to run, so I generated coverage reports with and without this PR's Java changes, for files at the top level of the test/ directory and diff'd the HTML reports. (BTW, this repo doesn't have a nifty way to automate that.)

Bottom line: The changes in this PR helped in some cases. I found no cases where the changes did any harm, such as marking something as "hit" that was really "missed."

Details on two tricky cases (https://github.com/xspec/xspec/blob/master/test/issue-1564.xspec and https://github.com/xspec/xspec/blob/master/test/global-override.xspec): This PR's changes caused a total of three global XSLT parameters to be reported as "hit" instead of "ignored". In all three cases, the global XSLT parameter was not overridden (i.e., did not have a value provided) from XSpec, so Saxon had to evaluate the default value provided in the <xsl:param> element. Presumably, that's why Saxon traced those <xsl:param> elements. With the change in this PR, the tracing made the elements get marked as "hit". Without the change, the tracing didn't make the elements get marked as "hit" because the trace element had uqname="Q{http://www.w3.org/1999/XSL/Transform}variable" which doesn't match xsl:param. Other logic in coverage-report.xsl unrelated to this PR caused the apparently-untraced <xsl:param> to be marked as ignored rather than missed.

galtm added 2 commits June 4, 2024 11:44
XML coverage data now includes class names.

Generated using Saxon 12.4.
@galtm
Copy link
Collaborator Author

galtm commented Jun 4, 2024

fee5255 adds end-to-end tests similar to #1917.

@galtm galtm marked this pull request as ready for review June 4, 2024 17:29
Comment on lines 431 to 440
<xsl:for-each select="$hits">
<xsl:variable name="hit-traceable-uqname" as="xs:string?"
select="exactly-one(key('traceables', @traceableId, $trace))/@uqname" />
<xsl:variable name="hit-traceable-class" as="xs:string?"
select="exactly-one(key('traceables', @traceableId, $trace))/@class" />
<xsl:if test="($node-uqname eq $hit-traceable-uqname) or
empty($hit-traceable-uqname)">
exists($hit-traceable-class)">
<xsl:sequence select="." />
</xsl:if>
</xsl:for-each>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am pretty sure this block of code can be simpler, maybe even removing the conditional logic. But it might be useful to do such refactoring in a follow-up pull request to make it easier to see whether any of the expected HTML coverage reports in test/end-to-end/cases-coverage/ actually change as a result of simplifying the XSLT.

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.

Issue with code Coverage Report in 3.0.3
2 participants