From 03c467bcbfbc30a56e0da3c6d39f653ab9e64701 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 28 Jan 2006 15:03:19 +0100 Subject: [PATCH 1/2] Move URI normalization to the test library --- src/dom/test/test-dom-configuration-basic | 8 +------- src/dom/test/test-sgml-parser-basic | 8 +------- src/dom/test/test-sgml-parser-incremental | 8 +------- test/libtest.sh | 13 ++++++++++++- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/dom/test/test-dom-configuration-basic b/src/dom/test/test-dom-configuration-basic index cd217b1ef..08381888a 100755 --- a/src/dom/test/test-dom-configuration-basic +++ b/src/dom/test/test-dom-configuration-basic @@ -17,13 +17,7 @@ test_normalize_output_equals () { src="$1"; shift out="$1"; shift - URI="test:$(echo "$desc" | sed ' - s/^[ \t]*\[[^]]*\][ \t]*//; - s/[:., \t][:., \t]*/-/g; - s/_/-/g; - # *cough* - y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/; - s/[^a-zA-Z0-9-]//g;')" + URI="test:$(normalize "$desc")" sgml-parser --src "$src" --normalize "$config" --uri "$URI" --src "$src" | sed 's/^ //' > output echo "#document: $URI" > expected diff --git a/src/dom/test/test-sgml-parser-basic b/src/dom/test/test-sgml-parser-basic index f19f158eb..f81495e9c 100755 --- a/src/dom/test/test-sgml-parser-basic +++ b/src/dom/test/test-sgml-parser-basic @@ -16,13 +16,7 @@ test_output_equals () { src="$1"; shift out="$1"; shift - URI="test:$(echo "$desc" | sed ' - s/^[ \t]*\[[^]]*\][ \t]*//; - s/[:., \t][:., \t]*/-/g; - s/_/-/g; - # *cough* - y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/; - s/[^a-zA-Z0-9-]//g;')" + URI="test:$(normalize "$desc")" sgml-parser --uri "$URI" --src "$src" | sed 's/^ //' > output echo "#document: $URI" > expected diff --git a/src/dom/test/test-sgml-parser-incremental b/src/dom/test/test-sgml-parser-incremental index aa6ea64b1..1e520d06f 100755 --- a/src/dom/test/test-sgml-parser-incremental +++ b/src/dom/test/test-sgml-parser-incremental @@ -16,13 +16,7 @@ test_incremental_parsing () { src="$1"; shift out="$1"; shift - URI="test:$(echo "$desc" | sed ' - s/^[ \t]*\[[^]]*\][ \t]*//; - s/[:., \t][:., \t]*/-/g; - s/_/-/g; - # *cough* - y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/; - s/[^a-zA-Z0-9-]//g;')" + URI="test:$(normalize "$desc")" echo "#document: $URI" > expected echo "$out" | sed -n '2,$p' >> expected diff --git a/test/libtest.sh b/test/libtest.sh index 12de5c920..a16e4577f 100755 --- a/test/libtest.sh +++ b/test/libtest.sh @@ -15,7 +15,7 @@ export LANG LC_ALL PAGER TZ # test_description='Description of this test... # This test checks if command xyzzy does the right thing... # ' -# . ./test-lib.sh +# . "$TEST_LIB error () { echo "* error: $*" @@ -27,6 +27,17 @@ say () { echo "* $*" } +normalize () { + echo "$@" | sed ' + s/^[ \t]*\[[^]]*\][ \t]*//; + s/[:., \t][:., \t]*/-/g; + s/_/-/g; + # *cough* + y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/; + s/[^a-zA-Z0-9-]//g;' +} + + test "${test_description}" != "" || error "Test script did not set test_description." From c223f6ce9418f5688da55320f906b81a152394d7 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 28 Jan 2006 15:12:49 +0100 Subject: [PATCH 2/2] Sed the expected output instead of the output from sgml-parser --- src/dom/test/test-dom-configuration-basic | 4 ++-- src/dom/test/test-sgml-parser-basic | 4 ++-- src/dom/test/test-sgml-parser-incremental | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/dom/test/test-dom-configuration-basic b/src/dom/test/test-dom-configuration-basic index 08381888a..dd118f406 100755 --- a/src/dom/test/test-dom-configuration-basic +++ b/src/dom/test/test-dom-configuration-basic @@ -19,9 +19,9 @@ test_normalize_output_equals () { URI="test:$(normalize "$desc")" - sgml-parser --src "$src" --normalize "$config" --uri "$URI" --src "$src" | sed 's/^ //' > output + sgml-parser --src "$src" --normalize "$config" --uri "$URI" --src "$src" > output echo "#document: $URI" > expected - echo "$out" | sed -n '2,$p' >> expected + echo "$out" | sed -n '2,$p' | sed 's/^/ /' >> expected test_expect_success "$desc" 'cmp output expected' } diff --git a/src/dom/test/test-sgml-parser-basic b/src/dom/test/test-sgml-parser-basic index f81495e9c..989366beb 100755 --- a/src/dom/test/test-sgml-parser-basic +++ b/src/dom/test/test-sgml-parser-basic @@ -18,9 +18,9 @@ test_output_equals () { URI="test:$(normalize "$desc")" - sgml-parser --uri "$URI" --src "$src" | sed 's/^ //' > output + sgml-parser --uri "$URI" --src "$src" > output echo "#document: $URI" > expected - echo "$out" | sed -n '2,$p' >> expected + echo "$out" | sed -n '2,$p' | sed 's/^/ /' >> expected test_expect_success "$desc" 'cmp output expected' } diff --git a/src/dom/test/test-sgml-parser-incremental b/src/dom/test/test-sgml-parser-incremental index 1e520d06f..81038b834 100755 --- a/src/dom/test/test-sgml-parser-incremental +++ b/src/dom/test/test-sgml-parser-incremental @@ -19,11 +19,10 @@ test_incremental_parsing () { URI="test:$(normalize "$desc")" echo "#document: $URI" > expected - echo "$out" | sed -n '2,$p' >> expected + echo "$out" | sed -n '2,$p' | sed -e 's/^/ /' >> expected for size in 1 2 3 4 5 6 7 8 9 10 15 20 25 50; do - echo -n "$src" | sgml-parser --uri "$URI" --stdin "$size" \ - | sed -e 's/^ //' > output + echo -n "$src" | sgml-parser --uri "$URI" --stdin "$size" > output test_run_ 'cmp output expected' if [ "$?" != 0 -o "$eval_ret" != 0 ] @@ -39,7 +38,7 @@ test_incremental_parsing () { test_incremental_parsing \ "Parse a small document." \ '

Hello World!

' \ - ' +' element: html element: body element: p