Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
111 lines (85 loc) · 2.42 KB

File metadata and controls

executable file
·
111 lines (85 loc) · 2.42 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/python3
#
# Copyright (c) 2022 David Steele <dsteele@gmail.com>
#
# SPDX-License-Identifier: GPL-2.0-or-later
# License-Filename: LICENSE
#
"""
devtest.py
This creates a virtual environment, and runs a number of test environments
against the comitup code.
The venv is persistent, and the tests run in parallel, so this is much quicker
than tox or nox.
"""
import subprocess
import sys
import textwrap
import venv
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from typing import List
envpath: Path = Path(__file__).resolve().parent / ".devenv"
pythonpath: str = str(envpath / "bin" / "python")
pkgs: List[str] = [
"pytest",
"mypy",
"ruff",
"cachetools",
"flask",
"types-tabulate",
"types-Flask",
"types-cachetools",
"types-Pygments",
"types-RPi.GPIO",
"types-pexpect",
"types-setuptools",
]
targets: str = "comitup comitup_web comitup_cli test devtest.py setup.py"
def mkcmd(cmd: str) -> List[str]:
return [str(pythonpath), "-m"] + cmd.split()
def run(cmd: str) -> subprocess.CompletedProcess:
cp = subprocess.run(
mkcmd(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
return cp
print("# Tests starting")
if not envpath.exists():
print("# Creating virtual environment")
virtenv = venv.EnvBuilder(
system_site_packages=True, symlinks=True, with_pip=True
)
virtenv.create(str(envpath))
print("# Installing packages")
run("pip install --upgrade pip")
for pkg in pkgs:
cp = run("pip install " + pkg)
print("Running", " ".join(cp.args))
print(cp.stdout.decode())
tests: List[str] = [
"ruff format --check {}".format(targets),
"ruff check --select I {}".format(targets),
"mypy {}".format(targets),
"ruff check {}".format(targets),
"pytest",
]
executor = ThreadPoolExecutor(max_workers=5)
fail = False
for result in executor.map(lambda x: run(x), tests):
judgement = "PASS" if not result.returncode else "FAIL"
print(
textwrap.dedent(
f"""\
#####################################
# Running {" ".join(result.args)}
{textwrap.indent(result.stdout.decode(), " ")}
################{judgement}#################
"""
)
)
if result.returncode:
fail = True
if fail:
print("# ERROR(S) ENCOUNTERED")
sys.exit(1)
print("# Tests complete")
Morty Proxy This is a proxified and sanitized view of the page, visit original site.