This is another preparation patch towards the transition to pytest where
testsuite support code is accessed through fixtures, rather than imports.
Having the equivalent of this information available as a property rather
than a global means we have access to this information though the "testcase"
object, something that works both with the current testsuite framework
and with the future pytest-based testsuite framework.
Note that the changes in the testcases themselves have been semi-automated.
I started with...
$ cd testsuite/tests
$ perl -pi -e 's/TEST_DIR/testcase.work_dir/g' */run_test.py
And then fixed up by hand the 30 testcases or so which had failures
in them. For the most part, it was about removing the import of
TEST_CASE, which had been replaced by an import of testsuite.work_dir.
TN: U530-006
Change-Id: I154dd58832dc10909623b869c488aa39edaf4c2d
This import is no longer used by any testcase, and can be removed.
This ensures we don't re-introduce calls to this function in the future.
This is part of the transition of the testsuite to pytest, where
testcase should not be changing the global environment (such as
the current working directory).
TN: U530-006
Change-Id: I13b0f4882295ad5980c92c0ee726d48614448284
This is another preparatory step towards being able to remove
the remaining calls to "cd" in our various testcases (something
that we cannot do once we transition to pytest, as it changes
the global environment).
Since the vast majority of commands being run by our testcases
are git commands to be run inside the non-bare repository,
this commit adjusts the TestCase._run method such that, if
a specific cwd is not specified, then run the command from
the directory of the non-bare repository.
TN: U530-006
Change-Id: I00d0685e02da24d83f652b035d37479eff310b1f
The purpose of this change is to help avoid the same code being
duplicated in the testcases themselves.
No testcase is changed to use this, yet, but some followup commits
will.
Found while working on the transition to pytest, where we'll need
to avoid changing the global environment, which means we'll need
to be more explicit about directories (avoid changing the working
directory, and/or avoid assuming what the current working directory
is).
TN: U530-006
Change-Id: Ieb90bd3c1ae09a8261ac88322c87a2ab6f8ec35f
The purpose of this change is to allow us to change the semantics
when calling testcase.run, by implementing these slight semantic
changes in that new method.
The ulterior goal of this change is to change the directory we run
commands from when the "cwd" parameter is None, changing it from
the current working directory, to the the directory where the test
repository is used. From there, we'll then be able to remove most
of the calls to "cd", something we have to do as part of the transition
of this testsuite to pytest.
TN: U530-006
Change-Id: I8ea69363aac28e1cbc4886dd387a191fd0f4bd03
The goal of this commit is to factorize the code in a few of
the testcases that computes the path to the testcase's bare
repository. That way, the reference to TEST_DIR, a global variable
that we're planning on eliminating in favor of a TestCase attribute,
gets factorized in the TestCase class, outside of the testcases.
Done while working on the testsuite transition to pytest (itself also
part of the transition to Python 3.x.
TN: U530-006
Change-Id: Ib47b02a8f9eccc54ad13332786e560203fb7b80e
This method should no longer be used, as it has unwanted side-effects.
Now that the testsuite is free of it, this commit removes it.
TN: U627-007
Change-Id: I0e405fb25563816fd3615d39fbbfd3560ea76bcb
This commit adds a new method to the TestCase class used by
the testsuite whose goal is to facilitate the calling of a script
which can then perform unit testing as a separate process from
the testcase's process.
This is preparation work for the transition out of gnatpython
(Python 2.x only) and towards pytest, where all the testing is done
within the same process. When that happens, changing globals such as
the environment should not be done, as the changes would cause
side-effects with other testcases that are run concurrently.
The "logger_error" is then re-implemented using this new method.
This allows us to greatly simplify this testcase as we don't have
to work so hard at creating a scenario resulting in a call to
the "syslog" function. As it happens, the scenario that we used
for this testcase involves some code which we want to get rid of
(now OBE), and the few other locations where "syslog" is called
do not lend themselves to traditional testing (those are current
covered via unit testing too).
TN: U627-004 (remove support for $HOME/.no_cvs_check)
TN: U627-007 (avoid changing testsuite environment in testcase)
TN: U530-006 (transition to Python 3.x)
Change-Id: I8f47dc4bc877387d52edddbcde10dd14a49b9b6b
This commit introduces a new run attribute in our testsuite's
TestCase class as a way to allow testcases to call this method
instead of instantiating the Run class. All testcases are then
modified to use this method, by running the following perl
command:
$ cd testsuite/tests
$ perl -pi -e 's/\bRun\(/testcase.run(/g' **/run_test.py
The testcases are then modified to remove the unused import using
the following perl command:
$ perl -pi -e 's/\s+Run,//g' **/run_test.py
The goal is to help the transition to pytest, where the testcases
will be using the "run" method to call external commands such as
Git. The difference is that the pytest version of this method
will do more than being a simple wrapper (e.g. it will take care
of the default working directory).
TN: U530-006
Change-Id: I1823ef4331d8d16da6cf5f4a4efdbb667c68848d
This commit updates the pre-commit hook to black version 21.5b1.
The hooks where then re-run on all files to update their formatting
to this new version of black.
Change-Id: Ib0866745ef8432cf93380a4d83fa23a479eb4a49
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
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
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
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.
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.
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.
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.
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.