mirror of
https://github.com/AdaCore/git-hooks.git
synced 2026-02-12 12:43:11 -08:00
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
18 lines
828 B
Bash
Executable File
18 lines
828 B
Bash
Executable File
#! /usr/bin/env bash
|
|
#
|
|
# A small wrapper around our stdout-sendmail program which unsets
|
|
# COVERAGE_PROCESS_START prior to calling it. The purpose is to disable
|
|
# code coverage prior to calling this script, because leaving it enabled
|
|
# causes a fatal error while trying to save the coverage data into a file
|
|
# at the end of the script's execution (during the atexit call). The error
|
|
# comes from the fact that the git-hooks daemonizes the execution of
|
|
# the call to sendmail, which results in the process changing its current
|
|
# working directory to /, and thus causes the coverage module to think
|
|
# that it should save its coverage data files there, resulting in
|
|
# an IOError:
|
|
#
|
|
# IOError: [Errno 13] Permission denied: '/.coverage.xxx.189363.572044'
|
|
|
|
unset COVERAGE_PROCESS_START
|
|
python -u `dirname $0`/stdout-sendmail "$@"
|