The goal of this commit is to include the updates.sendmail module
in our testing strategy, in order to make sure that the hooks are
passing email data down to the sendmail program without issues.
This will become particularly important when we switch over to
using Python 3.x, because of the strong distinction between bytes
and strings with newer versions of Python which can cause a lot
problems. Hence the need to use this code during our testing.
The main strategy introduced by this commit to achieve this is
fairly simple: The testsuite framework introduces a new minimal
script to be called in place of the standard sendmail. A new
environment variable called GIT_HOOKS_SENDMAIL is introduced
allowing the testsuite to tell the hooks to use its own (fake)
sendmail instead of the system one. With that in place,
the old code bypassing the use of updates.sendmail can be removed,
thus allowing the testsuite to include it as part of the testing.
The testsuite's (fake) sendmail script was written in a way to
mimick the old bypassing code, so there is no change in output.
Parallel to that, the hooks are enhanced to check that we can
indeed find sendmail, and otherwise return immediately with
an error if not. This way, we avoid emails silently being
dropped due to the missing sendmail.
A couple of testcases are also added to double-check some
specific error situations.
Note that I tried to think of ways to split this patch into
smaller individual parts, but couldn't really find a way to
do so in a meaningful way, while at the same time producing
a commit where the coverage report stays clean (0 lines missed).
TN: U530-006 (transition to Python 3.x)
TN: U924-032 (test for sendmail not found)
TN: U924-034 (test for sendmail override when in testsuite mode)
Change-Id: I74b993592ec6d701347bbca5283a42e037411f1c
As part of the transition to Python 3.x, we will start adding some code
which should only be executed when running the hooks using Python 3.x.
In the meantime, until the testsuite gets transitionned to Python 3.x,
we still want the coverage report for Python 2.x to remain clean, so
this commit adds a new exclude line to the default one: Any line with
"pragma: py3-only" should now be excluded from the coverage report.
As for the future, what we will do when the transition to Python 3.x
actually happens, is change the config again to exclude lines marked
"py2-only" (or remove the Python-2.x-only code directly, if that makes
better sense).
TN: U530-006
Change-Id: I67a1fe27dbfe614c1dba5176d78f1d8d1fe9cd35
The coverage.sh script creates a coverage.rc file, but this file wasn't
actually used during coverage generation. This change makes sure that
it is.
For now, this shouldn't make any difference, but this will help us
later for providing additional options during report generation
(in particular, it will allow us to add coverage exclusion patterns,
which will become handy to exclude code which is only meant to be
executed with a given version of Python).
TN: U530-006
Change-Id: Ifbba6dfb9a9347f7d5680b6cc464378282653813
The coverage report was only taking into account the modules
defined in GIT_HOOKS_DIR, while we started creating submodule
hierarchies. This change expands the coverage analysis to
these new modules and submodules.
Move the module-list computation to after running the testsuite.
This way, we know if there are any failures sooner rather than
later.