Skip to content

Commit 6fd96b8

Browse files
committed
dom: Basic plumbing for local DOM testcases
And a test from a bug report: #23
1 parent 5a936d7 commit 6fd96b8

9 files changed

+141
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ wxml/test/*.score
3333
wcml/test/*.score
3434
wkml/test/*.score
3535
sax/test/*.score
36+
dom/test/*.score
3637
common/test/failed.out
3738
common/test/test.out
3839
common/test/tests.out
@@ -41,6 +42,9 @@ utils/test/test.out
4142
utils/test/tests.out
4243
sax/test/test.out
4344
sax/test/tests.out
45+
dom/test/test.out
46+
dom/test/test.xml
47+
dom/test/tests.out
4448
wcml/test/test.out
4549
wcml/test/test.xml
4650
wcml/test/tests.out

dom/makefile

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ install: $(OBJFILES)
3838
$(CP) $$i $(MOD_DIR); done
3939
#
4040
check:
41+
(cd test; make) | tee -a ../dom_lib_check.out
4142

4243
clean:
4344
rm -f *.$(OBJEXT) *.$(MOD_EXT) $(LIBRARY)

dom/test/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include ../../arch.make
2+
3+
INCFLAGS=`../../FoX-config --fcflags`
4+
5+
.f90.exe:
6+
$(FC) $(FFLAGS) $(INCFLAGS) $(LDFLAGS) $(FCFLAGS_free_f90) $(LINK_O_FLAG) $@ $< `../../FoX-config --libs --dom`
7+
8+
check: clean
9+
./run_tests.sh
10+
clean:
11+
rm -f *.$(OBJEXT) *.exe

dom/test/run_tests.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
INCFLAGS=`../../FoX-config --fcflags`
4+
export INCFLAGS
5+
rm -f passed.score failed.score
6+
rm -f tests.out failed.out
7+
touch passed.score failed.score
8+
9+
for t in test_dom_*.sh
10+
do
11+
./$t
12+
done
13+
14+
echo RESULT dom/ Test Results:
15+
echo RESULT dom/ Passed: `grep -c PASSED tests.out`
16+
echo RESULT dom/ Failed: `grep -c FAILED tests.out`
17+
18+
echo RESULT dom/ See dom/test/failed.out for details of failed tests.

dom/test/test.sh

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/sh
2+
3+
# Core files off, because they are huge on a Mac
4+
ulimit -c 0
5+
6+
# NB Note that we ensure all locally-produced files
7+
# have Unix line endings only by using 'tr', in
8+
# order to compare properly to our canonical versions.
9+
10+
passed=no
11+
if ! make $1.exe; then
12+
echo $1 >> failed.out
13+
echo "------------" >> failed.out
14+
echo Cannot compile $1 >> failed.out
15+
echo "------------" >> failed.out
16+
else
17+
./$1.exe 2>&1 | tr -d '\15' | grep -v 'STOP' > test.out
18+
if test -f $1.xml
19+
then
20+
tr -d '\15' < test.xml | grep -v UUID > test.xml.tmp; mv test.xml.tmp test.xml
21+
if test -f test.xml
22+
then
23+
if diff test.xml $1.xml > /dev/null; then
24+
passed=yes
25+
else
26+
echo $1 >> failed.out
27+
echo "------------" >> failed.out
28+
diff -u test.xml $1.xml >> failed.out
29+
echo "------------" >> failed.out
30+
fi
31+
else
32+
echo $1 >> failed.out
33+
echo " -----------"
34+
echo "test.xml not produced"
35+
echo " -----------"
36+
fi
37+
elif test -f $1.out
38+
then
39+
# Note that for most of the test.sh files we only check
40+
# that the DIFFerences are in one direction. Here, we need
41+
# to check both directions as the "test_input" file reports
42+
# errors in a non-standard way (by adding lines).
43+
# FIXME: Better to correct test_input?
44+
if diff -B -b test.out $1.out | grep "^[><]" > /dev/null; then
45+
echo $1 >> failed.out
46+
echo "------------" >> failed.out
47+
diff -u test.out $1.out >> failed.out
48+
echo "------------" >> failed.out
49+
else
50+
passed=yes
51+
fi
52+
else
53+
echo $1 >> failed.out
54+
echo "------------" >> failed.out
55+
echo No test output found for $1
56+
echo "------------" >> failed.out
57+
fi
58+
fi
59+
60+
if [ $passed = yes ]; then
61+
echo 'PASSED: ' $1
62+
echo 'PASSED: ' $1 >> tests.out
63+
echo '1' >> passed.score
64+
else
65+
echo 'FAILED: ' $1
66+
echo 'FAILED: ' $1 >> tests.out
67+
echo '1' >> failed.score
68+
fi

dom/test/test_dom_getTextContent.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh -e
2+
3+
for t in ${0%.sh}_*.f90
4+
do
5+
TEST=${t%.f90}
6+
./test.sh $TEST
7+
done
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
program dom
2+
use FoX_dom
3+
implicit none
4+
5+
integer :: i
6+
type(Node), pointer :: doc, name
7+
type(NodeList), pointer :: nameList
8+
character(200) :: name_text
9+
10+
doc => parseFile("test_dom_getTextContent_1.xml_in")
11+
12+
nameList => getElementsByTagname(doc, "name")
13+
14+
do i = 0, getLength(nameList) - 1
15+
name_text = ''
16+
name => item(nameList,i)
17+
18+
name_text = getTextContent(name)
19+
20+
write(*,*) trim(name_text)
21+
enddo
22+
23+
call destroy(doc)
24+
end program dom
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
[_tmp]:=somecommand(data, 0, 1)
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
3+
<name>
4+
[_tmp]:=somecommand(data, 0, 1)
5+
</name>

0 commit comments

Comments
 (0)