<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="cmdline-007.xml"
        name="cmdline-007.xml"
        expected="pass">
   <t:info>
      <t:title>cmdline-007</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-02-22</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Created test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Simple test of the command-line testing framework capturing non-XML.</p>
   </t:description>
   <t:pipeline arguments="--pipe --output:multipart/mixed@alternate=output.mime                          --output:result=result.xml">
      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      version="3.0"
                      name="main">
         <p:output port="result" primary="true"/>
         <p:output port="alternate" pipe="@alt"/>
         <p:identity>
            <p:with-input>
               <doc>alternate</doc>
            </p:with-input>
         </p:identity>
         <p:set-properties xmlns:cx="http://xmlcalabash.com/ns/extensions"
                           name="alt"
                           properties="map { 'author': 'ndw',                                       'purpose': 'testing',                                       'cx:motto': 'Spoon!' }"/>
         <p:identity>
            <p:with-input>
               <doc>primary</doc>
            </p:with-input>
         </p:identity>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:pattern>
            <s:rule context="/">
               <s:assert test="directory">The root is wrong.</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory">
               <s:assert test="count(*) = 3">Wrong number of results</s:assert>
               <s:assert test="mime[@uri='output.mime']">No MIME</s:assert>
               <s:assert test="file[@uri='_stdout']">No stdout</s:assert>
               <s:assert test="file[@uri='result.xml']">No result</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory/mime">
               <s:assert test="count(part) = 1">Wrong number of parts</s:assert>
               <s:assert test="part[@port='alternate']/body/doc[. = 'alternate']">Alternate is wrong</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory/mime/part[@port='alternate']/headers">
               <s:assert test="count(header) = 3">Wrong number of headers</s:assert>
               <s:assert test="header[@name='purpose'] = 'testing'">Purpose header is wrong</s:assert>
               <s:assert test="header[@name='author'] = 'ndw'">Author header is wrong</s:assert>
               <s:assert test="header[@name='motto'] = 'Spoon!'">Motto header is wrong</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory/file[@uri='result.xml']">
               <s:assert test="doc = 'primary'">Result is incorrect</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory/file[@uri='_stdout']">
               <s:assert test="string(.) = ''">Stdout should be empty</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
</t:test>
