Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metakernel/tests/test_replwrap.py::REPLWrapTestCase::test_bash fails because of control codes in man(1) output #266

Open
mgorny opened this issue Jul 11, 2023 · 2 comments

Comments

@mgorny
Copy link

mgorny commented Jul 11, 2023

This test fals on Gentoo, apparently because man(1) is outputting control codes between characters.

============================================================== FAILURES ===============================================================
_____________________________________________________ REPLWrapTestCase.test_bash ______________________________________________________

self = <metakernel.tests.test_replwrap.REPLWrapTestCase testMethod=test_bash>

    def test_bash(self):
        bash = replwrap.bash()
        res = bash.run_command("time")
        assert 'real' in res, res
    
        # PAGER should be set to cat, otherwise man hangs
        res = bash.run_command('man sleep', timeout=2)
>       assert 'SLEEP' in res, res
E       AssertionError: SLEEP(1)                         User Commands                        SLEEP(1)^M
E         ^M
E         NAME^M
E                sleep - delay for a specified amount of time^M
E         ^M
E         SYNOPSIS^M
E                sleep NUMBER[SUFFIX]...^M
E                sleep OPTION^M
E         ^M
E         DESCRIPTION^M
E                Pause for NUMBER seconds.  SUFFIX may be 's' for seconds (the default),^M
E                'm'  for minutes, 'h' for hours or 'd' for days.  NUMBER need not be an^M
E                integer.  Given two or more arguments, pause for  the  amount  of  time^M
E                specified by the sum of their values.^M
E         ^M
E                --help display this help and exit^M
E         ^M
E                --version^M
E                       output version information and exit^M
E         ^M
E         AUTHOR^M
E                Written by Jim Meyering and Paul Eggert.^M
E         ^M
E         REPORTING BUGS^M
E                GNU coreutils online help: <https://www.gnu.org/software/coreutils/>^M
E                Report any translation bugs to <https://translationproject.org/team/>^M
E         ^M
E         SEE ALSO^M
E                sleep(3)^M
E         ^M
E                Full documentation <https://www.gnu.org/software/coreutils/sleep>^M
E                or available locally via: info '(coreutils) sleep invocation'^M
E         ^M
E                Packaged by Gentoo (9.3-r3 (p0))^M
E                Copyright (C) 2023 Free Software Foundation, Inc.^M
E                License  GPLv3+:  GNU  GPL  version  3  or  later  <https://gnu.org/li-^M
E                censes/gpl.html>.^M
E                This is free software: you are free to change and redistribute it.^M
E                There is NO WARRANTY, to the extent permitted by law.^M
E         ^M
E         GNU coreutils 9.3                 April 2023                          SLEEP(1)^M
E         
E       assert 'SLEEP' in "_\x08S_\x08L_\x08E_\x08E_\x08P(1)                         User Commands                        _\x08S_\x08L_\x08E_\x08E_\x08P(1)\r\n\r\nN\x08NA\x08AM\x08ME\x08E\r\n       sleep - delay for a specified amount of time\r\n\r\nS\x08SY\x08YN\x08NO\x08OP\x08PS\x08SI\x08IS\x08S\r\n       s\x08sl\x08le\x08ee\x08ep\x08p _\x08N_\x08U_\x08M_\x08B_\x08E_\x08R[_\x08S_\x08U_\x08F_\x08F_\x08I_\x08X]...\r\n       s\x08sl\x08le\x08ee\x08ep\x08p _\x08O_\x08P_\x08T_\x08I_\x08O_\x08N\r\n\r\nD\x08DE\x08ES\x08SC\x08CR\x08RI\x08IP\x08PT\x08TI\x08IO\x08ON\x08N\r\n       Pause for NUMBER seconds.  SUFFIX may be 's' for seconds (the default),\r\n       'm'  for minutes, 'h' for hours or 'd' for days.  NUMBER need not be an\r\n       integer.  Given two or more arguments, pause for  the  amount  of  time\r\n       specified by the sum of their values.\r\n\r\n       -\x08--\x08-h\x08he\x08el\x08lp\x08p display this help and exit\r\n\r\n       -\x08--\x08-v\x08ve\x08er\x08rs\x08si\x08io\x08on\x08n\r\n              output version information and exit\r\n\r\nA\x08AU\x08UT\x08TH\x08HO\x08OR\x08R\r\n       Written by Jim Meyering and Paul Eggert.\r\n\r\nR\x08RE\x08EP\x08PO\x08OR\x08RT\x08TI\x08IN\x08NG\x08G B\x08BU\x08UG\x08GS\x08S\r\n       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>\r\n       Report any translation bugs to <https://translationproject.org/team/>\r\n\r\nS\x08SE\x08EE\x08E A\x08AL\x08LS\x08SO\x08O\r\n       s\x08sl\x08le\x08ee\x08ep\x08p(3)\r\n\r\n       Full documentation <https://www.gnu.org/software/coreutils/sleep>\r\n       or available locally via: info '(coreutils) sleep invocation'\r\n\r\n       Packaged by Gentoo (9.3-r3 (p0))\r\n       Copyright (C) 2023 Free Software Foundation, Inc.\r\n       License  GPLv3+:  GNU  GPL  version  3  or  later  <https://gnu.org/li-\r\n       censes/gpl.html>.\r\n       This is free software: you are free to change and redistribute it.\r\n       There is NO WARRANTY, to the extent permitted by law.\r\n\r\nGNU coreutils 9.3                 April 2023                          _\x08S_\x08L_\x08E_\x08E_\x08P(1)\r\n"

bash       = <metakernel.replwrap.REPLWrapper object at 0x7fb6d0586b60>
res        = ('_\x08S_\x08L_\x08E_\x08E_\x08P(1)                         User '
 'Commands                        _\x08S_\x08L_\x08E_\x08E_\x08P(1)\r\n'
 '\r\n'
 'N\x08NA\x08AM\x08ME\x08E\r\n'
 '       sleep - delay for a specified amount of time\r\n'
 '\r\n'
 'S\x08SY\x08YN\x08NO\x08OP\x08PS\x08SI\x08IS\x08S\r\n'
 '       s\x08sl\x08le\x08ee\x08ep\x08p '
 '_\x08N_\x08U_\x08M_\x08B_\x08E_\x08R[_\x08S_\x08U_\x08F_\x08F_\x08I_\x08X]...\r\n'
 '       s\x08sl\x08le\x08ee\x08ep\x08p '
 '_\x08O_\x08P_\x08T_\x08I_\x08O_\x08N\r\n'
 '\r\n'
 'D\x08DE\x08ES\x08SC\x08CR\x08RI\x08IP\x08PT\x08TI\x08IO\x08ON\x08N\r\n'
 "       Pause for NUMBER seconds.  SUFFIX may be 's' for seconds (the "
 'default),\r\n'
 "       'm'  for minutes, 'h' for hours or 'd' for days.  NUMBER need not be "
 'an\r\n'
 '       integer.  Given two or more arguments, pause for  the  amount  of  '
 'time\r\n'
 '       specified by the sum of their values.\r\n'
 '\r\n'
 '       -\x08--\x08-h\x08he\x08el\x08lp\x08p display this help and exit\r\n'
 '\r\n'
 '       -\x08--\x08-v\x08ve\x08er\x08rs\x08si\x08io\x08on\x08n\r\n'
 '              output version information and exit\r\n'
 '\r\n'
 'A\x08AU\x08UT\x08TH\x08HO\x08OR\x08R\r\n'
 '       Written by Jim Meyering and Paul Eggert.\r\n'
 '\r\n'
 'R\x08RE\x08EP\x08PO\x08OR\x08RT\x08TI\x08IN\x08NG\x08G '
 'B\x08BU\x08UG\x08GS\x08S\r\n'
 '       GNU coreutils online help: '
 '<https://www.gnu.org/software/coreutils/>\r\n'
 '       Report any translation bugs to '
 '<https://translationproject.org/team/>\r\n'
 '\r\n'
 'S\x08SE\x08EE\x08E A\x08AL\x08LS\x08SO\x08O\r\n'
 '       s\x08sl\x08le\x08ee\x08ep\x08p(3)\r\n'
 '\r\n'
 '       Full documentation <https://www.gnu.org/software/coreutils/sleep>\r\n'
 "       or available locally via: info '(coreutils) sleep invocation'\r\n"
 '\r\n'
 '       Packaged by Gentoo (9.3-r3 (p0))\r\n'
 '       Copyright (C) 2023 Free Software Foundation, Inc.\r\n'
 '       License  GPLv3+:  GNU  GPL  version  3  or  later  '
 '<https://gnu.org/li-\r\n'
 '       censes/gpl.html>.\r\n'
 '       This is free software: you are free to change and redistribute it.\r\n'
 '       There is NO WARRANTY, to the extent permitted by law.\r\n'
 '\r\n'
 'GNU coreutils 9.3                 April 2023                          '
 '_\x08S_\x08L_\x08E_\x08E_\x08P(1)\r\n')
self       = <metakernel.tests.test_replwrap.REPLWrapTestCase testMethod=test_bash>

/tmp/portage/dev-python/metakernel-0.29.5/work/metakernel-0.29.5/metakernel/tests/test_replwrap.py:31: AssertionError
@mgorny
Copy link
Author

mgorny commented Jul 11, 2023

Apparently this is related to groff-1.23.0.

@alejandro-colomar
Copy link

Maybe you want to read grotty(1):

   Legacy output format
     The  -c  option  tells  grotty to use an output format compatible
     with paper terminals, like the Teletype machines for  which  roff
     and  nroff  were  first developed but which are no longer in wide
     use.  SGR escape sequences are not emitted; bold, italic, and un‐
     derlining character attributes are  thus  not  manipulated.   In‐
     stead,  grotty  overstrikes, representing a bold character c with
     the sequence “c BACKSPACE c”, an italic character c with the  se‐
     quence  “_  BACKSPACE  c”,  and  bold italics with “_ BACKSPACE c
     BACKSPACE c”.  This rendering is inherently  ambiguous  when  the
     character c is itself the underscore.

     The  legacy output format can be rendered on a video terminal (or
     emulator) by piping grotty’s output through ul(1), which may ren‐
     der bold italics  as  reverse  video.   Some  implementations  of
     more(1) are also able to display these sequences; you may wish to
     experiment  with  that  command’s -b option.  less renders legacy
     bold and italics without requiring options.  In contrast  to  the
     terminal  output  drivers  of  some  other  roff implementations,
     grotty never outputs reverse line feeds.  There is  therefore  no
     need to filter its output through col(1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants