22 Commits

Author SHA1 Message Date
Joel Brobecker
8b5d28174e Remove all imports of __future__.print_functions in the testsuite
This commit is the result of running the following command in
the testsuite/ directory:

   $ sed -i '/^from\s\+__future__\s\+import\s\+print_function\s*$/d' \
       `git grep print_function | cut -d: -f1 | sort -u`

Change-Id: Idb18a24f5368434a505af42b347b8f2a1d0481b5
TN: U530-006
2021-11-30 17:58:55 +04:00
Joel Brobecker
4b927b0a45 Remove remnants of old Python-2.x-based testsuite framework
Now that the hooks are Python 3.x-only, and that we have a new framework
to run the testsuite with Python 3.x, delete the old Python-2.x-based
testsuite framework.

Change-Id: If8f72a3a8f747f768f673dcca42c63f592ee57f7
TN: U530-006
2021-10-19 13:18:07 -07:00
Joel Brobecker
1b26ad75f0 testsuite/bin/stdout-sendmail: Parse email before printing
This script, which is used as a replacement for sendmail when
running the testsuite, has two modes. In the default mode,
it currently does nothing more than dumping to standard output
the email being asked to send.

This commit changes the script to parse the email instead, and
dump its contents once parsed, rather than dumping the email
as is. The dumping is written so to keep the output the same.

The goal is to help print the email body in a human-readable way
regardless of its content transfer encoding. This will become
particularly useful when we start using base64 content transfer
encodings.

This is tied to the transition to Python 3.x, where the email
support classes automatically chooses base64 transfer encoding
in some cases. More generally speaking, we have plans to use
base64 more often, as this format ensures that we do not exceed
some limitations in email transport (maximum line length, for
instance).

TN: U530-006
Change-Id: I645126470e8a3b944ff668aba6d30381d418c6b1
2021-10-04 08:14:13 -07:00
Joel Brobecker
f18c10b78c stop bypassing the updates.sendmail module during testsuite runs
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
2021-09-24 17:41:10 -07:00
Joel Brobecker
779602b325 testsuites/bin/{pack,unpack}-test-repos: Remove use of gnatpython.ex.Run
This commit removes another use of gnatpython in the testsuite, this time
eliminating the use of gnatpython.ex.Run, using the equivalent Popen class
instead. With Python 3.x, we would be able to write this a bit more simply
thanks to the "subprocess.run" function, but we are are to ready to drop
support for Python 2 yet, so we implemented this in a way that works with
both Python 2 and Python 3.

Change-Id: I9a1e9c0ece11de4ce5001d052cffc20ac97bd566
TN: U530-006
2021-06-04 13:46:52 -07:00
Joel Brobecker
6cc7fe71d3 replace gnatpython.file.mv by shutil.rmtree
This is another step towards moving away from gnatpython, which is
only available with Python 2.x. In this case, it was really
straightforward to use shutil.rmtree.

Change-Id: Idab48884e7e7072f8d0a7f64f196270424bc5ec6
TN: U530-006
2021-06-04 13:29:33 -07:00
Joel Brobecker
54877f91a3 testsuite: change the testcase filename from "test.py" to "run_test.py"
This is a small step towards migrating this testsuite towards
a pytest-based framework: The filename currently used for testcases
is "test.py", and that filename does not match the nomenclature
that pytest expects for testcase files. So this commit renames
all our testcases to something that pytest can identify as a testcase
file to load and execute, and then adjusts the current testsuite
framework accordingly.

Change-Id: I77fba65e8ea20612259c6ad10459fe96ef77a2fc
2021-04-18 18:57:38 +04:00
Joel Brobecker
a075b1653e reformat all the code using black
Change-Id: Idbc70777233ab2d40ab59765abb9cbbeeb88ec63
2021-04-18 14:59:01 +04:00
Joel Brobecker
50cbf3ad89 testsuite/bin/stdout-logger: Replace print statement by print function
This makes this part of the code compatible with both Python 2.x
and Python 3.x.

Change-Id: I5b6c7287750775ba2d3538df1e5129b0a17e50d7
2020-11-23 14:37:33 +01:00
Joel Brobecker
cf77ce5dc7 testsuite/bin/run-testcase: Use print function instead of print statement
This makes this part of the code Python-3.x compatible.

Change-Id: I6687436eb7428fa71aba108c261279bac8983c95
2020-11-23 14:09:30 +01:00
Joel Brobecker
b476291a83 testsuite/bin/unpack-test-repos: Fix (Python-3.x) flake8 violations
This commit fixes a number of violations reported by the Python-3.x
version of flake8.

Change-Id: Ie0e174fbd6afbcff6cf008e2a19db561355c5465
2020-11-23 14:09:18 +01:00
Joel Brobecker
35949ce78c testsuite/bin/pack-test-repos: Fix all (Python-3.x) flake8 errors
This commit fixes a number of flake8 violations reported by the Python-3.x
version of flake8.

Change-Id: I1db5c0491b6619ff99e45c15b848a5786317a363
2020-11-23 14:09:02 +01:00
Joel Brobecker
2ad4079bc8 Get the hooks' configuration from refs/meta/config:project.config...
... instead of the repository's config file.  For compatibility,
a fallback mechanism that falls back on reading the $GIT_DIR/config
file is provided.

For MC20-031.
2013-12-27 18:23:25 +04:00
Joel Brobecker
ad437bf477 Create project.config in refs/meta/config branch (from hooks_config).
We are still preserving the hooks_config file within the test
directory in order to help grep-ability, but this is no longer
the master.  The pack-test-repos script has been updated to grab
and update our convenience copy to match the latest master.

Similarly, the unpack-test-repos script has been updated to use
the project.config file (ie, use the master copy) to populate
the bare repository's config file. It is expected that this part
will become unnecessary at some point, when the hooks are enhanced
to get their config from this file, instead of the repository's
config file.

For MC20-031.
2013-12-27 15:44:02 +04:00
Joel Brobecker
0c02d4bb4a Split the bare repository's config into two: git config vs hooks config.
This is a first step towards moving the hook's configuration
inside the repository itself.

For MC20-031.
2013-12-27 13:28:00 +04:00
Joel Brobecker
0acd221057 Fix error in testsuite/bin/pack-test-repos.
There was an obvious (as in untested) error in the computation
of the path where the bare repository's config file was located.
This patch fixes it.
2012-12-28 16:21:32 +04:00
Joel Brobecker
6157951a8f syslog trace if .no_cvs_check file turns pre-commit checks off.
Update testsuite infrastructure to allow testing of syslog tracing
without actually filing a real syslog trace.

For L605-020.
2012-12-27 19:54:25 +04:00
Joel Brobecker
05d8354321 Move testscase bare/repo.git config file out of git-repos.tar.bz2.
This improvement allows us to track the config file normally,
instead of having it tracked as part of a (very binary) tarball.
2012-12-26 12:37:17 +04:00
Joel Brobecker
397334cfd6 Add support for testing pushes to non-bare repositories
Needed for LB24-002.
2012-11-24 11:37:48 -08:00
Joel Brobecker
8b7cffac64 pack-test-repos: pack everything from the "bare" directory...
... not just the bare/repo.git directory.  That way, we can have
multiple bare repositories.  This can be useful in the context of
git submodules, where multiple git repositories are in use.
2012-06-14 14:40:48 -07:00
Joel Brobecker
395ea0c909 Use tarballs to store the testcases' git repositories.
The current approach was not working, because it is hard to check in
a complete bare repository.  Also, checking git repositories had the
disadvantage  that the git repositories always contain a LOT of files,
flooding the other changes with those changes. It is easier in all
counts to just use an archive.

This does not fix the testcases themselves, but the checked in versions
do not work anyway, it doesn't make things worse in practice.
2012-05-26 11:22:46 +02:00
Joel Brobecker
b3e4989925 Move testsuite/run-test to testsuite/bin/run-testcase.
Adjust new run-testcase accordingly (mini-adjustment).
Update call from testcase/lib/testsuite.py.
2012-05-26 11:22:46 +02:00