polyglot-011

Tests that standard error and standard output are processed.

Test polyglot-011.xml is expected to pass.

It requires the following features: polyglot.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions" xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
   <p:import href="https://xmlcalabash.com/ext/library/polyglot.xpl"/>
   <p:import href="https://xmlcalabash.com/ext/library/pipeline-messages.xpl"/>
   <p:output port="result"/>
   <cx:python name="python">
      <p:with-input port="program">
         <p:inline content-type="text/plain" expand-text="false">
import sys
print("This is stdout")
print("This is stderr", file=sys.stderr)
42
          </p:inline>
      </p:with-input>
   </cx:python>
   <cx:pipeline-messages p:depends="python" level="info" clear="true"/>
</p:declare-step>

Schematron validation

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <s:ns prefix="cx" uri="http://xmlcalabash.com/ns/extensions"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="cx:messages">The document root is not correct.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/cx:messages">
         <s:assert test="cx:message[@level='WARN' and contains(@message, 'This is stderr')]">No message on stderr.</s:assert>
      </s:rule>
      <s:rule context="/cx:messages">
         <s:assert test="cx:message[@level='INFO' and contains(@message, 'This is stdout')]">No message on stdout.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

03 Jan 2025, Norm Tovey-Walsh

Created test.