-
Notifications
You must be signed in to change notification settings - Fork 31
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
Issue with Global Variables in coverage report in 3_0_3. #1921
Comments
Adrian, thanks for the examples. When working on #1918, I looked out for whether the changes fixed your specific problem but I also wanted to know: Do the changes introduce side effects, especially code being marked as hit, when it's really missed? I generated coverage reports for files in this repo's test suite and noticed that my code changes affected the hit/missed/ignored status of some global XSLT parameters (specifically https://github.com/xspec/xspec/blob/master/test/issue-1564.xspec and https://github.com/xspec/xspec/blob/master/test/global-override.xspec if you or anyone else reading this is interested). Looking into what the correct behavior should be is on my to-do list. Your examples will probably also be useful for determining whether #1918 is a correct fix or whether it needs adjustments. |
Amanda, Here are my thoughts. This is all from the point of only using Saxon-PE so there are a lot of features that I have never used, and cannot use. I think the starting point should be a hit for everything that Saxon says is a hit, otherwise things get very tricky if you decide to disagree with Saxon and ignore some hits. So that leaves you with working out what to mark as a hit when it's not in the trace output, and when it's not a hit is it a miss or ignored. From looking outside at this I would have a couple of questions (which I can partially answer from the coverage-report.xsl but I can't tell the rationale behind the rules in some cases):
From a bit more testing I have the following comments on my points 1 and 2 above (starting with some obvious ones):
This may also be the reason why global variables have problems for me. I removed the 2 variable tests because I still think they shouldn't be needed as most xsl:variable elements are hit if used (but see below): The comment for this rule I still see a problem for a global xsl:variable which has a select attribute with a string value because they are not hit in the trace when used. So I would say it should be marked as missed, but this is wrong and I don't know how you can get around this without getting Saxonica to change and include it in the trace. Finally, my suggestion would be a review of the rules in xsl:choose in the element(0 | text() template to see if they are still doing that they are intended to do, whether they do more than was intended and whether any more are needed. I do realise the potential ramifications of this suggestion. Note: what I found useful in the testing I did was something like a version of the coverage-report that only reports the hits from the coverage.xml file (this made it easy to see what was and wasn't being traced which is how I got some of the suggestions above). I had to knock something up to do this but I assume you have something similar. Adrian |
I've had a look at the tests in both the links and the reason for the change is the same in both. With your change I think this raises a question about whether it is worth doing the comparison with the uqname at all because if it fails you will still record a hit if there is a class name, which seems to make the uqname check redundant. This is your change inside local:hits-on-node In 3_0_3 the param lines were shown as ignored which seems a bit strange to me as I would have expected to see them as missed if they weren't hit, particularly as the test xspec expects the param to provide the result value. Related to my previous comments, does this need re-visiting to think about which global elements should be ignored or missed if they are not hit (this will of course come down to what Saxon records hits on). The XSLT 3.0 spec lists the following declaration elements permitted in the xsl:stylesheet: From your comment, "I generated coverage reports for files in this repo's test suite and noticed ..." does this mean that you have automated checking of coverage reports against your current baseline? Here are the details for issue-1564 as it is the simpler of the 2. With your changes you've added the @Class into the coverage.xml and that is used to make it a hit via the class and not the uqname. coverage.xml is now Adrian |
Adrian, thanks a lot for your analysis and observations. I am hoping to have a block of uninterrupted time sometime in the next few days, to look into this and write back more substantively. Thanks for your patience! |
Amanda, Saxon, and therefore xspec, only includes one of "if" or "choose" in the trace output even if both xsl:if and xsl:choose are present in the stylesheet. With your current changes everything is good. I'm not in any hurry for a response as I'm getting on ok at the moment using your changes and I've also set the tree model to linked in the Saxon config file. |
Thanks. I'm looking at this now, in fact. By the way, I edited your description at the top of this issue, to replace "1" with "2" in two spots ("CoverageGlobalVariableIssue02.xspec invokes TestTemplate02." instead of "CoverageGlobalVariableIssue01.xspec invokes TestTemplate02.", and similar in the last sentence.) I would not normally edit another person's comments, but I think these were merely copy/paste errors that are clearer to fix in place, for the sake of anyone else reading this issue. |
I agree.
You are asking good questions. XSpec doesn't have a formal specification, and I am not aware of artifacts that would answer your questions. I suspect that some of the XSLT logic was tailored for an older Saxon version that reported hits differently from Saxon 12.
I think you are right to question those clauses. Perhaps if a past Saxon version never reported variable declarations as hit, it made sense for the coverage XSLT to look at a following sibling of a local variable. Looking at a following sibling of a global variable doesn't seem like the right logic.
Interesting observation, and it makes the task a little trickier.
I agree, the comment doesn't match the logic, because that clause also matches top-level elements (including top-level XSLT elements) that don't match an earlier
Agreed.
That's a good idea, and I can make something similar while investigating this.
Yes, I also wondered whether we should merely pass along any hit with matching line/column data, regardless of the uqname or class name. That's not a change I want to do hastily, though. :)
Not exactly. The automated testing for coverage reporting in this repo is not as strong as the automated testing for the main XSpec functionality. I made an ad hoc script that generates lots of coverage reports, ran the script in workspaces with and without my code changes, and used a diff tool. Not nearly as automated as I would like. Re #1921 (comment), I haven't looked at your CoverageIfChooseIssue.zip file yet. General comment: What I'd like to do is treat these coverage reporting bugs as part of a larger task that involves enhancing automated testing of code coverage reporting in this repo, determining what's correct and what's incorrect, documenting the assumptions that this repo's code makes about what Saxon is reporting, and documenting the logic for when a node that Saxon doesn't report as "hit" should be marked as "missed" or "ignored." I am happy to hear that you have workarounds at the moment, because I think being able to "refactor without fear" in this corner of the repo is going to require a fair amount of time to gradually build up foundations. |
I've come across another issue which I'll raise with Saxonica direct and let you know what the number is. Separately I have put together a stylesheet that includes a large majority of the xslt elements in some simple examples. I need to do more work on it but will share it with you later. Adrian |
My new Saxonica issue is https://saxonica.plan.io/issues/6419. |
Thanks for reporting the new issue, and I see that Michael has already marked it as Resolved.
Fantastic! It sounds like your work can lead to some test cases in this repo. Recent pull request #1923 sets up a structure for code coverage reporting test cases. I invite you to make pull requests with test cases, if/when you are ready (probably after #1923 is merged in). If you want to share your files but have someone else shepherd them through GitHub, that is fine, too. |
GitHub is a mystery to me (I only got an account so I could raise an issue). Adrian |
I meant to mention about the template variables that are sometimes hit and sometimes missed even though they are all executed. I had a thought about optimisation and tried disabling all optimisations except j (-opt:j). This changed most variables from miss to hit. I also tried it with removing "inline variables" optimisation (-opt:-v)- this was nearly as good. |
Quick look so far -- this looks very, very useful for advancing the testing of the code coverage reporting feature. I will spend more time digesting it, hopefully this week. (I'll be away from computers much of next week.) Is |
Sorry yes - rename the text file. I have noticed some issues with some individual tests and although I tried to make them all independent there is some interaction between them, and also having them all in one 1000 line stylesheet means it is easy to get confused. So I think it needs to be split up into small tests for each element to make them easier to understand/check/amend, although there could still be an overarching stylesheet/xspec that includes them all. If you think this is a good idea I am ok with doing it and would suggest something like the following for a naming convention, unless you already have one: |
Got it. Thanks! Small tests sound like a good idea for the reasons you mentioned. The naming convention you proposed sounds good, though I think you can omit the |
I merged #1923 onto the
|
I've started having a look at the links above. Hopefully a quick question: in my xsl:character-map test the *-result.html output has 3 backward question marks each in a box rather than 100 (Saxon output produces 100). I assume I'm missing a bit of configuration in xspec - do you know what I need to do? |
I'm not sure yet. Where in the report do those characters appear? Are they literally in the raw HTML (it's not the |
I've attached my test case. It uses a character-map hierarchy and maps E000 to 0 and E001 to 1 to produce 100 in the output. |
I don't think this is a configuration question after all. If you run the XSLT transformation outside XSpec, Saxon applies the character map using Using the <x:expect label="Success"
test=".
=> serialize(
map {
'method': 'xml',
'use-character-maps': map{'': '0', '': '1'}
}
)
=> parse-xml()"
select="/">
<root>
<node type="character-map">100</node>
</root>
</x:expect> It isn't pretty, although the details could potentially be hidden away in a helper stylesheet. The technique I used is similar to the one in #227 (comment) . |
From a code coverage perspective, the machinations to make XSpec serialize and reparse the result are not helpful, because they don't tell you whether running the transformation outside XSpec will "hit" or use the character map. Would making the XSLT use a character map in a |
It looks like you've already noted that Saxon does not trace character maps, even when it uses them. But if you need a way in XSpec to exercise a character map without extra XSpec code afterward, you could modify your |
I'm going for the very simple option, unless you would prefer me to do something else. My very simple option is: Also, I've raised another issue with Saxonica 6428 called "Output of xsl:on-non-empty changes when using TraceListener". |
Simplicity is good, and so is reporting an issue you found along the way. Maybe Saxon 13 will be a great release for tracing. |
Adrian, I looked at your ZIP-file a little more, and it is really a wealth of information. I have some questions:
|
As you're not around next week I'll have a think about your questions and reply later. |
Starting with replies to your questions.
Yes although from the comments from Michael Kay I'm not sure Saxonica will do anything about it until version 13 when it all might change.
I would say yes because it is an instruction.
There is a change in my understanding of xsl:assert and xsl:try (see the XML file) as the TryCatch class trace appears on the line after the xsl:try and depends on what the first element is in xsl:try.
Yes.
Basically yes. From my tests I think "unknown" will be for elements that use a select attribute and are not traced. If the elements has a sequence constructor it is possible to use the state of the children to determine the state of the parent. I added some more tests in for this and the results are in the updates to the XSLT file. Here are my thoughts on Optimization and Tree Models. OptimizationHaving played with a bit of Java I've discovered that HE only supports the following optimization values: lmtv. Optimization would need to be configured in the "Running Tests" part where users could change it by setting a value in the SAXON_CUSTOM_OPTIONS environment variable (this would override a setting in a new saxon config file that could be used although you could set it as a command line option after the SAXON_CUSTOM_OPTIONS). Tree ModelBased on #1920 and https://saxonica.plan.io/issues/6405 with the fact that using the LinkedTree when generating the Coverage Report gives better column number values my suggestion is that the coverage-report-config.xml file has the treeModel="LinkedTree" set in it (I can provide details of the difference it makes to my test set if you want). Are you thinking about a new release of XSpec before a new release of Saxon or waiting until after the next release? |
It would help if I attached something. |
Thanks a lot for your comments and all the files and information in
XSpec doesn't have a history of very frequent releases, and the tentative date for the next release is in the fall. Saxonica has been fixing things that affect code coverage reporting in XSpec, yet I haven't seen all the fixes and don't know if XSpec needs further adaptations (e.g., in the custom listener or the report XSLT) to benefit from the Saxon fixes. My inclination is to have the next XSpec release wait at least until Saxon 12.5 but not necessarily wait for Saxon 13. |
I've reviewed about half of your per-element coverage tests so far. I think they will fit nicely in the Although I'm not done reviewing your tests as they run against the I have suggestions for resolving the open items you flagged in You mentioned GitHub being a mystery, so if it is OK with you, I'll create a pull request with your files plus my modifications. We can use the pull request page to continue the discussion if we have line-specific comments to discuss. To attribute your work to you, should I include your name and GitHub user name in the descriptions of commits that contain your code and in the pull request description? Let me know what you're comfortable with as far as visibility and privacy go. If you decide you want to make the commits and pull request yourself, let me know! |
@birdya22 : I've reviewed all your per-element coverage tests and assessed the effects of #1918 on the results. I'll wait to hear from you about attribution before setting up a pull request with the per-element coverage tests. (I could upload a ZIP-file so you could see the files, but then you wouldn't have the Git commits' comments and groupings.) In the meantime, there are parts of this conversation I still need to digest that would feed into subsequent pull requests. |
Yes.
I'm ok with that. |
I should say at the beginning that I've done my testing with the changes from #1917.
The stylesheet has the following content:
There are 7 global variables at the start with a variety of contents: xsl:text, xsl:for-each, xsl:choose, xsl:analyze-string. None of them are referenced within the rest of the stylesheet.
There are then 2 named templates:
TestTemplate01 outputs 100 in a root node.
TestTemplate02 outputs 200 in a root node.
CoverageGlobalVariableIssue01.xspec invokes TestTemplate01.
CoverageGlobalVariableIssue02.xspec invokes TestTemplate02.
CoverageGlobalVariableIssue01.xspec coverage report shows some parts of the global variables being hit and some missed, rather than all ignored.
CoverageGlobalVariableIssue02.xspec coverage report looks fine.
Adrian
GlobalVariableCoverageTest.zip
The text was updated successfully, but these errors were encountered: