Skip to content

Commit

Permalink
Merge pull request #774 from ndw/step-avail
Browse files Browse the repository at this point in the history
A few more step-available/use-when tests
  • Loading branch information
ndw authored Dec 7, 2024
2 parents 3912750 + ac689a6 commit 1b96593
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test-suite/pipelines/nw-decl1.xpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<p:library version="3.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:x="http://example.com/steps">

<p:declare-step type="x:step1">
<p:output port="result" />
<p:identity>
<p:with-input><step1/></p:with-input>
</p:identity>
</p:declare-step>

</p:library>
12 changes: 12 additions & 0 deletions test-suite/pipelines/nw-decl2.xpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<p:library version="3.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:x="http://example.com/steps">

<p:declare-step type="x:step2">
<p:output port="result" />
<p:identity>
<p:with-input><step2/></p:with-input>
</p:identity>
</p:declare-step>

</p:library>
12 changes: 12 additions & 0 deletions test-suite/pipelines/nw-decl3.xpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<p:library version="3.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:x="http://example.com/steps">

<p:declare-step type="x:step3">
<p:output port="result" />
<p:identity>
<p:with-input><step3/></p:with-input>
</p:identity>
</p:declare-step>

</p:library>
55 changes: 55 additions & 0 deletions test-suite/tests/nw-step-available-005.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>nw-step-available-005</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-12-06</t:date>
<t:author>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Initial commit</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests p:step-available with use-when and a chain of hidden steps, ending successfully.</p>
</t:description>
<t:pipeline>
<p:declare-step name="main"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:imp="http://example.com/steps"
xmlns:ex="http://extension">

<p:import href="../pipelines/nw-decl1.xpl" use-when="p:step-available('imp:step2')"/>
<p:import href="../pipelines/nw-decl2.xpl" use-when="p:step-available('imp:step3')"/>
<p:import href="../pipelines/nw-decl3.xpl"/>

<p:output port="result"/>

<p:identity>
<p:with-input>
<result>
<test>{p:step-available('imp:step1')}</test>
</result>
</p:with-input>
</p:identity>
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns="http://www.w3.org/1999/xhtml">
<s:pattern>
<s:rule context="/">
<s:assert test="result">The document root is not “result”.</s:assert>
<s:assert test="result/test/text()='true'">p:step-available for 'imp:step1' is wrong.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
55 changes: 55 additions & 0 deletions test-suite/tests/nw-step-available-006.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>nw-step-available-006</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-12-06</t:date>
<t:author>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Initial commit</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests p:step-available with use-when and a chain of hidden steps, ending in failure.</p>
</t:description>
<t:pipeline>
<p:declare-step name="main"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:imp="http://example.com/steps"
xmlns:ex="http://extension">

<p:import href="../pipelines/nw-decl1.xpl" use-when="p:step-available('imp:step2')"/>
<p:import href="../pipelines/nw-decl2.xpl" use-when="p:step-available('imp:step3')"/>
<p:import href="../pipelines/nw-decl3.xpl" use-when="p:step-available('ex:spoon')"/>

<p:output port="result"/>

<p:identity>
<p:with-input>
<result>
<test>{p:step-available('imp:step1')}</test>
</result>
</p:with-input>
</p:identity>
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns="http://www.w3.org/1999/xhtml">
<s:pattern>
<s:rule context="/">
<s:assert test="result">The document root is not “result”.</s:assert>
<s:assert test="result/test/text()='false'">p:step-available for 'imp:step1' is wrong.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
58 changes: 58 additions & 0 deletions test-suite/tests/nw-step-available-007.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>nw-step-available-007</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-12-06</t:date>
<t:author>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Initial commit</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests p:step-available with use-when and a chain of hidden steps.
If the use of step-available on p:import is treated as a special case,
this ends in failure. But an argument could be made that this contains
a deadlock.</p>
</t:description>
<t:pipeline>
<p:declare-step name="main"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:imp="http://example.com/steps"
xmlns:ex="http://extension">

<p:import href="../pipelines/nw-decl1.xpl" use-when="p:step-available('imp:step2')"/>
<p:import href="../pipelines/nw-decl2.xpl" use-when="p:step-available('imp:step3')"/>
<p:import href="../pipelines/nw-decl3.xpl" use-when="p:step-available('imp:step1')"/>

<p:output port="result"/>

<p:identity>
<p:with-input>
<result>
<test>{p:step-available('imp:step1')}</test>
</result>
</p:with-input>
</p:identity>
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns="http://www.w3.org/1999/xhtml">
<s:pattern>
<s:rule context="/">
<s:assert test="result">The document root is not “result”.</s:assert>
<s:assert test="result/test/text()='false'">p:step-available for 'imp:step1' is wrong.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>

0 comments on commit 1b96593

Please sign in to comment.