Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

dom: Basic plumbing for local DOM testcases

And a test from a bug report:

    #23
  • Loading branch information...
commit 6fd96b8f1e1c3201f03211ccc3cadd3eac4ccadc 1 parent 5a936d7
@andreww authored
View
4 .gitignore
@@ -33,6 +33,7 @@ wxml/test/*.score
wcml/test/*.score
wkml/test/*.score
sax/test/*.score
+dom/test/*.score
common/test/failed.out
common/test/test.out
common/test/tests.out
@@ -41,6 +42,9 @@ utils/test/test.out
utils/test/tests.out
sax/test/test.out
sax/test/tests.out
+dom/test/test.out
+dom/test/test.xml
+dom/test/tests.out
wcml/test/test.out
wcml/test/test.xml
wcml/test/tests.out
View
1  dom/makefile
@@ -38,6 +38,7 @@ install: $(OBJFILES)
$(CP) $$i $(MOD_DIR); done
#
check:
+ (cd test; make) | tee -a ../dom_lib_check.out
clean:
rm -f *.$(OBJEXT) *.$(MOD_EXT) $(LIBRARY)
View
11 dom/test/Makefile
@@ -0,0 +1,11 @@
+include ../../arch.make
+
+INCFLAGS=`../../FoX-config --fcflags`
+
+.f90.exe:
+ $(FC) $(FFLAGS) $(INCFLAGS) $(LDFLAGS) $(FCFLAGS_free_f90) $(LINK_O_FLAG) $@ $< `../../FoX-config --libs --dom`
+
+check: clean
+ ./run_tests.sh
+clean:
+ rm -f *.$(OBJEXT) *.exe
View
18 dom/test/run_tests.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+INCFLAGS=`../../FoX-config --fcflags`
+export INCFLAGS
+rm -f passed.score failed.score
+rm -f tests.out failed.out
+touch passed.score failed.score
+
+for t in test_dom_*.sh
+do
+ ./$t
+done
+
+echo RESULT dom/ Test Results:
+echo RESULT dom/ Passed: `grep -c PASSED tests.out`
+echo RESULT dom/ Failed: `grep -c FAILED tests.out`
+
+echo RESULT dom/ See dom/test/failed.out for details of failed tests.
View
68 dom/test/test.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# Core files off, because they are huge on a Mac
+ulimit -c 0
+
+# NB Note that we ensure all locally-produced files
+# have Unix line endings only by using 'tr', in
+# order to compare properly to our canonical versions.
+
+passed=no
+if ! make $1.exe; then
+ echo $1 >> failed.out
+ echo "------------" >> failed.out
+ echo Cannot compile $1 >> failed.out
+ echo "------------" >> failed.out
+else
+ ./$1.exe 2>&1 | tr -d '\15' | grep -v 'STOP' > test.out
+ if test -f $1.xml
+ then
+ tr -d '\15' < test.xml | grep -v UUID > test.xml.tmp; mv test.xml.tmp test.xml
+ if test -f test.xml
+ then
+ if diff test.xml $1.xml > /dev/null; then
+ passed=yes
+ else
+ echo $1 >> failed.out
+ echo "------------" >> failed.out
+ diff -u test.xml $1.xml >> failed.out
+ echo "------------" >> failed.out
+ fi
+ else
+ echo $1 >> failed.out
+ echo " -----------"
+ echo "test.xml not produced"
+ echo " -----------"
+ fi
+ elif test -f $1.out
+ then
+ # Note that for most of the test.sh files we only check
+ # that the DIFFerences are in one direction. Here, we need
+ # to check both directions as the "test_input" file reports
+ # errors in a non-standard way (by adding lines).
+ # FIXME: Better to correct test_input?
+ if diff -B -b test.out $1.out | grep "^[><]" > /dev/null; then
+ echo $1 >> failed.out
+ echo "------------" >> failed.out
+ diff -u test.out $1.out >> failed.out
+ echo "------------" >> failed.out
+ else
+ passed=yes
+ fi
+ else
+ echo $1 >> failed.out
+ echo "------------" >> failed.out
+ echo No test output found for $1
+ echo "------------" >> failed.out
+ fi
+fi
+
+if [ $passed = yes ]; then
+ echo 'PASSED: ' $1
+ echo 'PASSED: ' $1 >> tests.out
+ echo '1' >> passed.score
+else
+ echo 'FAILED: ' $1
+ echo 'FAILED: ' $1 >> tests.out
+ echo '1' >> failed.score
+fi
View
7 dom/test/test_dom_getTextContent.sh
@@ -0,0 +1,7 @@
+#!/bin/sh -e
+
+for t in ${0%.sh}_*.f90
+do
+ TEST=${t%.f90}
+ ./test.sh $TEST
+done
View
24 dom/test/test_dom_getTextContent_1.f90
@@ -0,0 +1,24 @@
+program dom
+ use FoX_dom
+ implicit none
+
+ integer :: i
+ type(Node), pointer :: doc, name
+ type(NodeList), pointer :: nameList
+ character(200) :: name_text
+
+ doc => parseFile("test_dom_getTextContent_1.xml_in")
+
+ nameList => getElementsByTagname(doc, "name")
+
+ do i = 0, getLength(nameList) - 1
+ name_text = ''
+ name => item(nameList,i)
+
+ name_text = getTextContent(name)
+
+ write(*,*) trim(name_text)
+ enddo
+
+ call destroy(doc)
+end program dom
View
3  dom/test/test_dom_getTextContent_1.out
@@ -0,0 +1,3 @@
+
+[_tmp]:=somecommand(data, 0, 1)
+
View
5 dom/test/test_dom_getTextContent_1.xml_in
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<name>
+[_tmp]:=somecommand(data, 0, 1)
+</name>
Please sign in to comment.
Something went wrong with that request. Please try again.