1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-16 01:08:31 -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 committed by Witold Filipczyk
parent dab6062347
commit 211ffef1e6

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.' \