-
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. |
@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 created #1932. I can't add you the list of official code reviewers (due to permissions, I think), but you should be able to add comments in the body of the pull request or on a per-line basis in the "Files Changed" tab. |
I was thinking about putting the
@birdya22 : Do you think that makes sense? If so, should I use the file from that latest ZIP-file as a starting point? |
Yes I think it makes sense.
I would like to tidy it up first:
What do you think about the format? An XML file was easy to produce but not easy to view which is why I produced a xsl stylesheet to turn it into a set of tables. What would work best on here? |
Good questions. I'd like something that is easy for contributors to modify, is easy for anyone to read, and leads to understandable diffs. I think your existing XML/XSLT/HTML approach is a good choice. A disadvantage, though, is having to generate the HTML file each time the XML changes. While GitHub can automate that, I'm not sure (without further GitHub research) if such automation can be done in a way that makes the HTML persist indefinitely instead of having an expiration date. For things like log files, expiration dates make sense. We can make the browser apply XSLT dynamically to avoid having to keep a generated HTML file in sync with the XML source. However, I believe that that works only in some circumstances. In the simple dynamic-XSLT experiments I tried, an HTML previewer like html-preview.github.io (example: rendered HTML vs. raw markup if you don't use the previewer) didn't work, and viewing the experimental pages locally required a local web server rather than the I suppose HTML could be a source format -- with one table, not the different ways of presenting the same data. The html-preview.github.io renderer should work for viewing, without anyone having to convert XML to HTML. Markdown renders nicely in GitHub and Oxygen, but I'm concerned that it will be a pain to work with a Markdown table that has lengthy content in some of the cells. Even if we use a WYSIWYG Markdown editor to facilitate modifying the Markdown file, diffs will be ugly. Unless you prefer HTML or Markdown as a source format, my suggestion is to stick to the path you're already on. If you want to take some time to think it over or try experiments, no problem. |
I've had a play with Markdown and restructured the output so each element is in it's own details/summary section with a small table (there aren't any headings in the table and it produces a couple of blank cells). I still need to do more checking on the content but what do you think of the format? |
I like the format. I think it mitigates my concerns about tables with lengthy cell contents. A few suggestions, especially while it is easy to regenerate from your XML data:
|
Done.
I installed
No.
Yes. I haven't made any changes to the actual content yet. |
Great idea, thanks. I've just installed that extension as well. I don't have further comments about the Markdown formatting. When you work further on the actual content, maybe the main heading should be more specific, including something about code coverage. XSLT Element Code Coverage? Code Coverage for XSLT Elements? |
I had a thought about the content of the Markdown document: Wherever you know that a rule in the document is a proposed behavior rather than the current behavior, can you indicate that, such as by writing "(Proposed)"? It'll help us see where discussions or code changes are still to come. For example, I believe the rule you wrote for |
I'll have a think about that because the outcome may be the same but it may be that the code changes e.g. for the "Always Ignore" rule the result will still be "ignored" but there might be a code change to introduce a new template that matches all the elements to be ignored. On a separate point I noticed in a Saxonica issue unrelated to XSPec Michael Kay wrote "We're working on final testing of a 12.5 maintenance release at the moment." |
In terms of discussions I've put "Element Specific - TBD" as a rule where I haven't proposed anything. |
I've done as much as I am going to on the XSLT Element Code Coverage file for now.
The potential XSLT 4.0 elements and the Saxon Extension Instructions (XSLT Only) raise the question as to the scope that XSpec covers with respect to Saxon. And whether it is, or needs to be, defined/documented somewhere. I discovered an issue related to |
Yes.
If you have time to spend on recording your thoughts, whatever approach you prefer will be helpful. Thank you for suggesting this.
Sure. I haven't looked at your last .md file yet, but I think I can do so by Thursday. |
I didn't include a blank line between the lines in the Comments so here's a better one. I've looked at the |
Here's my list of changes I expect to see in the Coverage Reports based on the rules in the xsltelementDetails.md file (some Report changes are TBD as the Rule is TBD). The |
Thank you for the list of changes!
Do you mean how will it be handled in GitHub? Yesterday, you wrote, "I've looked at the xsl:param test and added more tests". Whenever you're ready to share your updates, I can set up a pull request with them. If you think a new GitHub issue would be a better vehicle for sharing updated files than adding to this issue, feel free to make a new one. About changing the treatment of |
Document written by user birdya22 (Adrian Bird). From xsltElementDetails.md file in comment xspec#1921 (comment) and formatted with `prettier`
Document written by user birdya22 (Adrian Bird). From xsltElementDetails.md file in comment xspec#1921 (comment) and formatted with `prettier`
Document written by user birdya22 (Adrian Bird). From xsltElementDetails.md file in comment xspec#1921 (comment) and formatted with `prettier`
Your xsltElementDetails.md file became the basis for #1934. |
I do think there is benefit in putting the Saxon version in the document. Code coverage reporting has such a tight connection with Saxon behaviors, and some of those behaviors have changed significantly across releases. I added the version number as a section of the document (not just a simple one-liner) in case we have more to say in the future, such as subtle differences among 12.4, 12.5, and 13.x. |
I decided a new issue 1935 would be easier because of what I wanted to write about it. As I can't attach .xsl or .xspec file to an issue, is it better to add .txt to the end (which is what I did in this case) or put them in a zip file, or do something else? |
Fantastic, thanks. Your .txt workaround is fine. If there were lots of files instead of only a couple, we'd probably find a ZIP-file easier. |
* Per-element doc for code coverage behavior Document written by user birdya22 (Adrian Bird). From xsltElementDetails.md file in comment #1921 (comment) and formatted with `prettier` * Editorial-type changes - Rule descriptions state the rule first and then describe motivation - Tried to clarify xsl:template xsl:param description - Various wordsmithing changes * Add mention of Saxon version * Clarify xsl:stylesheet and xsl:transform comment * Include link to Saxonica issue (template param) Plus a few attempted clarifications also in the xsl:param section * Use term "coverage status" instead of category
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: