"make check" tests against both python2 AND python3

Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
This commit is contained in:
David A. Wheeler 2017-11-16 20:07:12 -05:00
parent 90269a2c75
commit 5f1b87ab51
2 changed files with 60 additions and 33 deletions

View File

@ -35,39 +35,21 @@ The DCO basically says that you assert that you're legally allowed to
provide the commit. Please include in your commit a statement of the
form to confirm this ("git commit -s" will do this):
> Signed-off-by: Your-name <your-email-address>
> Signed-off-by: Your-name \<your-email-address\>
You much include the DCO in your first commit proposal.
You must include the DCO in your first commit proposal.
If you forget occasionally, we'll assume that you just forgot, but
please try to not forget.
## Code Conventions
## Development environment setup
To make the program easy to install everywhere, the main executable
is exactly one self-contained file. That involves some compromises,
but for now, please keep it that way.
As always, if you're modifying the software, you'll need to have
your development environment set up. You need:
We generally use the code conventions of
[PEP 8](https://www.python.org/dev/peps/pep-0008/).
The Python code uses 4-space indents (we used to use 2-space indents).
Do not use tabs. In some cases the code doesn't yet comply;
patches to improve that are often welcome.
The code is currently Python 2, and is only tested on
the Python 2.7 series. Please don't make it hard to convert
to Python 3 when that eventually happens.
WE use "pylint" to check for style and other problems.
This is configured by the included "pylintrc" file.
We intentionally disable some checks as being "less important",
for example, the current code has many lines longer than 80 characters.
That said, patches to make lines fit in 80 characters are welcome.
We require that the pylint results for contributions be at least 9.5/10 as
configured with the provided "pylintrc" file, without any errors ("E").
Better is better. You can run "make pylint" to run this check.
The current version *does* cause some pylint reports
(patches to fix those are welcome!).
* make
* python2 (invokable as "python2")
* python3 (invokable as "python3")
* pylint (see below)
An easy way to install pylint is to use pip.
Most python installs have pip, but if yours does not
@ -83,10 +65,46 @@ Finally, you can actually install pylint using:
> pip install pylint
## Code Conventions
To make the program easy to install everywhere, the main executable
is exactly one self-contained file. That involves some compromises,
but for now, please keep it that way.
We generally use the code conventions of
[PEP 8](https://www.python.org/dev/peps/pep-0008/).
The Python code uses 4-space indents (we used to use 2-space indents).
Do not use tabs. In some cases the code doesn't yet comply;
patches to improve that are often welcome.
The code must run on both Python 2.7 and Python 3.
To check that it works on both, run:
~~~~
make check
~~~~
We use "pylint" to check for style and other generic quality problems.
To check that the code passes these quality tests, run:
~~~~
make pylint
~~~~
We require that the pylint results for contributions be at least 9.5/10 as
configured with the provided "pylintrc" file, without any errors ("E").
Better is better. The current version *does* cause some pylint reports
(patches to fix those are welcome!). Note that we configure pylint
with the included "pylintrc" file.
We intentionally disable some checks as being "less important",
for example, the current code has many lines longer than 80 characters.
That said, patches to make lines fit in 80 characters are welcome.
## Tests
Make *sure* that your code passes the automated tests. Invoke tests with
"make check".
Make *sure* that your code passes the automated tests.
As noted above, invoke tests with
"make check", which tests the code using both Python2 and Python3.
It's our policy that as major new functionality is added to the software
produced by the project, tests of that functionality should be added to
@ -94,5 +112,5 @@ the automated test suite.
## Other
We want to eventually earn a
[CII Best Practices Badge](https://bestpractices.coreinfrastructure.org/projects/323).
We have earned a
[CII Best Practices Badge](https://bestpractices.coreinfrastructure.org/projects/323)... make sure we keep it!

View File

@ -17,6 +17,8 @@ ARCH=noarch
SAMPLE_DIR=/usr/src/linux-2.2.16
PYTHON=python
PYTHON2=python2
PYTHON3=python3
# Flawfinder has traditionally used INSTALL_DIR, INSTALL_DIR_BIN, and
# INSTALL_DIR_MAN. Here we add support for GNU variables like prefix, etc.;
@ -183,13 +185,20 @@ test_007: setup.py
@test "`$(PYTHON) setup.py --license`" == 'GPL-2.0+'
@test "`$(PYTHON) setup.py --author`" == 'David A. Wheeler'
# Run all tests; output shows differences from expected results.
# Run all tests on *one* version of Python;
# output shows differences from expected results.
# If everything works as expected, it just prints test numbers.
# Set PYTHON as needed, including to ""
test: test_001 test_002 test_003 test_004 test_005 test_006 test_007
@echo 'All tests pass!'
check: test
# Usual check routine. Run all tests using *both* python2 and python3.
check:
@echo "Testing with $(PYTHON2)"
@PYTHON="$(PYTHON2)" make test
@echo
@echo "Testing with $(PYTHON3)"
@PYTHON="$(PYTHON3)" make test
# Run "make test-is-correct" if the results are as expected.
test-is-correct: test-results.txt