1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-14 05:53:36 -04:00

Refactor test-sgml-parser-basic to work with non-bash shells

A problem with \n replacement caused test no. 19 to fail.
Fix it by also allowing expected output to be prepared in a
file by introducing a new backend: test_output_equals_file,
also used test_output_equals.

Tested on Ubuntu Feisty Fawn with both /bin/bash and /bin/sh
where /bin/sh failed before the fix. Reported by Witek.
This commit is contained in:
Jonas Fonseca 2007-05-05 11:39:23 +02:00
parent d1fa336f7f
commit 3f93148c9b

View File

@ -11,20 +11,30 @@ correctly in the DOM tree.
. "$TEST_LIB"
test_output_equals () {
test_output_equals_file () {
desc="$1"; shift
src="$1"; shift
out="$1"; shift
file="$1"; shift
URI="test:$(normalize "$desc")"
sgml-parser --uri "$URI" --src "$src" > output
echo "#document: $URI" > expected
echo "$out" | sed -n '2,$p' | sed 's/^/ /' >> expected
sed 's/^/ /' < "$file" >> expected
test_expect_success "$desc" 'cmp output expected'
}
test_output_equals () {
desc="$1"; shift
src="$1"; shift
out="$1"; shift
echo "$out" | sed -n '2,$p' > expected+
test_output_equals_file "$desc" "$src" "expected+"
}
################################################################
# Parse various SGML node types.
@ -184,18 +194,21 @@ entity-reference: #
#text: -
entity-reference: #xx'
test_output_equals \
cat > expected2 <<EOF
proc-instruction: xml -> encoding="UTF8"
attribute: encoding -> UTF8
#text: \\n...\\n
proc-instruction: ecmascript -> var val=2;\\n
EOF
test_output_equals_file \
'Parse processing instructions.' \
'<?xml encoding="UTF8"?>
...
<?ecmascript
var val=2;
?>' \
'
proc-instruction: xml -> encoding="UTF8"
attribute: encoding -> UTF8
#text: \n...\n
proc-instruction: ecmascript -> var val=2;\n'
expected2
test_output_equals \
'Parse XML processing instructions.' \