[bug #59461] smoke-test_html_device.sh: make the test more independent of locale

2020-11-13 Thread Bjarni Ingi Gislason
URL:
  

 Summary: smoke-test_html_device.sh: make the test more
independent of locale
 Project: GNU troff
Submitted by: bjarniig
Submitted on: Fri 13 Nov 2020 06:02:49 PM UTC
Category: Preprocessor html
Severity: 3 - Normal
  Item Group: Test
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
 Planned Release: None

___

Details:

src/roff/groff/tests/smoke-test_html_device.sh:
  make the test more independent of the locale charset (charmap).

  Only test "locale" for the existence of a UTF-8 locale on the
computer.
(This might even be irrelevant.)

  As the encoding of the input is known, use that information.

  That is, change the option '-k' to '-Kutf8' for UTF-8 input,
and remove it for ascii input.

  Add a test for latin1 input.

  This was tested with

"locale charmap": ISO-8859-1

  and

"locale -a":

C
C.UTF-8
icelandic
is_IS
is_IS.iso88591
is_IS.utf8
POSIX

  A test without any UTF-8 locale file on the computer is missing (test
without the "locale -a | ...").

###

  Script to test changes:


#!/bin/sh

set -e

groff=/usr/bin/groff 

# Check three forms of character transformation.
#

# We test compatibility-mode HTML output somewhat differently from the
# third test
# since preconv only emits groffish \[u] escapes for non-ASCII
# codepoints.

# 1)

echo "testing -C -Thtml with \"\('a\"" >&2
printf "\('a" | "$groff" -C -Thtml | grep -qx 'á'

# 2)

echo "testing -C -Thtml with \"\('a\" as a latin1 code" >&2
printf "á" | "$groff" -C -Thtml | grep -qx 'á'

# 3)
# We possibly can't run this tests, if no file for a UTF-8 locale exists

locale -a | grep -F -q UTF-8 || exit 77 # skip

# dash's built-in printf doesn't support \x or \u escapes, so likely
# other shells don't either, and expecting one, that does, to be in the
# $PATH seems optimistic.  So use UTF-8 octal bytes directly.

echo "testing -Kutf8 -Thtml" >&2
printf '\303\241' | "$groff" -Kutf8 -Thtml | grep -qx 'á'

## End of script





___

Reply to this item at:

  

___
  Message sent via Savannah
  https://savannah.gnu.org/




[bug #59461] smoke-test_html_device.sh: make the test more independent of locale

2020-11-13 Thread Bjarni Ingi Gislason
Follow-up Comment #1, bug #59461 (project groff):

  unset GROFF_ENCODING

must be added to eliminate an external influence.

___

Reply to this item at:

  

___
  Message sent via Savannah
  https://savannah.gnu.org/




[bug #59461] smoke-test_html_device.sh: make the test more independent of locale

2020-11-15 Thread G. Branden Robinson
Update of bug #59461 (project groff):

  Status:None => Need Info  

___

Follow-up Comment #2:

What are you trying to achieve?  This is a smoke test; it's there to make sure
the HTML preprocessor and output driver (post-grohtml) don't SEGV or fail to
produce output at all.

Careful consideration of locale support in HTML documents generated by groff
should be developed in dedicated tests.

I am inclined to regard this report as invalid unless its scope can be
redrawn.

___

Reply to this item at:

  

___
  Message sent via Savannah
  https://savannah.gnu.org/




[bug #59461] smoke-test_html_device.sh: make the test more independent of locale

2020-11-15 Thread Bjarni Ingi Gislason
Follow-up Comment #3, bug #59461 (project groff):

  I am expanding the scope of the tests,
to test as many of them without a specific charmap interfering.

  Additionally to a missing "unset GROFF_ENCODING",
an "export" was missing in front of "LC_CTYPE=C.UTF-8".

  Oder of the tests matters.

  Not using "preconv" can matter.

  The test can be made variable with "LC_ALL=..." in front of the file.

  This is an improved version of the test file:

#!/bin/sh
#
groff="${abs_top_builddir:-.}/test-groff"

if test -x $groff;
then
  :
else
  groff=test-groff
  if command -v $groff > /dev/null
  then
:
  else
groff=groff
  fi
fi

echo Used groff is `which "$groff"`

#set -e

unset GROFF_ENCODING

echo 'testing -C -Thtml with'" \('a" >&2
printf "\('a" | "$groff" -C -Thtml | grep -qx 'á' || \
  { echo Test failed >&2; exit 1; }

echo 'testing -C -Thtml with á' >&2
printf 'á' | "$groff" -C -Thtml | grep -qx 'á' || \
  { echo Test failed >&2; exit 1; }

echo 'testing -Thtml with -Kutf8' >&2

export LC_CTYPE=C.UTF-8

test "$(locale charmap)" = UTF-8 || { echo charmap failed >&2; exit 77; } #
skip
printf '\303\241' | "$groff" -Kutf8 -Thtml | grep -qx 'á' ||\
  { echo Test failed >&2; exit 1; }



___

Reply to this item at:

  

___
  Message sent via Savannah
  https://savannah.gnu.org/




[bug #59461] smoke-test_html_device.sh: make the test more independent of locale

2020-11-16 Thread G. Branden Robinson
Follow-up Comment #4, bug #59461 (project groff):

Bjarni, I don't feel your reply was responsive to my comment #2.

"This is a smoke test; it's there to make sure the HTML preprocessor and
output driver (post-grohtml) don't SEGV or fail to produce output at all.

Careful consideration of locale support in HTML documents generated by groff
should be developed in dedicated tests."

You are proposing adding stuff to the test that makes it longer without
accomplishing any marginal benefit over the existing test infrastructure.

For instance, you don't need to test if test-groff exists and is executable,
if it's not, it won't run, and _tons_ of tests will fail, alerting the
developer that something has gone badly wrong.  And a groff test suite,
properly considered, doesn't need to test anything outside the build tree (and
its corresponding source tree for non-generated files).

The audience for unit tests/regression tests is developers familiar with the
software under test.  Handholding of confused users is a distraction from the
task at hand.

If you're developing these for your own different purposes, to run against
test-groff when available and against the system groff otherwise, that's fine,
but it renders them inappropriate for incorporation into the test suite in the
source tree.

I encourage you to experiment and explore, but I would ask that you not use
Savannah to propose such materials for adoption by the project.  The mailing
list is a more appropriate forum for sharing and discussion. 

Regards,
Branden

___

Reply to this item at:

  

___
  Message sent via Savannah
  https://savannah.gnu.org/




[bug #59461] smoke-test_html_device.sh: make the test more independent of locale

2022-06-02 Thread G. Branden Robinson
Update of bug #59461 (project groff):

  Status:   Need Info => Wont Fix   
 Assigned to:None => gbranden   
 Open/Closed:Open => Closed 

___

Follow-up Comment #5:

No follow-up to "Need Info" status for about 18 months.

Resolving as "Won't Fix".


___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




Re: [bug #59461] smoke-test_html_device.sh: make the test more independent of locale

2020-11-13 Thread Steffen Nurpmeso
Bjarni Ingi Gislason wrote in
 <20201113-180249.sv93188.62...@savannah.gnu.org>:
 |URL:
 |  
 ...
 |locale -a | grep -F -q UTF-8 || exit 77 # skip

That will not do, at least not portably and if you care for older
systems.  At minimum you must test utf8 and utf-8 here.  Better to
conditionalize on "command -v locale" first, it may be missing as
such (but forgot the details, i however do it like that).
Maybe something like "grep -i -q 'utf-\{0,1\}8$'" or so.

--steffen
|
|Der Kragenbaer,The moon bear,
|der holt sich munter   he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



Re: [bug #59461] smoke-test_html_device.sh: make the test more independent of locale

2020-11-15 Thread Bjarni Ingi Gislason
On Fri, Nov 13, 2020 at 08:54:27PM +0100, Steffen Nurpmeso wrote:
> Bjarni Ingi Gislason wrote in
>  <20201113-180249.sv93188.62...@savannah.gnu.org>:
>  |URL:
>  |  
>  ...
>  |locale -a | grep -F -q UTF-8 || exit 77 # skip
> 
> That will not do, at least not portably and if you care for older
> systems.  At minimum you must test utf8 and utf-8 here.  Better to
> conditionalize on "command -v locale" first, it may be missing as
> such (but forgot the details, i however do it like that).
> Maybe something like "grep -i -q 'utf-\{0,1\}8$'" or so.
> 

  Yes, I just changed the orignal test but kept the UTF-8,
so both versions will then fail.

  This test of mine is unnecessary,
and my next test version will drop it.

N.B.  The groff versions before 1.20 (year 2009) did not have the option
'-k'.

-- 
Bjarni I. Gislason