Commit 1ace2034 authored by Kasimier T. Buchcik's avatar Kasimier T. Buchcik

Adapted the XS tests to use the new release of tests and test-definitions.

* xstc/Makefile.am xstc.py xstc-to-python.xsl: Adapted the
  XS tests to use the new release of tests and test-definitions.
parent 3ea201ce
Wed Jun 8 19:11:42 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xstc/Makefile.am xstc.py xstc-to-python.xsl: Adapted the
XS tests to use the new release of tests and test-definitions.
2005-06-07 Aleksey Sanin <aleksey@aleksey.com>
* c14n.c: fix rendering of attributes when parent node
......
......@@ -2,89 +2,106 @@
# Definition for the tests from W3C
#
PYSCRIPTS=nist-test.py ms-test.py sun-test.py
TESTDIRS=msxsdtest nisttest suntest
TARBALL=XSTC-20020116.tar.gz
TARBALLURL=http://www.w3.org/2001/05/xmlschema-test-collection/$(TARBALL)
TESTDIR=Tests
TESTDIRS=$(TESTDIR)/msxsdtest $(TESTDIR)/suntest $(TESTDIR)/Datatypes
TARBALL=xsts-2002-01-16.tar.gz
TARBALL_2=xsts-2004-01-14.tar.gz
TSNAME=xmlschema2002-01-16
TSNAME_2=xmlschema2004-01-14
TARBALLURL=http://www.w3.org/XML/2004/xml-schema-test-suite/$(TSNAME)/$(TARBALL)
TARBALLURL_2=http://www.w3.org/XML/2004/xml-schema-test-suite/$(TSNAME_2)/$(TARBALL_2)
MSTESTDEF=MSXMLSchema1-0-20020116.testSet
SUNTESTDEF=SunXMLSchema1-0-20020116.testSet
NISTTESTDEF=NISTXMLSchema1-0-20020116.testSet
NISTTESTDEF_2=NISTXMLSchemaDatatypes.testSet
#
# The local data and scripts
#
EXTRA_DIST=xstc.py sun-test-def.xml ms-test-def.xml nist-test-def.xml \
xstc-to-python.xsl
EXTRA_DIST=xstc.py xstc-to-python.xsl
#
# Nothing is done by make, only make tests and
# only if Python and Schemas are enabled.
#
all:
#
# Rule to load the test description and extract the informations
#
$(TESTDIRS) Tests/$(NISTTESTDEF_2) Tests/$(MSTTESTDEF) Tests/$(SUNTESTDEF):
-@(if [ ! -d Tests ] ; then \
mkdir Tests ; \
fi)
-@(if [ ! -f $(TARBALL) ] ; then \
echo "Missing the test suite description (2002-01-16), trying to fetch it" ;\
if [ -x /usr/bin/wget ] ; then \
wget $(TARBALLURL) ; \
else echo "Dont' know how to fetch $(TARBALLURL)" ; fi ; fi)
-@(if [ -f $(TARBALL) ] ; then \
echo -n "extracting test data (Sun, Microsoft)..." ; \
$(TAR) -C Tests --strip-path 1 -xzf $(TARBALL) '*/suntest' '*/msxsdtest' '*/$(MSTESTDEF)' '*/$(SUNTESTDEF)' ; \
echo "done" ; \
fi)
-@(if [ ! -f $(TARBALL_2) ] ; then \
echo "Missing the test suite description (2004-01-14), trying to fetch it" ;\
if [ -x /usr/bin/wget ] ; then \
wget $(TARBALLURL_2) ; \
else echo "Dont' know how to fetch $(TARBALLURL_2)" ; fi ; fi)
-@(if [ -f $(TARBALL_2) ] ; then \
echo -n "extracting test data (NIST)..." ; \
$(TAR) -C Tests --strip-path 1 -xzf $(TARBALL_2) '*/Datatypes' ; \
$(TAR) -C Tests --strip-path 2 -xzf $(TARBALL_2) '*/Metadata/$(NISTTESTDEF_2)' ; \
echo "done" ; \
fi)
#
# The python tests are generated via XSLT
#
nist-test.py: nist-test-def.xml xstc-to-python.xsl
-@(if [ -x $(XSLTPROC) ] ; then \
echo "Rebuilding script" $@ ; \
$(XSLTPROC) --nonet $(srcdir)/xstc-to-python.xsl \
$(srcdir)/nist-test-def.xml > $@ ; \
nist-test.py: Tests/$(NISTTESTDEF_2) xstc-to-python.xsl
-@(if [ -x $(XSLTPROC) ] ; then \
echo "Rebuilding script (NIST)" $@ ; \
$(XSLTPROC) --nonet --stringparam vendor NIST-2 \
$(srcdir)/xstc-to-python.xsl \
$(srcdir)/Tests/$(NISTTESTDEF_2) > $@ ; \
chmod +x $@ ; fi )
ms-test.py: ms-test-def.xml xstc-to-python.xsl
-@(if [ -x $(XSLTPROC) ] ; then \
echo "Rebuilding script" $@ ; \
$(XSLTPROC) --nonet $(srcdir)/xstc-to-python.xsl \
$(srcdir)/ms-test-def.xml > $@ ; \
ms-test.py: Tests/$(MSTTESTDEF) xstc-to-python.xsl
-@(if [ -x $(XSLTPROC) ] ; then \
echo "Rebuilding script (Microsoft)" $@ ; \
$(XSLTPROC) --nonet --stringparam vendor MS \
$(srcdir)/xstc-to-python.xsl \
$(srcdir)/Tests/$(MSTESTDEF) > $@ ; \
chmod +x $@ ; fi )
sun-test.py: sun-test-def.xml xstc-to-python.xsl
-@(if [ -x $(XSLTPROC) ] ; then \
echo "Rebuilding script" $@ ; \
$(XSLTPROC) --nonet $(srcdir)/xstc-to-python.xsl \
$(srcdir)/sun-test-def.xml > $@ ; \
sun-test.py: Tests/$(SUNTESTDEF) xstc-to-python.xsl
-@(if [ -x $(XSLTPROC) ] ; then \
echo "Rebuilding script (Sun)" $@ ; \
$(XSLTPROC) --nonet --stringparam vendor SUN \
$(srcdir)/xstc-to-python.xsl \
$(srcdir)/Tests/$(SUNTESTDEF) > $@ ; \
chmod +x $@ ; fi )
#
# Rule to load the test description and extract the informations
#
$(TESTDIRS):
-@(if [ ! -f $(TARBALL) ] ; then \
echo "Missing the test suite description, trying to fetch it" ;\
if [ -x /usr/bin/wget ] ; then \
wget $(TARBALLURL) ; \
else echo "Dont' know how to fetch $(TARBALLURL)" ; fi ; fi)
-@(if [ -f $(TARBALL) ] ; then \
echo -n "extracting tests directories..." ; \
$(TAR) -xzf $(TARBALL) $(TESTDIRS) ; \
echo "done" ; \
fi);
-@(if [ -x fixup-tests.py ] ; then \
chmod -R u+w msxsdtest; \
echo "## Microsoft tests fixups"; \
PYTHONPATH="../python:../python/.libs:..:../libs:$$PYTHONPATH" ;\
export PYTHONPATH; \
LD_LIBRARY_PATH="$(top_builddir)/.libs:$$LD_LIBRARY_PATH" ; \
$(PYTHON) fixup-tests.py ; fi)
#
# The actual test run if present. PYTHONPATH is updated to make sure
# we run the version from the loacl build and not preinstalled bindings
#
pytests: $(PYSCRIPTS) $(TESTDIRS)
-@(if [ -x nist-test.py -a -d nisttest ] ; then \
echo "## Running NIST Schemas tests"; \
-@(if [ -x nist-test.py -a -d $(TESTDIR)/Datatypes ] ; then \
echo "## Running XML Schema tests (NIST)"; \
PYTHONPATH="../python:../python/.libs:..:../libs:$$PYTHONPATH" ;\
export PYTHONPATH; \
LD_LIBRARY_PATH="$(top_builddir)/.libs:$$LD_LIBRARY_PATH" ; \
export LD_LIBRARY_PATH; \
$(CHECKER) $(PYTHON) nist-test.py -s -b $(srcdir) ; fi)
-@(if [ -x sun-test.py -a -d suntest ] ; then \
echo "## Running Sun Schemas tests"; \
-@(if [ -x sun-test.py -a -d $(TESTDIR)/suntest ] ; then \
echo "## Running Schema tests (Sun)"; \
PYTHONPATH="../python:../python/.libs:..:../libs:$$PYTHONPATH" ;\
export PYTHONPATH; \
LD_LIBRARY_PATH="$(top_builddir)/.libs:$$LD_LIBRARY_PATH" ; \
export LD_LIBRARY_PATH; \
$(CHECKER) $(PYTHON) sun-test.py -s -b $(srcdir) ; fi)
-@(if [ -x ms-test.py -a -d msxsdtest ] ; then \
echo "## Running Microsoft Schemas tests"; \
-@(if [ -x ms-test.py -a -d $(TESTDIR)/msxsdtest ] ; then \
echo "## Running Schema tests (Microsoft)"; \
PYTHONPATH="../python:../python/.libs:..:../libs:$$PYTHONPATH" ;\
export PYTHONPATH; \
LD_LIBRARY_PATH="$(top_builddir)/.libs:$$LD_LIBRARY_PATH" ; \
......
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<!-- Main template. -->
<xsl:template match="/">
<xsl:text>#!/usr/bin/python -u
#
# This file is generated from the W3C test suite description file.
#
from xstc import MSTestRunner, MSTestCase
r = MSTestRunner()
</xsl:text>
<xsl:apply-templates select="tests/test"/>
<xsl:text>
r.run()
##################
# Display results.
#
</xsl:text>
</xsl:template>
<!-- Test template. -->
<xsl:template match="file">
<xsl:text>"</xsl:text>
<xsl:value-of select="@folder"/><xsl:text>", "</xsl:text>
<xsl:value-of select="@fileName"/><xsl:text>", </xsl:text>
<xsl:value-of select="@validity"/>
</xsl:template>
<xsl:template match="test">
<xsl:text>r.addTest(MSTestCase("</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>", """</xsl:text>
<xsl:value-of select="description/text()"/>
<xsl:text>""", "</xsl:text>
<xsl:value-of select="files/file[@role='schema']/@tsDir"/>
<xsl:text>", </xsl:text>
<xsl:choose>
<xsl:when test="count(files/file[@role='schema']) = 1">
<xsl:apply-templates select="files/file[@role='schema']"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>"", "", 0</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="count(files/file[@role='instance']) = 1">
<xsl:text>, 1, </xsl:text>
<xsl:apply-templates select="files/file[@role='instance']"/>
</xsl:when>
<xsl:otherwise>, 0, "", "", 0</xsl:otherwise>
</xsl:choose>
<xsl:text>))
</xsl:text>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ts="TestSuite" version="1.0"
xmlns:xl="http://www.w3.org/1999/xlink">
<xsl:param name="vendor" select="'NIST'"/>
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>#!/usr/bin/python -u
# -*- coding: UTF-8 -*-
#
# This file is generated from the W3C test suite description file.
#
import xstc
from xstc import XSTCTestRunner, XSTCTestGroup, XSTCSchemaTest, XSTCInstanceTest
xstc.vendor = "</xsl:text><xsl:value-of select="$vendor"/><xsl:text>"
r = XSTCTestRunner()
# Group definitions.
</xsl:text>
<xsl:apply-templates select="ts:testSet/ts:testGroup" mode="group-def"/>
<xsl:text>
# Test definitions.
</xsl:text>
<xsl:apply-templates select="ts:testSet/ts:testGroup" mode="test-def"/>
<xsl:text>
r.run()
</xsl:text>
</xsl:template>
<!-- groupName, descr -->
<xsl:template match="ts:testGroup" mode="group-def">
<xsl:text>r.addGroup(XSTCTestGroup("</xsl:text>
<!-- group -->
<xsl:value-of select="@name"/><xsl:text>", "</xsl:text>
<!-- main schema -->
<xsl:value-of select="ts:schemaTest[1]/ts:schemaDocument/@xl:href"/><xsl:text>", """</xsl:text>
<!-- group-description -->
<xsl:call-template name="str">
<xsl:with-param name="str" select="ts:annotation/ts:documentation/text()"/>
</xsl:call-template>
<xsl:text>"""))
</xsl:text>
</xsl:template>
<xsl:template name="str">
<xsl:param name="str"/>
<xsl:choose>
<xsl:when test="contains($str, '&quot;')">
<xsl:call-template name="str">
<xsl:with-param name="str" select="substring-before($str, '&quot;')"/>
</xsl:call-template>
<xsl:text>'</xsl:text>
<xsl:call-template name="str">
<xsl:with-param name="str" select="substring-after($str, '&quot;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$str"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="ts:testGroup" mode="test-def">
<xsl:param name="group" select="@name"/>
<xsl:for-each select="ts:schemaTest">
<!-- groupName, isSchema, Name, Accepted, File, Val, Descr -->
<xsl:text>r.addTest(XSTCSchemaTest("</xsl:text>
<!-- group -->
<xsl:value-of select="$group"/><xsl:text>", "</xsl:text>
<!-- test-name -->
<xsl:value-of select="@name"/><xsl:text>", </xsl:text>
<!-- accepted -->
<xsl:value-of select="number(ts:current/@status = 'accepted')"/><xsl:text>, "</xsl:text>
<!-- filename -->
<xsl:value-of select="ts:schemaDocument/@xl:href"/><xsl:text>", </xsl:text>
<!-- validity -->
<xsl:value-of select="number(ts:expected/@validity = 'valid')"/><xsl:text>, "</xsl:text>
<!-- test-description -->
<xsl:value-of select="ts:annotation/ts:documentation/text()"/><xsl:text>"))
</xsl:text>
</xsl:for-each>
<xsl:for-each select="ts:instanceTest">
<!-- groupName, isSchema, Name, Accepted, File, Val, Descr -->
<xsl:text>r.addTest(XSTCInstanceTest("</xsl:text>
<!-- group -->
<xsl:value-of select="$group"/><xsl:text>", "</xsl:text>
<!-- test-name -->
<xsl:value-of select="@name"/><xsl:text>", </xsl:text>
<!-- accepted -->
<xsl:value-of select="number(ts:current/@status = 'accepted')"/><xsl:text>, "</xsl:text>
<!-- filename -->
<xsl:value-of select="ts:instanceDocument/@xl:href"/><xsl:text>", </xsl:text>
<!-- validity -->
<xsl:value-of select="number(ts:expected/@validity = 'valid')"/><xsl:text>, "</xsl:text>
<!-- test-description -->
<xsl:value-of select="ts:annotation/ts:documentation/text()"/><xsl:text>"))
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2004. Sonic Software Corporation. All rights reserved.
<metaInformation>
<scenarios/><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
</metaInformation>
-->
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment