fix cmdeploy test command

This commit is contained in:
holger krekel 2023-12-11 14:05:07 +01:00
parent d70eb78a76
commit cdbda291c5
3 changed files with 22 additions and 14 deletions

View File

@ -24,15 +24,18 @@ jobs:
- name: initenv
run: scripts/initenv.sh
- name: append venv/bin to PATH
run: echo venv/bin >>$GITHUB_PATH
- name: run formatting checks
run: venv/bin/cmdeploy fmt -v
run: cmdeploy fmt -v
- name: run deploy-chatmail offline tests
working-directory: deploy-chatmail
run: venv/bin/pytest tests
run: pytest tests
- name: initialize with chatmail domain
run: venv/bin/cmdeploy init chat.example.org
run: cmdeploy init chat.example.org
# all other cmdeploy commands require a staging server
# see https://github.com/deltachat/chatmail/issues/100

View File

@ -15,6 +15,10 @@ dependencies = [
"termcolor",
"build",
"tox",
"ruff",
"black",
"pytest",
"pytest-xdist",
]
[project.scripts]

View File

@ -111,26 +111,20 @@ def status_cmd(args, out):
def test_cmd(args, out):
"""Run local and online tests.
"""Run local and online tests for chatmail deployment.
This will also pip-install 'deltachat' if it's not available.
This will automatically pip-install 'deltachat' if it's not available.
"""
tox = shutil.which("tox")
proc1 = subprocess.run([tox, "-c", "chatmaild"])
proc2 = subprocess.run([tox, "-c", "deploy-chatmail"])
x = importlib.util.find_spec("deltachat")
if x is None:
out.check_call(f"{sys.executable} -m pip install deltachat")
pytest_path = shutil.which("pytest")
proc3 = subprocess.run(
[pytest_path, "tests/", "-rs", "-x", "-vrx", "--durations=5"]
ret = out.run_ret(
[pytest_path, "tests/", "-n4", "-rs", "-x", "-vrx", "--durations=5"]
)
if any(x.returncode != 0 for x in (proc1, proc2, proc3)):
return 1
return 0
return ret
def fmt_cmd_options(parser):
@ -219,6 +213,13 @@ class Out:
self(f"[$ {arg}]", file=sys.stderr)
return subprocess.check_call(arg, shell=True, env=env)
def run_ret(self, args, env=None, quiet=False):
if not quiet:
cmdstring = " ".join(args)
self(f"[$ {cmdstring}]", file=sys.stderr)
proc = subprocess.run(args, env=env)
return proc.returncode
def add_config_option(parser):
parser.add_argument(