acli's tests integrated; all tests passing on Linux/Windows

Richard <legalize-aS9lmoZGLiVWk0Htik3J/[email protected]> Mon, 24 Apr 2023 10:13:35 -0600
Newsgroups gmane.network.trn.general
Organization multi-cellular, biological
Message-ID <[email protected]>
Hi Team,

I've integrated my changes on top of acli's UTF8 improvements and
migrated all of acli's tests to gtest.  I've added some more tests of
my own as well.

I've been building under WSL to check the linux configuration.  Trn's
code is so old that it predates linux and comes from that time in unix
history when every unix was a little bit different and POSIX system
calls hadn't yet been standardized.  Later, linux adopted a POSIX API
but deprecated some system calls like gtty/stty.

Linux also pretends to have both <termio.h> and <termios.h>, but if
you examine <termio.h> it tells you to use the <termios.h> header
instead.  So I have removed all conditionally compiled code for
gtty/stty and <termio.h> and left only the <termios.h>/MSDOS branches.
However, I think something in there was enabling raw output on MSDOS
because now I see raw ESC codes in the Windows console instead of the
codes applying effects :).  That's probably not a big deal to fix, but
I haven't fixed it yet.

Using CMake's configure_file to generate test file inputs has a nice
advantage that you can generate headers/source files from the smae
CMake variables.  That means that you can use symbolic names for test
data that should match instead of having magic values/strings that have
to be kept in sync between the test code and the test data files.
This turns out to be incredibly convenient for writing tests to cover
existing behavior in trn.  Usually when I write some covering tests
for existing behavior in trn I find a bug or two and fix it along the
way.

The cmake branch will probably be merged into master soon, now that
the build and tests are passing in both Linux and Windows.

I'm headed to Vegas this week, so probably no more progress until 2
weeks from now :)

Cheers,
-- Richard

Other progress:

- Added "string-algos.h": small, inline functions to manipulate
  character string pointers like "advance this pointer until it
  doesn't point at a delimineter character (e.g. space)".  This
  replaced a bunch of hand-written inline loops all over the code.

- Added tests to cover mimecap file parsing and documented some %
  interpolations that are applied to commands.  This isn't documented
  in the man page.  MIME type handling in unix has advanced
  considerably in the time that trn was last hacked upon; there's
  probably some considerable improvement that could be made for
  handling MIME types.

- putenv has some weird, inconsistent behavior when you try to delete
  a variable from the environment.  Trn would try to manipulate the
  environ global variable directly in order to effect a deletion, but
  this was giving me problems on Windows.  Also, documentation on both
  Windows and Linux really warns you against messing around with this
  variable directly and instead refers you to the functions
  getenv/putenv for manipulating environment variables.  Much of trn's
  code is influenced by the presence or absence of environment
  variables, so the platform-specific nature of putenv was making for
  fragile tests.  A std::function<> seam was inserted to decouple trn
  directly from the environment and allow the test code to insert a
  mock environment.  See tests/trn/mock_env.h for details of how this
  works.

- Added a submodule for vcpkg to prepare for github build/test
  workflows.

- I got a test article from a user that experienced a crash in trn,
  but haven't had a chance to see if I could reproduce the problem.
  It's from a binary newsgroup and contains a big yenc encoded body.
  There's no existing yenc support in trn and the 8-bit characters in
  the body are probably confusing it in some way.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
             The Terminals Wiki <http://terminals-wiki.org>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>