progon 0.6.25__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- progon/__init__.py +19 -0
- progon/__main__.py +5 -0
- progon/_build.py +2 -0
- progon/adapters/__init__.py +22 -0
- progon/adapters/base.py +185 -0
- progon/adapters/dotnet.py +554 -0
- progon/adapters/dotnet_progress.awk +81 -0
- progon/adapters/go.py +521 -0
- progon/adapters/go_progress.awk +96 -0
- progon/adapters/gomutants.py +305 -0
- progon/adapters/gomutants_progress.awk +32 -0
- progon/adapters/js.py +170 -0
- progon/adapters/js_progress.awk +81 -0
- progon/adapters/junit.py +107 -0
- progon/adapters/mutation.py +207 -0
- progon/adapters/mutmut.py +152 -0
- progon/adapters/mutmut_locate.py +81 -0
- progon/adapters/mutmut_progress.awk +28 -0
- progon/adapters/python.py +376 -0
- progon/adapters/python_progress.awk +106 -0
- progon/adapters/shell.py +241 -0
- progon/adapters/stryker_js.py +163 -0
- progon/adapters/stryker_js_drop_survivors.js +24 -0
- progon/adapters/stryker_js_progress.awk +20 -0
- progon/adapters/stryker_net.py +311 -0
- progon/adapters/stryker_net_progress.awk +34 -0
- progon/archive.py +81 -0
- progon/baseline.py +46 -0
- progon/cli.py +1032 -0
- progon/config.py +160 -0
- progon/diagnostics.py +205 -0
- progon/docs/adapters.md +182 -0
- progon/docs/agent-runbook.md +176 -0
- progon/docs/configuration.md +212 -0
- progon/docs/profiles.md +801 -0
- progon/docs/project-setup.md +244 -0
- progon/errors.py +51 -0
- progon/estimate.py +105 -0
- progon/group.py +246 -0
- progon/help.py +61 -0
- progon/live.py +335 -0
- progon/model.py +148 -0
- progon/orchestrate.py +900 -0
- progon/policy.py +34 -0
- progon/profile.py +486 -0
- progon/reach.py +139 -0
- progon/script.py +494 -0
- progon/server.py +709 -0
- progon/since.py +256 -0
- progon/snapshot.py +155 -0
- progon/state.py +84 -0
- progon/store.py +198 -0
- progon/summary.py +513 -0
- progon/targets.py +603 -0
- progon-0.6.25.dist-info/METADATA +228 -0
- progon-0.6.25.dist-info/RECORD +60 -0
- progon-0.6.25.dist-info/WHEEL +5 -0
- progon-0.6.25.dist-info/entry_points.txt +2 -0
- progon-0.6.25.dist-info/licenses/LICENSE +21 -0
- progon-0.6.25.dist-info/top_level.txt +1 -0
progon/__init__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""progon: one-command test runs on shared test VMs through progon-server."""
|
|
2
|
+
|
|
3
|
+
VERSION = "0.6.25"
|
|
4
|
+
|
|
5
|
+
# scripts/build-pyz.sh writes progon/_build.py into the pyz: the short commit and the build date.
|
|
6
|
+
try:
|
|
7
|
+
from ._build import BUILD, BUILT
|
|
8
|
+
except ImportError:
|
|
9
|
+
BUILD = BUILT = None
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def build_version():
|
|
13
|
+
"""`0.2.0+<commit> built <date>` for a pyz, plain VERSION for a checkout."""
|
|
14
|
+
return "%s+%s built %s" % (VERSION, BUILD, BUILT) if BUILD else VERSION
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def short_version():
|
|
18
|
+
"""`0.2.0+<commit>` for a pyz, plain VERSION for a checkout: what `progon update` compares."""
|
|
19
|
+
return "%s+%s" % (VERSION, BUILD) if BUILD else VERSION
|
progon/__main__.py
ADDED
progon/_build.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Adapter registry. A new stack or mutation tool is one module registered here."""
|
|
2
|
+
|
|
3
|
+
from ..errors import ProgonError
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _registry():
|
|
7
|
+
from . import dotnet, go, gomutants, js, mutmut, python, shell, stryker_js, stryker_net
|
|
8
|
+
adapters = (go.GoAdapter, dotnet.DotnetAdapter, python.PythonAdapter, js.JsAdapter,
|
|
9
|
+
gomutants.GomutantsAdapter, stryker_js.StrykerJsAdapter, stryker_net.StrykerNetAdapter,
|
|
10
|
+
mutmut.MutmutAdapter, shell.ShellAdapter)
|
|
11
|
+
return {cls.name: cls for cls in adapters}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def get_adapter(name, where="profile"):
|
|
15
|
+
registry = _registry()
|
|
16
|
+
if name not in registry:
|
|
17
|
+
raise ProgonError("profile", "%s: unknown adapter %r (available: %s)" % (where, name, ", ".join(sorted(registry))))
|
|
18
|
+
return registry[name]()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def adapter_names():
|
|
22
|
+
return sorted(_registry())
|
progon/adapters/base.py
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"""The adapter contract.
|
|
2
|
+
|
|
3
|
+
An adapter knows one stack or one mutation tool. The core gives it the
|
|
4
|
+
resolved profile and the caller's narrowing arguments; the adapter returns
|
|
5
|
+
POSIX shell for the runner, an optional awk progress filter, and a parser that
|
|
6
|
+
turns the exported reports into the normalized model (progon.model).
|
|
7
|
+
|
|
8
|
+
The core never looks inside a stack's reports, and an adapter never talks to
|
|
9
|
+
a VM. See docs/adapters.md.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import shlex
|
|
13
|
+
from importlib import resources
|
|
14
|
+
|
|
15
|
+
from ..errors import UsageError
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def resource_text(name):
|
|
19
|
+
"""A file shipped next to the adapters (awk filters, helper scripts), from a checkout or from the pyz."""
|
|
20
|
+
return resources.files(__package__).joinpath(name).read_text(encoding="utf-8")
|
|
21
|
+
|
|
22
|
+
def wrapper_option(value, fail, key):
|
|
23
|
+
"""`wrapper`: the command that launches the tool; progon passes the original tool argv after `--`."""
|
|
24
|
+
if not isinstance(value, list) or not value or not all(isinstance(a, str) and a for a in value):
|
|
25
|
+
fail(key, "must be a non-empty command, e.g. [\"sh\", \"scripts/guard.sh\"]")
|
|
26
|
+
return list(value)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# The `finalize` stage of a fenced wrapper run: the wrapper itself closes the broker's end-of-run fence, drains,
|
|
30
|
+
# waits and attests (`progon-quiesce close`, `wait`, `verified`); progon checks the broker's own record of it.
|
|
31
|
+
# Exit codes of the wrapper: 70 the guard stopped the tool, 71 the project's final verification failed.
|
|
32
|
+
FENCE_FINALIZE = (
|
|
33
|
+
"stage_begin finalize",
|
|
34
|
+
'fin_log="$P/finalize.log"; : > "$fin_log"',
|
|
35
|
+
'case "$test_exit" in',
|
|
36
|
+
' 70) echo "the wrapper reported a fatal guard (exit 70): the tool was stopped; its raw reports are kept" >> "$fin_log"; stage_fail 70 ;;',
|
|
37
|
+
' 71) echo "the wrapper reported that the final verification failed (exit 71)" >> "$fin_log"; stage_fail 71 ;;',
|
|
38
|
+
"esac",
|
|
39
|
+
'fence_status=$(progon-quiesce status 2>> "$fin_log") || { echo "progon-quiesce status failed" >> "$fin_log"; stage_fail 1; }',
|
|
40
|
+
"for fence_key in closed_at waited_ok_at verified_at; do",
|
|
41
|
+
' case "$fence_status" in',
|
|
42
|
+
' *\\"$fence_key\\":\\ \\"*) ;;',
|
|
43
|
+
' *) echo "the wrapper did not complete the end-of-run fence: $fence_key is missing" >> "$fin_log"; stage_fail 1 ;;',
|
|
44
|
+
" esac",
|
|
45
|
+
"done",
|
|
46
|
+
'case "$fence_status" in',
|
|
47
|
+
' *\\"uncertain\\":\\ null*) ;;',
|
|
48
|
+
' *) echo "the end-of-run fence is uncertain: an effect of a request cannot be classified" >> "$fin_log"; stage_fail 1 ;;',
|
|
49
|
+
"esac",
|
|
50
|
+
"stage_ok",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# The live-progress files every progress filter writes, relative to /work/results.
|
|
54
|
+
COUNTS_FILE = "progon/counts.tsv"
|
|
55
|
+
FAILURES_FILE = "progon/failures.tsv"
|
|
56
|
+
MUTANTS_FILE = "progon/mutants.tsv"
|
|
57
|
+
# Survivors known while a mutation run is going: `file<TAB>line<TAB>mutator<TAB>replacement`, appended.
|
|
58
|
+
SURVIVORS_FILE = "progon/survivors.tsv"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class TestContext:
|
|
62
|
+
"""What the runner script provides to an adapter's test fragment.
|
|
63
|
+
|
|
64
|
+
All paths are container paths. The fragment runs in `workdir` (inside `repo_dir`, the snapshot), must write
|
|
65
|
+
the native exit code of the test command to `exit_file`, and writes its
|
|
66
|
+
reports under `report_dir`. `state_dir` holds the adapter's state files
|
|
67
|
+
from the last run, when there are any, and the tool updates them there; it
|
|
68
|
+
is None when this run keeps no state (see `Adapter.state_files`).
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
def __init__(self, workdir, report_dir, exit_file, scratch_dir, results_dir, cpu, *, repo_dir, state_dir=None):
|
|
72
|
+
self.workdir = workdir
|
|
73
|
+
self.repo_dir = repo_dir
|
|
74
|
+
self.report_dir = report_dir
|
|
75
|
+
self.exit_file = exit_file
|
|
76
|
+
self.scratch_dir = scratch_dir
|
|
77
|
+
self.results_dir = results_dir
|
|
78
|
+
self.cpu = cpu
|
|
79
|
+
self.state_dir = state_dir
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class Adapter:
|
|
83
|
+
name = None
|
|
84
|
+
kind = "test" # or "mutation"
|
|
85
|
+
# The file under the report directory that receives the test command's console output, if the
|
|
86
|
+
# adapter keeps one: its last line is the test stage's activity (e.g. a build before tests run).
|
|
87
|
+
console_file = None
|
|
88
|
+
# The stage runs the go command (module downloads): with netrc = true the runner also sets GONOSUMDB.
|
|
89
|
+
go_modules = False
|
|
90
|
+
|
|
91
|
+
def fence_wrapper(self, profile):
|
|
92
|
+
"""Whether the run's tool is launched by a project wrapper under the end-of-run fence (needs the broker)."""
|
|
93
|
+
return False
|
|
94
|
+
|
|
95
|
+
def finalize_fragment(self, profile):
|
|
96
|
+
"""Shell lines of the `finalize` stage, run after the test stage; empty when the adapter has none."""
|
|
97
|
+
return []
|
|
98
|
+
|
|
99
|
+
def validate_options(self, options, fail):
|
|
100
|
+
"""Check `[kind.X.options]`; call fail(key, message) on an error. Returns the normalized options."""
|
|
101
|
+
if options:
|
|
102
|
+
fail(sorted(options)[0], "unknown option")
|
|
103
|
+
return {}
|
|
104
|
+
|
|
105
|
+
def validate_selection(self, selection, fail):
|
|
106
|
+
"""Check `[kind.X.selection]`. Returns the normalized selection."""
|
|
107
|
+
if selection:
|
|
108
|
+
fail(sorted(selection)[0], "unknown key")
|
|
109
|
+
return {}
|
|
110
|
+
|
|
111
|
+
def parse_narrowing(self, args, profile):
|
|
112
|
+
"""Turn the caller's narrowing arguments into a selection; raise UsageError if not allowed."""
|
|
113
|
+
if args:
|
|
114
|
+
raise UsageError("adapter %s takes no narrowing arguments" % self.name)
|
|
115
|
+
return {}
|
|
116
|
+
|
|
117
|
+
def describe_selection(self, selection):
|
|
118
|
+
return ""
|
|
119
|
+
|
|
120
|
+
def environment(self, profile, ctx):
|
|
121
|
+
"""Extra environment for every runner stage."""
|
|
122
|
+
return {}
|
|
123
|
+
|
|
124
|
+
def preparation(self, profile, ctx):
|
|
125
|
+
"""Shell commands the adapter needs before the profile's own preparation."""
|
|
126
|
+
return []
|
|
127
|
+
|
|
128
|
+
def state_files(self, profile):
|
|
129
|
+
"""Plain file names that carry the tool's incremental state from one run to the next.
|
|
130
|
+
|
|
131
|
+
progon keeps them per (project, kind) and puts the last ones into
|
|
132
|
+
`ctx.state_dir` before the test stage; the fragment points the tool at
|
|
133
|
+
them there, and the tool reads and rewrites them. A file the tool does
|
|
134
|
+
not write is simply not kept. Default: no state.
|
|
135
|
+
"""
|
|
136
|
+
return []
|
|
137
|
+
|
|
138
|
+
def snapshot_extras(self, profile, selection, src):
|
|
139
|
+
"""Files the adapter adds to the run's tooling directory (`/work/repo/.progon-run/<name>`): {name: bytes}.
|
|
140
|
+
|
|
141
|
+
`src` is the local snapshot directory, already complete. It may note in `selection` what the test fragment needs
|
|
142
|
+
(the selection is kept in the plan). Raise UsageError when a file cannot be made.
|
|
143
|
+
"""
|
|
144
|
+
return {}
|
|
145
|
+
|
|
146
|
+
def test_fragment(self, profile, selection, ctx):
|
|
147
|
+
"""POSIX shell that runs the selected tests."""
|
|
148
|
+
raise NotImplementedError
|
|
149
|
+
|
|
150
|
+
def progress_awk(self):
|
|
151
|
+
"""An awk program reading the test command's stdout, or None.
|
|
152
|
+
|
|
153
|
+
It must copy every input line to stdout unchanged and keep the
|
|
154
|
+
progress files up to date (see docs/adapters.md, "Live progress").
|
|
155
|
+
"""
|
|
156
|
+
return None
|
|
157
|
+
|
|
158
|
+
def collect(self, report_dir, options, selection):
|
|
159
|
+
"""Parse the exported reports in `report_dir` (the local copy of the fragment's report_dir).
|
|
160
|
+
|
|
161
|
+
`options` and `selection` are the validated values from the plan.
|
|
162
|
+
Returns (tests, stages, mutation): CTRF test records, extra stage
|
|
163
|
+
records, and a mutation result {"mutants": [...]} or None. A mutation
|
|
164
|
+
result may carry "notes": lines the summary prints under the mutation
|
|
165
|
+
line, e.g. why the tool measured no mutant.
|
|
166
|
+
"""
|
|
167
|
+
raise NotImplementedError
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def quote(argv):
|
|
171
|
+
return " ".join(shlex.quote(str(a)) for a in argv)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def split_flag(token):
|
|
175
|
+
"""`-run=X` → ("-run", "X"); `-run` → ("-run", None)."""
|
|
176
|
+
if token.startswith("-") and "=" in token:
|
|
177
|
+
name, value = token.split("=", 1)
|
|
178
|
+
return name, value
|
|
179
|
+
return token, None
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def check_allowed(flag, allow, adapter):
|
|
183
|
+
if flag not in allow:
|
|
184
|
+
raise UsageError("%s: narrowing argument %s is not allowed by the profile (allowed: %s)"
|
|
185
|
+
% (adapter, flag, ", ".join(allow) or "none"))
|