Tidy up tests

- Makefile: add 'unittest' to .PHONY targets.
- Remove unnecessary #! line from e2e_test.py.
- Extract Python path to test/e2e.ini file.
This commit is contained in:
Piotr F. Mieszkowski 2022-01-10 18:30:19 +01:00
parent 1e7d33c1df
commit 24f0c86d4f
3 changed files with 4 additions and 7 deletions

View File

@ -1,6 +1,6 @@
PYTHON = python3.8
.PHONY: test pre-clean clean
.PHONY: test unittest pre-clean clean
#
# Run a set of end-to-end tests.

View File

@ -31,6 +31,7 @@ certs: test/certs
[tests]
# Number of "test-*" sections in this file, describing test cases.
cases: 3
python_path: /usr/local/bin/python3.8
e2e_log: test/logs/e2e.log
e2e_log_format: %(asctime)s %(pathname)s:%(lineno)d %(levelname)s [%(funcName)s] %(message)s
e2e_log_datefmt: %Y-%m-%d %H:%M:%S

View File

@ -1,5 +1,3 @@
#!/usr/local/bin/python3.8
#
# gpg-mailgate
#
@ -32,8 +30,6 @@ from time import sleep
RELAY_SCRIPT = "test/relay.py"
CONFIG_FILE = "test/gpg-mailgate.conf"
PYTHON_BIN = "python3.8"
def build_config(config):
cp = configparser.ConfigParser()
@ -95,10 +91,10 @@ def execute_e2e_test(case_name, config, config_path):
test_command = "GPG_MAILGATE_CONFIG=%s %s gpg-mailgate.py %s < %s" % (
config_path,
PYTHON_BIN,
config.get("tests", "python_path"),
config.get(case_name, "to"),
config.get(case_name, "in"))
result_command = "%s %s %d" % (PYTHON_BIN, config.get("relay", "script"), config.getint("relay", "port"))
result_command = "%s %s %d" % (config.get("tests", "python_path"), config.get("relay", "script"), config.getint("relay", "port"))
logging.debug("Spawning relay: '%s'" % (result_command))
pipe = os.popen(result_command, 'r')