Commit Graph

29 Commits

Author SHA1 Message Date
Simon Marchi
a2909b2c8d Convert print statements to print function
In preparation for the transition to Python 3, convert to using the
print function.  The special import

    from __future__ import print_function

in Python 2.7 makes "print" become the function and not the statement.
In Python 3, it has no effect.  Once the transition is done and we
exclusively use Python 3, we can simply remove the imports.

The testsuite shows no regressions.
2020-11-22 19:29:38 -05:00
Joel Brobecker
1de3eb14c7 Add support for new config option hooks.commit-extra-check
This option allows projects to ask the git-hooks to perform custom
checks of any kind to validate every new commit being pushed.

This commit also contains a change in hooks/updates/emails.py which
enhances the email-sending debug tracing mechanism used by the testsuite,
adding support for a tracing mode where the traces are just one line
per email. Technically, this change is independent from the rest,
but it is merged with this commit nonetheless because these changes
would show up as uncovered by the testsuite without the testcases
we're adding here. That way, we maintain the principle that we always
have 100% testing coverage for any commit.

Change-Id: I0e446a95d05f5578f977af3eaa547144187eb86b
TN: T209-005
2020-07-19 19:38:58 -07:00
Joel Brobecker
05636d6c06 Remove gnatpython.fileutils wildcard import in testsuite/lib/support.py
Just import the one symbol that's actually used by the various
testcases in its place. This allows us to pass all current
style checks at AdaCore for Python files.

Change-Id: I458060771e18684e097e98131f292e09690a2e6d
2020-06-15 11:32:45 -07:00
Joel Brobecker
847eca781b [testsuite] do not ignore whitespaces when computing diffs
When a test wants to verify the output of a given command, it normally
does this as follow:

    self.assertRunOutputEqual(p, expected_out)

What this does is verify that the command's output matches, and if it
does not, then it not only reports and error, but also provides a diff
at the end, so as to facilitate the analysis.

However, while writing a test where that was unexpected failing
an output comparison, the diff in the error message was empty.
After investigation, it turned out that the function used to compute
that diff has a parameter ignore_white_chars set to True, which is
not what we want, here, and explains the discrepancy.

This commit fixes that by explicitly setting that parameter to False.
In the situation described above, this allowed the difference to
be shown in the diff section.

Change-Id: Ie5df10bcd7990eab928fc6f7fed3f41eaaa5d469
2020-06-15 11:32:45 -07:00
Joel Brobecker
8fb4f9ee34 Fix setting of GIT_HOOKS_STYLE_CHECKER
Do not use os.getcwd to compute the testcase's directory, as one
testcase may have multiple tests, and each test might do a "cd",
thus modifying the current working directory and thus affecting
the next testcase. Luckily, we have TEST_DIR already, so we might
as well use that.
2016-11-01 07:43:16 -07:00
Joel Brobecker
db894bf25c Use hard-coded git user name and email config during testsuite.
This is to make sure that, we the testsuite creates new commits,
the author name and email do not depend on the user who is runing
the testsuite.
2014-12-21 15:25:05 -05:00
Joel Brobecker
73db3edef6 testsuite/lib/support.py: pep8 violation fixes. 2014-12-21 15:25:05 -05:00
Joel Brobecker
461fec9660 testsuite/lib/support.py: Remove unused imports. 2013-12-30 14:27:45 +04:00
Joel Brobecker
153fbe32fc lib/testsuite: Remove Env import. Not used. 2013-12-30 14:24:56 +04:00
Joel Brobecker
50fd97b3e6 testsuite: Print summary at end of testsuite run. 2013-12-30 14:24:21 +04:00
Joel Brobecker
62500a702c Avoid use of "cvs_check" in favor of "style-checker" wherever possible.
Since we're about to allow the use of an alternate style-checker,
and since the name "cvs_check" contains the name of an old technology
we abandonned many years ago, it seems like a good idea to introduce
a more neutral name for that tool.

There is one, non-upward-compatible user-visible change: The script
now uses the GIT_HOOKS_STYLE_CHECKER environment variable, instead
of the GIT_HOOKS_CVS_CHECK environement as a backdoor to specifying
an alternate style-checker.  This should be OK, however, as this
feature was really only meant to be used during testing, and is,
in practice, only really usable in that context.

This is prep work before introducing a new config option allowing
the repository to use an alternate style checker.

Part of MA09-043.
2013-10-11 16:42:57 +04:00
Joel Brobecker
cca0aa4e14 Revert "Make sure the info/attributes file is group-writable."
It turns out that making info/attributes group-writable is not
sufficient: A second user is allowed to overwrite the file, but
then the hooks fail when trying to change the file permissions
to make it group-writable.

We will use a different approach which should not need this anymore.

Part of M116-004.
2013-01-18 07:27:23 +04:00
Joel Brobecker
fc20bd3285 Make sure the info/attributes file is group-writable.
A user needs to be able to overwrite this file, so we make it
group-writable.

Update the testsuite to verify this requirement for both
a repository's .gitattribute file, as well as the bare
repository's default_attribute file.
2013-01-16 12:23:04 +04:00
Joel Brobecker
c5bfa403ac New method support.TestCase.assertRunOutputEqual
This method verifies that the output of a Run is equal to the given
expected output, and otherwise prints the command's image, actual
output, followed by a diff. The "diff" is the part that's new, and
allowed to quickly determine the difference, as the expected output
tends to be quite long in a typical test.

Update all testcases accordingly.
2012-12-28 07:04:10 +04:00
Joel Brobecker
f0b370bd9e New method support.Run.diff allowing us to print output diff...
... after printing the actual output. This allows us to spot
differences much faster.  Adjust branch_no_precommit_check to use it.
2012-12-28 06:31:38 +04:00
Joel Brobecker
719f83658d Add handing of small output differences from git version on kani.
kani provides version 1.7.8.2 while my laptop provides 1.7.10.4.
This patch helps provide testing support for both versions.
2012-12-26 12:11:02 +01:00
Joel Brobecker
731e1a59a7 testsuite/lib/support.py: Handle minor output variation with older git 2012-12-01 14:19:21 +04:00
Joel Brobecker
424208b426 testsuite/lib/support.py: Strip trailing spaces in command output.
See comment explaining why...
2012-12-01 10:45:22 +01:00
Joel Brobecker
3709fc2f95 Sanitize output from git commands run from testcase.
There is a trailing \033[K sequence (terminal control sequence
that tells the terminal to erase the end of the line) which seems
to be generated by git, and it makes matching the output a little
more difficult than necessary.  So we create a subclass of
gnatpython.ex.Run which provides an additional property containing
the santized output.

While at it, we also added another property which replaces the
ex_run_image function.

Update all testcases throughout.
2012-11-25 12:07:05 +01:00
Joel Brobecker
eb0ceffa5d New TestCase.set_debug_level method.
Use that to set the debug level rather than requiring the testcase
to know how to set it.

Update all testcases accordingly.
2012-11-25 11:04:54 +01:00
Joel Brobecker
5061b7c75d Add verification that our scripts do not leak any temporary file.
This patch forces the scripts to use a specific directory as the root
for their own temporary directories/files. We create it as an empty
directory at the start of the testcase, and then verify at the end
that it is still empty. If not, the testcase will report a failure.

This patch also makes sure that, even if the scripts do leak some
files/directories, the testsuite catches those and deletes them.
2012-11-24 10:56:03 -08:00
Joel Brobecker
e729a670bf Merge the AbstractRefChange class into the updates.AbstractUpdate class.
This finally merges the two parallel infrastructures defined in
post_receive.py and the update modules+sub-modules.  This allows
us to treat each type of update within its own module, rather
than having a gigantic post_receive.py file.  Also, every aspect
related to a given update is all handled within the same module.

There was a unit test for post_receive.py's AbstractRefChange,
which has now been replaced by the corresponding unit test for
class update.AbstractUpdate.  This also required a minor upgrade
of the unit-test infrastructure.

The changes should all be internal. There should be no user-visible
changes.
2012-11-22 18:47:27 -08:00
Joel Brobecker
55db2aa74c Introduce the post-receive hook.
This patch introduces the framework for a post-receive hook.
Currently, the hook only handles the creation of lightweight tags.
2012-06-25 12:49:57 -07:00
Joel Brobecker
8e8ee02cb5 Add new TestCase.enable_unit_test method.
Will be useful to help setup testcases that want to do some
unit testing.

See L614-038, for instance.
2012-06-14 15:17:24 -07:00
Joel Brobecker
3a213bf06e Minor cleanup: pass discs = None instead of [] to generate_run_testcase. 2012-06-10 10:19:03 -07:00