2022-01-10 20:22:17 +01:00
|
|
|
.POSIX:
|
2022-04-23 13:08:40 +02:00
|
|
|
.PHONY: test e2etest unittest crontest pre-clean clean
|
2021-11-09 21:25:41 +01:00
|
|
|
|
2022-01-10 20:22:17 +01:00
|
|
|
#
|
|
|
|
# On systems where Python 3.x binary has a different name, just
|
|
|
|
# overwrite the name/path on the command line, like:
|
|
|
|
#
|
|
|
|
# make test PYTHON=/usr/local/bin/python3.8
|
|
|
|
#
|
|
|
|
# This marco is passed via environment to test/e2e_test.py, where it's
|
|
|
|
# used to compute further commands.
|
|
|
|
#
|
|
|
|
PYTHON = python3
|
|
|
|
|
2022-04-23 13:08:40 +02:00
|
|
|
TEST_DB = test/lacre.db
|
|
|
|
|
|
|
|
#
|
|
|
|
# Main goal to run tests.
|
|
|
|
#
|
|
|
|
test: e2etest unittest crontest
|
|
|
|
|
2022-01-09 21:00:51 +01:00
|
|
|
#
|
|
|
|
# Run a set of end-to-end tests.
|
|
|
|
#
|
|
|
|
# Test scenarios are described and configured by the test/e2e.ini
|
|
|
|
# file. Basically this is just a script that feeds GPG Mailgate with
|
|
|
|
# known input and checks whether output meets expectations.
|
|
|
|
#
|
2022-04-23 13:08:40 +02:00
|
|
|
e2etest: test/tmp test/logs pre-clean
|
2021-11-09 21:25:41 +01:00
|
|
|
$(PYTHON) test/e2e_test.py
|
2021-11-11 10:57:00 +01:00
|
|
|
|
2022-04-23 13:08:40 +02:00
|
|
|
#
|
|
|
|
# Run a basic cron-job test.
|
|
|
|
#
|
|
|
|
# We use PYTHONPATH to make sure that cron.py can import GnuPG
|
|
|
|
# package. We also set GPG_MAILGATE_CONFIG env. variable to make sure
|
|
|
|
# it slurps the right config.
|
|
|
|
#
|
|
|
|
crontest: clean-db $(TEST_DB)
|
|
|
|
GPG_MAILGATE_CONFIG=test/gpg-mailgate-cron-test.conf PYTHONPATH=`pwd` $(PYTHON) gpg-mailgate-web/cron.py
|
|
|
|
|
|
|
|
$(TEST_DB):
|
|
|
|
$(PYTHON) test/schema.py $(TEST_DB)
|
|
|
|
|
|
|
|
# Before running the crontest goal we need to make sure that the
|
|
|
|
# database gets regenerated.
|
|
|
|
clean-db:
|
|
|
|
rm -f $(TEST_DB)
|
|
|
|
|
2022-01-09 21:00:51 +01:00
|
|
|
#
|
|
|
|
# Run unit tests
|
|
|
|
#
|
|
|
|
unittest:
|
|
|
|
$(PYTHON) -m unittest discover -s test
|
|
|
|
|
2021-11-11 10:57:00 +01:00
|
|
|
pre-clean:
|
|
|
|
rm -fv test/gpg-mailgate.conf
|
2022-01-06 16:23:10 +01:00
|
|
|
rm -f test/logs/*.log
|
2021-11-11 10:57:00 +01:00
|
|
|
|
|
|
|
test/tmp:
|
|
|
|
mkdir test/tmp
|
|
|
|
|
|
|
|
test/logs:
|
|
|
|
mkdir test/logs
|
|
|
|
|
|
|
|
clean: pre-clean
|
|
|
|
rm -rfv test/tmp test/logs
|