Skip to content

Commit

Permalink
Test deprecation message for Saxon 9.7
Browse files Browse the repository at this point in the history
  • Loading branch information
AirQuick committed Sep 10, 2019
1 parent ec1b334 commit ca99bec
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 60 deletions.
75 changes: 45 additions & 30 deletions test/win-bats/collection.xml
Expand Up @@ -128,7 +128,7 @@
<case name="invoking xspec generates message with default report location and creates report files">
call :run ..\bin\xspec.bat ..\tutorial\escape-for-regex.xspec
call :verify_retval 0
call :verify_line 19 x "Report available at %PARENT_DIR_ABS%\tutorial\xspec\escape-for-regex-result.html"
call :verify_line 20 x "Report available at %PARENT_DIR_ABS%\tutorial\xspec\escape-for-regex-result.html"

rem Verify
rem * XML report file is created
Expand Down Expand Up @@ -163,7 +163,7 @@
<case name="invoking xspec with -j option generates message with JUnit report location and creates report files">
call :run ..\bin\xspec.bat -j ..\tutorial\escape-for-regex.xspec
call :verify_retval 0
call :verify_line 20 x "Report available at %PARENT_DIR_ABS%\tutorial\xspec\escape-for-regex-junit.xml"
call :verify_line 21 x "Report available at %PARENT_DIR_ABS%\tutorial\xspec\escape-for-regex-junit.xml"

rem XML report file
call :verify_exist ..\tutorial\xspec\escape-for-regex-result.xml
Expand All @@ -186,13 +186,13 @@
set "TEST_DIR=%WORK_DIR%"
call :run ..\bin\xspec.bat ..\tutorial\escape-for-regex.xspec
call :verify_retval 0
call :verify_line 19 x "Report available at %TEST_DIR%\escape-for-regex-result.html"
call :verify_line 20 x "Report available at %TEST_DIR%\escape-for-regex-result.html"
</case>

<case name="invoking xspec that passes a non xs:boolean does not raise a warning #46">
call :run ..\bin\xspec.bat xspec-46.xspec
call :verify_retval 0
call :verify_line 4 r "Testing with"
call :verify_line 5 r "Testing with"
</case>

<case ifdef="XMLCALABASH_JAR" name="executing the Saxon XProc harness generates a report with UTF-8 encoding">
Expand All @@ -210,7 +210,7 @@

call :run ..\bin\xspec.bat "%SPECIAL_CHARS_DIR%\escape-for-regex.xspec"
call :verify_retval 0
call :verify_line 20 x "Report available at %EXPECTED_REPORT%"
call :verify_line 21 x "Report available at %EXPECTED_REPORT%"
call :verify_exist "%EXPECTED_REPORT%"
</case>

Expand All @@ -230,7 +230,7 @@
set SCHEMATRON_XSLT_COMPILE=schematron\schematron-param-001-step3.xsl
call :run ..\bin\xspec.bat -s schematron\schematron-param-001.xspec
call :verify_retval 0
call :verify_line 19 x "passed: 9 / pending: 0 / failed: 0 / total: 9"
call :verify_line 20 x "passed: 9 / pending: 0 / failed: 0 / total: 9"
</case>

<case name="Schematron phase/parameters are passed to Schematron compile (Ant)">
Expand All @@ -256,7 +256,7 @@
call :verify_line 4 x "I am schematron-xslt-include.xsl!"
call :verify_line 5 x "I am schematron-xslt-expand.xsl!"
call :verify_line 6 x "I am schematron-xslt-compile.xsl!"
call :verify_line 18 x "passed: 3 / pending: 0 / failed: 0 / total: 3"
call :verify_line 19 x "passed: 3 / pending: 0 / failed: 0 / total: 3"
</case>

<case name="invoking xspec with Schematron XSLTs provided externally uses provided XSLTs for Schematron compile (Ant)">
Expand Down Expand Up @@ -323,7 +323,7 @@
<case name="invoking xspec with -q option runs XSpec test for XQuery">
call :run ..\bin\xspec.bat -q ..\tutorial\xquery-tutorial.xspec
call :verify_retval 0
call :verify_line 5 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
call :verify_line 6 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
</case>

<case ifdef="BASEX_JAR XMLCALABASH_JAR" name="XProc harness for BaseX (standalone)">
Expand Down Expand Up @@ -368,8 +368,8 @@
-o result="file:/%EXPECTED_REPORT:\=/%" ^
..\src\harnesses\basex\basex-server-xquery-harness.xproc
call :verify_retval 0
call :verify_line_count 1
call :verify_line 1 r "..*/src/harnesses/harness-lib.xpl:267:45:passed: 1 / pending: 0 / failed: 0 / total: 1"
call :verify_line_count 2
call :verify_line 2 r "..*/src/harnesses/harness-lib.xpl:267:45:passed: 1 / pending: 0 / failed: 0 / total: 1"

rem Output file
call :verify_exist "%EXPECTED_REPORT%"
Expand Down Expand Up @@ -497,21 +497,21 @@
set "SAXON_CP=%SAXON_JAR%;%XML_RESOLVER_JAR%"
call :run ..\bin\xspec.bat -catalog "%SPACE_DIR%\catalog-01-catalog.xml" "%SPACE_DIR%\catalog-01-xslt.xspec"
call :verify_retval 0
call :verify_line 8 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
call :verify_line 9 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
</case>

<case ifdef="XML_RESOLVER_JAR" name="invoking xspec for XQuery with -catalog uses XML Catalog resolver">
set "SAXON_CP=%SAXON_JAR%;%XML_RESOLVER_JAR%"
call :run ..\bin\xspec.bat -catalog catalog\catalog-01-catalog.xml -q catalog\catalog-01-xquery.xspec
call :verify_retval 0
call :verify_line 5 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
call :verify_line 6 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
</case>

<case ifdef="XML_RESOLVER_JAR" name="invoking xspec for Schematron with -catalog uses XML Catalog resolver">
set "SAXON_CP=%SAXON_JAR%;%XML_RESOLVER_JAR%"
call :run ..\bin\xspec.bat -catalog catalog\catalog-02-catalog.xml -s catalog\catalog-02-schematron.xspec
call :verify_retval 0
call :verify_line 13 x "passed: 1 / pending: 0 / failed: 1 / total: 2"
call :verify_line 14 x "passed: 1 / pending: 0 / failed: 1 / total: 2"
</case>

<case ifdef="XML_RESOLVER_JAR" name="invoking xspec with XML_CATALOG set uses XML Catalog resolver and does so even with spaces in file path">
Expand All @@ -523,7 +523,7 @@
set "XML_CATALOG=%SPACE_DIR%\catalog-01-catalog.xml"
call :run ..\bin\xspec.bat "%SPACE_DIR%\catalog-01-xslt.xspec"
call :verify_retval 0
call :verify_line 8 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
call :verify_line 9 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
</case>

<case ifdef="XML_RESOLVER_JAR" name="invoking xspec using SAXON_HOME finds Saxon jar and XML Catalog Resolver jar">
Expand All @@ -539,7 +539,7 @@

call :run ..\bin\xspec.bat -catalog catalog\catalog-01-catalog.xml catalog\catalog-01-xslt.xspec
call :verify_retval 0
call :verify_line 8 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
call :verify_line 9 x "passed: 1 / pending: 0 / failed: 0 / total: 1"
</case>

<case ifdef="JING_JAR" name="Schema detects no error in known good .xspec files">
Expand Down Expand Up @@ -674,15 +674,15 @@

call :run ..\bin\xspec.bat xspec-185\import-1.xspec
call :verify_retval 0
call :verify_line 5 x "Scenario 1-1"
call :verify_line 6 x "Scenario 1-2"
call :verify_line 7 x "Scenario 1-3"
call :verify_line 8 x "Scenario 2a-1"
call :verify_line 9 x "Scenario 2a-2"
call :verify_line 10 x "Scenario 2b-1"
call :verify_line 11 x "Scenario 2b-2"
call :verify_line 12 x "Scenario 3"
call :verify_line 13 x "Formatting Report..."
call :verify_line 6 x "Scenario 1-1"
call :verify_line 7 x "Scenario 1-2"
call :verify_line 8 x "Scenario 1-3"
call :verify_line 9 x "Scenario 2a-1"
call :verify_line 10 x "Scenario 2a-2"
call :verify_line 11 x "Scenario 2b-1"
call :verify_line 12 x "Scenario 2b-2"
call :verify_line 13 x "Scenario 3"
call :verify_line 14 x "Formatting Report..."
</case>

<case name="Import order with Ant #185">
Expand All @@ -707,10 +707,10 @@
rem Provide TEST_DIR with an existing directory to make the output lines predictable
set "TEST_DIR=%WORK_DIR%"
call :run ..\bin\xspec.bat end-to-end\cases\xspec-ambiguous-expect.xspec
call :verify_line 10 r "WARNING: x:expect has boolean @test"
call :verify_line 15 r "WARNING: x:expect has boolean @test"
call :verify_line 22 r "WARNING: x:expect has boolean @test"
call :verify_line 31 x "Formatting Report..."
call :verify_line 11 r "WARNING: x:expect has boolean @test"
call :verify_line 16 r "WARNING: x:expect has boolean @test"
call :verify_line 23 r "WARNING: x:expect has boolean @test"
call :verify_line 32 x "Formatting Report..."
</case>

<case name="Deprecate x:space">
Expand Down Expand Up @@ -804,7 +804,7 @@
<case name="Error message when source is not XSpec #522">
call :run ..\bin\xspec.bat do-nothing.xsl
call :verify_retval 2
call :verify_line 3 r "Source document is not XSpec"
call :verify_line 4 r "Source document is not XSpec"
</case>

<case name="Error on user-defined variable in XSpec namespace">
Expand All @@ -813,6 +813,21 @@

call :run ..\bin\xspec.bat variable\reserved-name.xspec
call :verify_retval 2
call :verify_line 4 r ".*x:XSPEC008:"
call :verify_line 5 r ".*x:XSPEC008:"
</case>

<case name="Deprecated Saxon version">
rem Make the line numbers predictable by providing an existing output dir
set "TEST_DIR=%WORK_DIR%"

call :run ..\bin\xspec.bat ..\tutorial\escape-for-regex.xspec
call :verify_retval 0

java -cp "%SAXON_JAR%" net.sf.saxon.Version 2>&amp;1 | find " 9.7."
if errorlevel 1 (
call :verify_line 3 x " "
) else (
call :verify_line 3 r "WARNING: Saxon version ..*"
)
</case>
</collection>
76 changes: 46 additions & 30 deletions test/xspec.bats
Expand Up @@ -201,7 +201,7 @@ teardown() {
run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[18]}" = "Report available at ../tutorial/xspec/escape-for-regex-result.html" ]
[ "${lines[19]}" = "Report available at ../tutorial/xspec/escape-for-regex-result.html" ]

# Verify
# * XML report file is created
Expand Down Expand Up @@ -244,7 +244,7 @@ teardown() {
run ../bin/xspec.sh -j ../tutorial/escape-for-regex.xspec
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[19]}" = "Report available at ../tutorial/xspec/escape-for-regex-junit.xml" ]
[ "${lines[20]}" = "Report available at ../tutorial/xspec/escape-for-regex-junit.xml" ]

# XML report file
[ -f "../tutorial/xspec/escape-for-regex-result.xml" ]
Expand All @@ -271,15 +271,15 @@ teardown() {
run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[18]}" = "Report available at ${TEST_DIR}/escape-for-regex-result.html" ]
[ "${lines[19]}" = "Report available at ${TEST_DIR}/escape-for-regex-result.html" ]
}


@test "invoking xspec that passes a non xs:boolean does not raise a warning #46" {
run ../bin/xspec.sh xspec-46.xspec
echo "$output"
[ "$status" -eq 0 ]
[[ "${lines[3]}" =~ "Testing with" ]]
[[ "${lines[4]}" =~ "Testing with" ]]
}


Expand All @@ -305,7 +305,7 @@ teardown() {
run ../bin/xspec.sh "${special_chars_dir}/escape-for-regex.xspec"
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[19]}" = "Report available at ${expected_report}" ]
[ "${lines[20]}" = "Report available at ${expected_report}" ]
[ -f "${expected_report}" ]
}

Expand All @@ -329,7 +329,7 @@ teardown() {
run ../bin/xspec.sh -s schematron/schematron-param-001.xspec
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[18]}" == "passed: 9 / pending: 0 / failed: 0 / total: 9" ]
[ "${lines[19]}" == "passed: 9 / pending: 0 / failed: 0 / total: 9" ]
}


Expand Down Expand Up @@ -359,7 +359,7 @@ teardown() {
[ "${lines[3]}" = "I am schematron-xslt-include.xsl!" ]
[ "${lines[4]}" = "I am schematron-xslt-expand.xsl!" ]
[ "${lines[5]}" = "I am schematron-xslt-compile.xsl!" ]
[ "${lines[17]}" = "passed: 3 / pending: 0 / failed: 0 / total: 3" ]
[ "${lines[18]}" = "passed: 3 / pending: 0 / failed: 0 / total: 3" ]
}


Expand Down Expand Up @@ -439,7 +439,7 @@ teardown() {
run ../bin/xspec.sh -q ../tutorial/xquery-tutorial.xspec
echo "${lines[5]}"
[ "$status" -eq 0 ]
[ "${lines[4]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
[ "${lines[5]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
}


Expand Down Expand Up @@ -500,8 +500,8 @@ teardown() {
../src/harnesses/basex/basex-server-xquery-harness.xproc
echo "$output"
[ "$status" -eq 0 ]
[ "${#lines[@]}" = "1" ]
[[ "${lines[0]}" =~ "src/harnesses/harness-lib.xpl:267:45:passed: 1 / pending: 0 / failed: 0 / total: 1" ]]
[ "${#lines[@]}" = "2" ]
[[ "${lines[1]}" =~ "src/harnesses/harness-lib.xpl:267:45:passed: 1 / pending: 0 / failed: 0 / total: 1" ]]

# Output file
[ -f "${expected_report}" ]
Expand Down Expand Up @@ -669,7 +669,7 @@ teardown() {
run ../bin/xspec.sh -catalog "${space_dir}/catalog-01-catalog.xml" "${space_dir}/catalog-01-xslt.xspec"
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[7]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
[ "${lines[8]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
}


Expand All @@ -682,7 +682,7 @@ teardown() {
run ../bin/xspec.sh -catalog catalog/catalog-01-catalog.xml -q catalog/catalog-01-xquery.xspec
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[4]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
[ "${lines[5]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
}


Expand All @@ -695,7 +695,7 @@ teardown() {
run ../bin/xspec.sh -catalog catalog/catalog-02-catalog.xml -s catalog/catalog-02-schematron.xspec
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[12]}" = "passed: 1 / pending: 0 / failed: 1 / total: 2" ]
[ "${lines[13]}" = "passed: 1 / pending: 0 / failed: 1 / total: 2" ]
}


Expand All @@ -713,7 +713,7 @@ teardown() {
run ../bin/xspec.sh "${space_dir}/catalog-01-xslt.xspec"
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[7]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
[ "${lines[8]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
}


Expand All @@ -737,7 +737,7 @@ teardown() {
run ../bin/xspec.sh -catalog catalog/catalog-01-catalog.xml catalog/catalog-01-xslt.xspec
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[7]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
[ "${lines[8]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ]
}


Expand Down Expand Up @@ -915,15 +915,15 @@ teardown() {
run ../bin/xspec.sh xspec-185/import-1.xspec
echo "$output"
[ "$status" -eq 0 ]
[ "${lines[4]}" = "Scenario 1-1" ]
[ "${lines[5]}" = "Scenario 1-2" ]
[ "${lines[6]}" = "Scenario 1-3" ]
[ "${lines[7]}" = "Scenario 2a-1" ]
[ "${lines[8]}" = "Scenario 2a-2" ]
[ "${lines[9]}" = "Scenario 2b-1" ]
[ "${lines[10]}" = "Scenario 2b-2" ]
[ "${lines[11]}" = "Scenario 3" ]
[ "${lines[12]}" = "Formatting Report..." ]
[ "${lines[5]}" = "Scenario 1-1" ]
[ "${lines[6]}" = "Scenario 1-2" ]
[ "${lines[7]}" = "Scenario 1-3" ]
[ "${lines[8]}" = "Scenario 2a-1" ]
[ "${lines[9]}" = "Scenario 2a-2" ]
[ "${lines[10]}" = "Scenario 2b-1" ]
[ "${lines[11]}" = "Scenario 2b-2" ]
[ "${lines[12]}" = "Scenario 3" ]
[ "${lines[13]}" = "Formatting Report..." ]
}


Expand Down Expand Up @@ -953,10 +953,10 @@ teardown() {
export TEST_DIR="${work_dir}"
run ../bin/xspec.sh end-to-end/cases/xspec-ambiguous-expect.xspec
echo "$output"
[[ "${lines[9]}" =~ "WARNING: x:expect has boolean @test" ]]
[[ "${lines[14]}" =~ "WARNING: x:expect has boolean @test" ]]
[[ "${lines[21]}" =~ "WARNING: x:expect has boolean @test" ]]
[ "${lines[30]}" = "Formatting Report..." ]
[[ "${lines[10]}" =~ "WARNING: x:expect has boolean @test" ]]
[[ "${lines[15]}" =~ "WARNING: x:expect has boolean @test" ]]
[[ "${lines[22]}" =~ "WARNING: x:expect has boolean @test" ]]
[ "${lines[31]}" = "Formatting Report..." ]
}


Expand Down Expand Up @@ -1085,7 +1085,7 @@ teardown() {
run ../bin/xspec.sh do-nothing.xsl
echo "$output"
[ "$status" -eq 1 ]
[[ "${lines[2]}" =~ "Source document is not XSpec" ]]
[[ "${lines[3]}" =~ "Source document is not XSpec" ]]
}


Expand All @@ -1096,7 +1096,23 @@ teardown() {
run ../bin/xspec.sh variable/reserved-name.xspec
echo "$output"
[ "$status" -eq 1 ]
[[ "${lines[3]}" =~ "x:XSPEC008:" ]]
[[ "${lines[4]}" =~ "x:XSPEC008:" ]]
}


@test "Deprecated Saxon version" {
# Make the line numbers predictable by providing an existing output dir
export TEST_DIR="${work_dir}"

run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec
echo "$output"
[ "$status" -eq 0 ]

if ! java -cp "${SAXON_JAR}" net.sf.saxon.Version 2>&1 | grep -F " 9.7."; then
[ "${lines[2]}" = " " ]
else
[[ "${lines[2]}" =~ "WARNING: Saxon version " ]]
fi
}


0 comments on commit ca99bec

Please sign in to comment.