Commit f9d16914 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

added first test for the patterns a few fixes Daniel

* Makefile.am configure.in result/pattern/simple
  test/pattern/simple.*: added first test for the patterns
* pattern.c xmllint.c: a few fixes
Daniel
parent 8f2efae4
Sun Jan 30 23:35:19 CET 2005 Daniel Veillard <daniel@veillard.com>
* Makefile.am configure.in result/pattern/simple
test/pattern/simple.*: added first test for the patterns
* pattern.c xmllint.c: a few fixes
Sun Jan 30 19:27:23 CET 2005 Daniel Veillard <daniel@veillard.com>
 
* pattern.c include/libxml/pattern.h xmllint.c: added a
......
......@@ -148,7 +148,7 @@ check-local: all tests
testall : tests SVGtests SAXtests
tests: XMLtests XMLenttests NStests IDtests Errtests APItests @READER_TEST@ @TEST_SAX@ @TEST_PUSH@ @TEST_HTML@ @TEST_PHTML@ @TEST_VALID@ URItests @TEST_XPATH@ @TEST_XPTR@ @TEST_XINCLUDE@ @TEST_C14N@ @TEST_DEBUG@ @TEST_CATALOG@ @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@ Timingtests @TEST_VTIME@ @PYTHON_TESTS@ @TEST_MODULES@
tests: XMLtests XMLenttests NStests IDtests Errtests APItests @READER_TEST@ @TEST_SAX@ @TEST_PUSH@ @TEST_HTML@ @TEST_PHTML@ @TEST_VALID@ URItests @TEST_PATTERN@ @TEST_XPATH@ @TEST_XPTR@ @TEST_XINCLUDE@ @TEST_C14N@ @TEST_DEBUG@ @TEST_CATALOG@ @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@ Timingtests @TEST_VTIME@ @PYTHON_TESTS@ @TEST_MODULES@
@(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; \
$(MAKE) MAKEFLAGS+=--silent tests ; fi)
@(cd doc/examples ; $(MAKE) MAKEFLAGS+=--silent tests)
......@@ -1001,6 +1001,30 @@ SchemasPythonTests:
fi)
@(if [ -x $(PYTHON) -a -d xstc ] ; then cd xstc ; $(MAKE) CHECKER="$(CHECKER)" MAKEFLAGS+=--silent pytests ; fi)
Patterntests: xmllint$(EXEEXT)
@(echo > .memdump)
@echo "## Pattern regression tests"
-@(for i in $(srcdir)/test/pattern/*.pat ; do \
name=`basename $$i .pat`; \
if [ -f $(srcdir)/test/pattern/$$name.xml ] ; then \
if [ ! -f $(srcdir)/result/pattern/$$name ] ; then \
rm -f result.$$name ; \
echo New test file $$name ; \
for pat in `cat $$i` ; do \
$(CHECKER) $(top_builddir)/xmllint --stream --pattern $$pat $(srcdir)/test/pattern/$$name.xml >> $(srcdir)/result/pattern/$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
done ;\
else \
rm -f result.$$name ; \
lst=`cat $$i` ; \
log=`for pat in $$lst ; do $(CHECKER) $(top_builddir)/xmllint --stream --pattern $$pat $(srcdir)/test/pattern/$$name.xml 2>&1 >> result.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
done ;\
diff $(srcdir)/result/pattern/$$name result.$$name` ; \
if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
rm result.$$name ; \
fi ; fi ; done ;)
ModuleTests: testModule$(EXEEXT) testdso.la
@echo "## Module tests"
@(./testModule$(EXEEXT))
......
......@@ -866,13 +866,13 @@ AC_SUBST(WITH_WRITER)
if test "$with_pattern" = "no" ; then
echo Disabling the xmlPattern parsing interface
WITH_PATTERN=0
PATTERN_TEST=
TEST_PATTERN=
else
WITH_PATTERN=1
PATTERN_TEST=Patterntests
TEST_PATTERN=Patterntests
fi
AC_SUBST(WITH_PATTERN)
AC_SUBST(PATTERN_TEST)
AC_SUBST(TEST_PATTERN)
if test "$with_sax1" = "no" ; then
echo Disabling the older SAX1 interface
......
......@@ -11,6 +11,20 @@
* daniel@veillard.com
*/
/*
* TODO:
* - compilation flags to check for specific syntaxes
* using flags of xmlPatterncompile()
* - making clear how pattern starting with / or . need to be handled,
* currently push(NULL, NULL) means a reset of the streaming context
* and indicating we are on / (the document node), probably need
* something similar for .
* - xmlPatterncompile support of namespaces arguments, I'm not sure
* it's implemented and definitely not tested
* - handling of disjunction "pattern1 | pattern2" mean needed to build
* and check a list internally
*/
#define IN_LIBXML
#include "libxml.h"
......@@ -1348,7 +1362,6 @@ xmlStreamPush(xmlStreamCtxtPtr stream,
}
} else if (!(comp->steps[step].flags & XML_STREAM_STEP_DESC)) {
/* didn't match, discard */
printf("discard %d\n", i);
stream->states[2 * i] = -1;
}
}
......
Node /a matches pattern a
Node /a/b matches pattern b
Node /a/b matches pattern b
Node /a matches pattern /a
Node /a/b matches pattern a/b
Node /a/b/c matches pattern a/b/c
Node /a matches pattern //a
Node /a/b matches pattern //b
Node /a/b/c matches pattern //c
Node /a/b matches pattern a//b
Node /a/b/c matches pattern a//c
Node /a/b/c matches pattern b//c
a
b
b
/a
/b
/c
a/b
a/b/c
//a
//b
//c
a//b
a//c
b//c
<a>
<b>
<c d="attr">text</c>
</b>
</a>
......@@ -865,8 +865,6 @@ static void processNode(xmlTextReaderPtr reader) {
fprintf(stderr,
" pattern %s node %s\n",
pattern, path);
if (path != NULL)
xmlFree(path);
}
......@@ -879,6 +877,8 @@ static void processNode(xmlTextReaderPtr reader) {
}
}
}
if (path != NULL)
xmlFree(path);
}
#endif
}
......
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