From 211ffef1e65791970cb4afbd4fc3241b6ee9cd2b Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 5 May 2007 11:39:23 +0200 Subject: [PATCH] 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. --- src/dom/test/test-sgml-parser-basic | 31 ++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/dom/test/test-sgml-parser-basic b/src/dom/test/test-sgml-parser-basic index fc8e45e6..791bbf4a 100755 --- a/src/dom/test/test-sgml-parser-basic +++ b/src/dom/test/test-sgml-parser-basic @@ -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 < encoding="UTF8" + attribute: encoding -> UTF8 +#text: \\n...\\n +proc-instruction: ecmascript -> var val=2;\\n +EOF + +test_output_equals_file \ 'Parse processing instructions.' \ ' ... ' \ -' -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.' \