-
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
Basic test for code coverage (Ant) #300
Conversation
…-tests # Conflicts: # build.xml # test/run-xspec-tests-ant.cmd # test/run-xspec-tests-ant.sh
…-tests # Conflicts: # test/end-to-end/generate-expected.cmd # test/end-to-end/generate-expected.sh # test/end-to-end/run-e2e-tests.cmd # test/end-to-end/run-e2e-tests.sh
…overage # Conflicts: # build.xml # test/end-to-end/generate-expected.cmd # test/end-to-end/generate-expected.sh # test/end-to-end/processor/html/_normalizer.xsl # test/end-to-end/run-e2e-tests.cmd # test/end-to-end/run-e2e-tests.sh # test/run-xspec-tests-ant.cmd # test/run-xspec-tests-ant.sh
…185_cumulative # Conflicts: # test/xspec-bat.cmd # test/xspec.bats
…-tests # Conflicts: # test/xspec-bat.cmd # test/xspec.bats
…overage # Conflicts: # test/xspec-bat.cmd # test/xspec.bats
…k/xspec into align-bats-tests # Conflicts: # test/xspec-bat.cmd # test/xspec.bats
…-tests # Conflicts: # test/xspec-bat.cmd # test/xspec.bats
…into test_ant-coverage # Conflicts: # test/xspec.bats
…overage # Conflicts: # test/run-bats.cmd # test/run-bats.sh # test/win-bats/collection.xml # test/xspec.bats
…overage # Conflicts: # .travis.yml # appveyor.yml # test/win-bats/collection.xml # test/xspec.bats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having issues testing this on my machine but I think it is due to my configuration rather than to this pull request. For some reason when I run run-bats.sh
with Saxon EE the Saxon license file (which is in the same directory as the Saxon EE jar file) is not picked up and test 40 gives me this output:
Creating Test Stylesheet...
No license file found - running with licensable features disabled
Running Tests...
No license file found - running with licensable features disabled
Testing with SAXON EE (unlicensed) 9.6.0.4
Test 47 is always skipped on my local machine and I think it is for a similar reason. However, if I run the test manually from the test directory with this command:
ant -buildfile "${PWD}/../build.xml" -Dxspec.xml="${PWD}/../tutorial/coverage/demo.xspec" -lib "${SAXON_JAR}" -Dxspec.coverage.enabled=true
the report is correctly created. I also checked that my license file for Saxon EE is valid and found by running these commands.
I wonder if you encountered a similar issue in the past or if you had to do any special set up for Saxon EE in order to pick up the license file correctly when using the shell and batch scripts. If possible, could you share your configuration for Saxon EE? It may help me setting up mine.
On another subject: the run-bats.sh
contains this command:
if java -jar "${SAXON_JAR}" -nogo -xsl:../src/reporter/coverage-report.xsl 2> /dev/null;
I looked for documentation in Java and Saxon for the option -nogo
but I couldn't find anything. What does this option do?
|
Test 40: thanks for the additional commit, I confirm it works fine with Saxon EE 9.6 and the test is executed and passes. Test 47: thanks for the explanation about the In order to test if Saxon EE 9.6 was actually capable of running test 47, I removed the if java -jar "${SAXON_JAR}" -nogo -xsl:../src/reporter/coverage-report.xsl 2> /dev/null; then
export XSLT_SUPPORTS_COVERAGE=1
fi so that To find a backward compatible solution I reinstated the saxon_version=$(java -jar "${SAXON_JAR}" -t 2>&1 | head -n 1)
if [[ "${saxon_version}" =~ ^Saxon-[E|P]E ]]; then
export XSLT_SUPPORTS_COVERAGE=1
fi
I wonder if a snippet like this (or a similar implementation, I am not too fussy about is as long as I can run it on my machine) could be added to your pull request. I am aware that the Let me know what you think and feel free to suggest another solution. |
Checking the Saxon version output won't last long. Fortunately, the test script doesn't clear the environment variable. You can force running the coverage test. export XSLT_SUPPORTS_COVERAGE=1
./run-bats.sh set XSLT_SUPPORTS_COVERAGE=1
run-bats.cmd This way, you can run the coverage test on Saxon 9.6 (or any other). |
Thanks, your solution is a good workaround for me and allows me to run the tests without adding more complexity to the code base. I can now follow your procedure for testing and everything works as you described in both Linux and Windows. I'm merging this pull request into |
This pull request derives from #299. So needs to be handled after that.
This pull request adds some basic tests for the code coverage on Ant (implemented in #279).
Some of the tests are enabled only when Saxon (specified by
SAXON_JAR
) is capable of the code coverage. So they are skipped on Travis and AppVeyor. They are enabled automatically, if you're running the tests on your machine with Saxon license.How it works
run-bats.sh
(and.cmd
) checks to see ifSAXON_JAR
can compile the coverage reporter XSL.If it can, the environment variable
XSLT_SUPPORTS_COVERAGE
is set. (d557f39)xspec.bats
(andcollection.xml
) checksXSLT_SUPPORTS_COVERAGE
before testing the coverage report feature. (01e6386)How to test
Here's what I tested on my local machine.
Do
set SAXON_JAR=\path\to\saxon9ee.jar
. (saxon9pe.jar
should be fine too, but I haven't tested.)Run
run-bats.cmd
intest/
.Must pass, including the test case 47.
Do
set SAXON_JAR=\path\to\saxon9he.jar
. (Notice the file name; It's Saxon-HE.)Run
run-bats.cmd
.Must pass, skipping the test case 47. (demonstrated on Travis and AppVeyor)
Check out 024c845 which is intentionally broken.
Do
set SAXON_JAR=\path\to\saxon9ee.jar
.Run
run-bats.cmd
.At least 29, 47, 48 and 49 must fail. (29, 48 and 49 are demonstrated on Travis and AppVeyor)
Repeat the same steps using
run-bats.sh --tap
on Ubuntu.