This commit adds support for C++ files, which were previously
not recognized (unless they used C file extensions). The same
checks as for C files are applied, in fact, the same checker
is used for both.
Change-Id: Ic98a68530b4cb280ef2846e282511e3c7e550c25
TN: W105-011
The run-validation-tests has a pre-testing phase where it verifies
that all necessary dependencies for running the testsuite without
error are present. One of those checks is the list of Python modules
being installed, which we get by calling pip3, asking for the list
in JSON format.
This commit avoids a testsuite crash when the version of pip being
installed is not the latest one:
| $ ./run-validation-tests
| Traceback (most recent call last):
| [...]
| File "/[...]/./run-validation-tests", line 117, in check_dependencies
| package_list_from_pip3 = json.loads(p.out)
| [...]
| raise JSONDecodeError("Extra data", s, end)
| json.decoder.JSONDecodeError: Extra data: line 3 column 1 (char 5379)
The error happens because pip added the following warning
after the JSON output:
| $ pip3 list --format=json
| [JSON data snipped]
|
| [notice] A new release of pip available: xxxx -> yyyy
| [notice] To update, run: python -m pip install --upgrade pip
This commit avoids this issue by telling pip3 to not do a version check.
Found while working on W105-011.
Change-Id: I00cfd6203d113c28e6ddb2991d6eae3834308f8b
We had a situation where the style_check incorrectly thought that
a .txt file was a Python file, and thereore activated the corresponding
checkers, leading to a spurious error. This comes from the fact that,
by default, we use the "file" command to analyze files whose extension
we don't explicitly already recognize. The problem, here, is that "file"
returns something unexpected, leading us down the wrong path.
Since I don't see a .txt extension being used for anything but pure
text files, it seems reasonable to recognize those explicitly and
then disable all style checks on those.
Change-Id: I1377647f727b9d1e7cf00d04e15ad574536f1050
TN: V614-013
This commit upgrades the pre-commit checks to using newer versions
of black and flake8. The code was then reformatted with this new
version of black.
Change-Id: I146b6529c0c4521266367cda5a4a55cfc7d8f054
distutils.version is deprecated, unfortunately, so this commit
changes the testsuite to use packaging.version instead.
Change-Id: I2140eb72d0f2e5221586bcd7e666cc15a1728ef9
This commit adds -vv to the list of command-line arguments we pass
to pytest when running the testsuite. This doesn't change anything
when the test is successful, but increases the amount of information
being provided when a test fails. In particular, when a string equality
test fails, it'll show the whole diff, rather than just an abbreviated
version of the expanded strings. Without this, if the strings are
are a few lines long, it becomes impossible to diagnose the issue
just from the testsuite report alone.
Change-Id: I5ecdbb3a9badf12f33ea9fd1091f6e170310492c
In V103-009, I updated the list of valid copyright holders
to add a couple more names, but clearly I forgot to run
the testsuite, because this of course causes some changes
to the style_checker's output when a file should have a valid
copyright, but does not.
This commit fixes that omission, allowing us to get clean testing
again.
Change-Id: I652d88d81cb91c04126cb0fc00219ab1fb1a85e0
TN: V103-009
For Ada runtimes, we were relying on -gnatg to imply -gnatX
to allow GNAT extensions in those files. However, this isn't
always the case, so this commit changes the style_checker to
always call the compiler with -gnatX when checking a file
that's identified as a GNAT runtime file.
Change-Id: I913417e4b70b4cd13925b6f3b95887562a678bee
TN: UB09-015
A new rule is added to reject certain unicode characters that
an attacker could use to exploit the Unicode Bidi algorithm
and construct source code that would appear innocuous when rendered
in an editor, but that would actually contain malicious code.
This new rule is applied to all files which are known by
the style_checker to be a programming language.
Change-Id: Ic0e4a7d17d316effcfe9c74ef5b57b8bcf5b1779
TN: UB03-053
This commit fixes a small thinko: The "env_setup" fixture creates
a temporary directory, and then creates inside that temporary
directory two more subdirectories: A "tmp" directory, and an "src"
directory. The intent for that "src" directory was to be the working
directory inside which the testcase's sources would be copied and
the testcase itself be run.
The problem is that we os.chdir-ed to the temporary directory,
rather than the "src" subdirectory inside that temporary directory.
As a result, the testcase ended up not using our "src" subdirectory
at all. It's cleaner to run our testcase in that "src" subdirectory
because it is guaranteed to be empty at the time we copy the testcase's
sources over, so this commit fixes this issue by chdir-ing to
the "src" subdirectory.
Change-Id: I4047d805a7c658faee0cb8bc4f5094ae5110d61e
Up until recently, having unique filenames for the testcases was
required by pytest due to the way pytest was called and the testsuite
architected. But now that we're using --import-mode=importlib,
there is no such limitation anymore. So this commit renames all
current testcase scripts to a simpler, shorter and more consistent
"run_test.py".
For the record, the shell command used to do the renaming was:
for i in */test_*.py; do
tc_dir=`echo $i | cut -d/ -f1`
git mv $i ${tc_dir}/run_test.py
done
Change-Id: If8592e7812a2d8549d8c35a2272e93725f21377d
... and abort the testing if this testing returned some errors.
Basically: We know that we're going to have to fix any style
violation found, which means modifying the code, which in turn
means we'll need to re-run the testsuite anyway. Might as well
just abort the testing early... Users who still want to do
the testing regardless of style violations can always bypass
this via --no-style-checking.
Change-Id: I2c68420243f36222a7f5a95102a20ca725b18d15
Now that we have the pre-commits configured to use a variety of
tools, re-use this to perform the style conformance testing.
This commit also adapts the list of required Python packages
accordingly.
Change-Id: Ie908ee9934c3dcda407890f0e33e98985920a4f0
This allows the files used as part of the testsuite's framework to
still be covered by the precommit-check.
Change-Id: I195842105d85e43e4f27ba4ce615c383bb5d91fa
This commit simply runs "black" on all our Python files except
those in testsuites/tests/.
Note that I ran into one small difficulty when reformatting setup.py,
where black was reformatting a couple of lines in the code in a way
that it triggered the following E231 flake8 violations:
setup.py:23:69: E231 missing whitespace after ','
setup.py:25:74: E231 missing whitespace after ','
This is a known issue with black...
https://github.com/psf/black/issues/1288
... which is fortunately easily worked around by simply removing
the offending comma (black does not add it back).
Change-Id: I492eb1ca5fa371d063e691f7fe06c47daae60d4c
That way, we do not have to hardcode the list of rules that flake8
ignores by default just so we could add our own list of extra ignores.
This also brings the ignore list in line with what AdaCore's style_check
does.
Change-Id: I717e2918dd23a46440e96b2319129cddd23df8f9
Instead of checking for the "coverage" executable as a roundabout way
to check if the "pytest-cov" pluggin has been installed, just use
the new pip3-based mechanism. It brings this check in line with
the check for the pytest-xdist plugin.
Change-Id: Ie020b63078d87b356038eeba92b9f107563729f6
This commit sorts the list of required_packages in alphabetical order,
so as to make it easier and faster to scan it when looking for
a specific entry.
Change-Id: I91e1d187dd86ff6b1318b922197c09817be11b3c