mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
tests: Rework testapi.c
Only test NULL and 0 arguments which is the only useful test from my experience. Use ElementTree instead of libxml2's own Python bindings in gentest.py. Stop using the <cond> element in libxml2-api.xml. Look up modules required by symbols using separate code in xmlmod.py, preparing for the eventual removal of apibuild.py.
This commit is contained in:
@@ -18,11 +18,10 @@ The documentation and other generated files can be rebuilt by running
|
||||
|
||||
make -C doc rebuild
|
||||
|
||||
This requires `xsltproc`, the DocBook stylesheets in your XML Catalog
|
||||
and the libxml2 Python bindings to be installed, so it's best done on a
|
||||
Linux system. On Debian/Ubuntu, try
|
||||
Besides Python, this requires `xsltproc` and the DocBook stylesheets in
|
||||
your XML Catalog. On Debian/Ubuntu, try
|
||||
|
||||
apt install xsltproc python3-libxml2 docbook-xsl docbook-xml
|
||||
apt install xsltproc docbook-xsl docbook-xml
|
||||
|
||||
doc/apibuild.py generates doc/libxml2-api.xml which is used to generate
|
||||
|
||||
|
||||
1146
tools/gentest.py
Executable file → Normal file
1146
tools/gentest.py
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
141
tools/xmlmod.py
Normal file
141
tools/xmlmod.py
Normal file
@@ -0,0 +1,141 @@
|
||||
# Symbol to module mapping
|
||||
#
|
||||
# This relies on a few tables and some regexes.
|
||||
|
||||
import re
|
||||
|
||||
moduleMap = {
|
||||
'HTMLtree': 'HTML',
|
||||
'HTMLparser': 'HTML',
|
||||
'c14n': 'C14N',
|
||||
'catalog': 'CATALOG',
|
||||
'debugXML': 'DEBUG',
|
||||
'nanohttp': 'HTTP',
|
||||
'pattern': 'PATTERN',
|
||||
'relaxng': 'RELAXNG',
|
||||
'schemasInternals': 'SCHEMAS',
|
||||
'schematron': 'SCHEMATRON',
|
||||
'xinclude': 'XINCLUDE',
|
||||
'xlink': 'XPTR',
|
||||
'xmlautomata': 'REGEXP',
|
||||
'xmlmodule': 'MODULES',
|
||||
'xmlreader': 'READER',
|
||||
'xmlregexp': 'REGEXP',
|
||||
'xmlsave': 'OUTPUT',
|
||||
'xmlschemas': 'SCHEMAS',
|
||||
'xmlschemastypes': 'SCHEMAS',
|
||||
'xmlwriter': 'WRITER',
|
||||
'xpath': 'XPATH',
|
||||
'xpathInternals': 'XPATH',
|
||||
'xpointer': 'XPTR',
|
||||
}
|
||||
|
||||
symbolMap1 = {
|
||||
# not VALID
|
||||
'xmlValidateNCName': '',
|
||||
'xmlValidateNMToken': '',
|
||||
'xmlValidateName': '',
|
||||
'xmlValidateQName': '',
|
||||
|
||||
'htmlDefaultSAXHandlerInit': 'HTML',
|
||||
'xmlSAX2InitHtmlDefaultSAXHandler': 'HTML',
|
||||
|
||||
'xmlRegisterHTTPPostCallbacks': 'HTTP',
|
||||
|
||||
'xmlAttrSerializeTxtContent': 'OUTPUT',
|
||||
'xmlUTF8ToIsolat1': 'OUTPUT',
|
||||
'xmlSprintfElementContent': 'OUTPUT',
|
||||
|
||||
'xmlCreatePushParserCtxt': 'PUSH',
|
||||
'xmlParseChunk': 'PUSH',
|
||||
|
||||
'xmlParseBalancedChunkMemory': 'SAX1',
|
||||
'xmlParseBalancedChunkMemoryRecover': 'SAX1',
|
||||
'xmlParseDoc': 'SAX1',
|
||||
'xmlParseEntity': 'SAX1',
|
||||
'xmlParseExternalEntity': 'SAX1',
|
||||
'xmlParseFile': 'SAX1',
|
||||
'xmlParseMemory': 'SAX1',
|
||||
'xmlSAXDefaultVersion': 'SAX1',
|
||||
'xmlSetupParserForBuffer': 'SAX1',
|
||||
|
||||
'xmlCtxtGetValidCtxt': 'VALID',
|
||||
'xmlFreeValidCtxt': 'VALID',
|
||||
'xmlNewValidCtxt': 'VALID',
|
||||
}
|
||||
|
||||
symbolMap2 = {
|
||||
# not OUTPUT (should be fixed in xmlIO.h)
|
||||
'xmlOutputBufferCreateFilenameDefault': '',
|
||||
|
||||
'xmlXPathDebugDumpCompExpr': 'DEBUG',
|
||||
'xmlXPathDebugDumpObject': 'DEBUG',
|
||||
'xmlSchemaDump': 'DEBUG',
|
||||
|
||||
'xmlACatalogDump': 'OUTPUT',
|
||||
'xmlCatalogDump': 'OUTPUT',
|
||||
'xmlIOHTTPOpenW': 'OUTPUT',
|
||||
'xmlNanoHTTPSave': 'OUTPUT',
|
||||
'xmlRegisterHTTPPostCallbacks': 'OUTPUT',
|
||||
'xmlRelaxNGDump': 'OUTPUT',
|
||||
'xmlRelaxNGDumpTree': 'OUTPUT',
|
||||
|
||||
'xmlTextReaderPreservePattern': 'PATTERN',
|
||||
|
||||
'htmlCreatePushParserCtxt': 'PUSH',
|
||||
'htmlParseChunk': 'PUSH',
|
||||
|
||||
'xmlValidBuildContentModel': 'REGEXP',
|
||||
'xmlValidatePopElement': 'REGEXP',
|
||||
'xmlValidatePushCData': 'REGEXP',
|
||||
'xmlValidatePushElement': 'REGEXP',
|
||||
|
||||
'xmlTextReaderRelaxNGSetSchema': 'RELAXNG',
|
||||
'xmlTextReaderRelaxNGValidate': 'RELAXNG',
|
||||
'xmlTextReaderRelaxNGValidateCtxt': 'RELAXNG',
|
||||
|
||||
'xmlTextReaderSchemaValidate': 'SCHEMAS',
|
||||
'xmlTextReaderSchemaValidateCtxt': 'SCHEMAS',
|
||||
'xmlTextReaderSetSchema': 'SCHEMAS',
|
||||
|
||||
'xmlTextReaderReadInnerXml': 'WRITER',
|
||||
'xmlTextReaderReadOuterXml': 'WRITER',
|
||||
}
|
||||
|
||||
outputRegex = '|'.join((
|
||||
'^(html|xml(Buf)?)(Doc(Content|Format)?|Elem|Node)Dump',
|
||||
'^(html|xml)Save(Format)?File',
|
||||
'^xmlDump.*(Decl|Table)',
|
||||
'^xml(Alloc)?OutputBuffer',
|
||||
'^xml.*OutputCallbacks',
|
||||
))
|
||||
|
||||
def findModules(filename, symbol):
|
||||
module1 = symbolMap1.get(symbol)
|
||||
|
||||
if module1 is None:
|
||||
module1 = moduleMap.get(filename)
|
||||
|
||||
if module1 is None:
|
||||
if re.search('^xml(Ctxt)?Valid|Parse(DTD|Dtd)', symbol):
|
||||
module1 = 'VALID'
|
||||
elif re.search('^xml(Recover|SAX(User)?Parse)', symbol):
|
||||
module1 = 'SAX1'
|
||||
elif re.search('^xmlIOHTTP', symbol):
|
||||
module1 = 'HTTP'
|
||||
|
||||
module2 = symbolMap2.get(symbol)
|
||||
|
||||
if module2 is None:
|
||||
if re.search(outputRegex, symbol):
|
||||
if module1 is None:
|
||||
module1 = 'OUTPUT'
|
||||
else:
|
||||
module2 = 'OUTPUT'
|
||||
|
||||
if module1 is None:
|
||||
module1 = ''
|
||||
if module2 is None:
|
||||
module2 = ''
|
||||
|
||||
return module1, module2
|
||||
Reference in New Issue
Block a user