@jesdi/skills 0.0.81 → 0.0.82
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.
- package/package.json +2 -1
- package/skills/crap-gate/launcher.sh +104 -0
- package/skills/crap-gate/run.sh +15 -75
- package/skills/crap-gate/test_launcher.py +39 -0
- package/skills/implement-spec/launcher.sh +104 -0
- package/skills/implement-spec/run.sh +10 -89
- package/skills/implement-spec/tests/test_launcher.py +138 -0
- package/skills/test-weigh-in/SKILL.md +16 -0
- package/skills/test-weigh-in/dashboard.html +112 -0
- package/skills/test-weigh-in/launcher.sh +104 -0
- package/skills/test-weigh-in/rules.toml +134 -0
- package/skills/test-weigh-in/run.sh +21 -0
- package/skills/test-weigh-in/tests/brittle_repo.py +79 -0
- package/skills/test-weigh-in/tests/conftest.py +35 -0
- package/skills/test-weigh-in/tests/fixture_repo.py +99 -0
- package/skills/test-weigh-in/tests/kill_repo.py +87 -0
- package/skills/test-weigh-in/tests/maint_repo.py +139 -0
- package/skills/test-weigh-in/tests/map_fixture.py +56 -0
- package/skills/test-weigh-in/tests/pt_repo.py +46 -0
- package/skills/test-weigh-in/tests/red_repo.py +44 -0
- package/skills/test-weigh-in/tests/rule_repo.py +208 -0
- package/skills/test-weigh-in/tests/rules_fixture.py +65 -0
- package/skills/test-weigh-in/tests/smell_repo.py +138 -0
- package/skills/test-weigh-in/tests/test_brittleness.py +75 -0
- package/skills/test-weigh-in/tests/test_brittleness_history.py +168 -0
- package/skills/test-weigh-in/tests/test_coverage_run.py +201 -0
- package/skills/test-weigh-in/tests/test_coverage_value.py +76 -0
- package/skills/test-weigh-in/tests/test_dashboard_map.py +20 -0
- package/skills/test-weigh-in/tests/test_interpreters.py +115 -0
- package/skills/test-weigh-in/tests/test_kill_matrix.py +126 -0
- package/skills/test-weigh-in/tests/test_maintainability_smells.py +113 -0
- package/skills/test-weigh-in/tests/test_mutation_recovery.py +67 -0
- package/skills/test-weigh-in/tests/test_mutation_sampling.py +53 -0
- package/skills/test-weigh-in/tests/test_mutation_score.py +140 -0
- package/skills/test-weigh-in/tests/test_mutation_stale.py +30 -0
- package/skills/test-weigh-in/tests/test_mutmut_contract.py +43 -0
- package/skills/test-weigh-in/tests/test_ruff_pt_smells.py +45 -0
- package/skills/test-weigh-in/tests/test_runs.py +156 -0
- package/skills/test-weigh-in/tests/test_score.py +26 -0
- package/skills/test-weigh-in/tests/test_scoring.py +154 -0
- package/skills/test-weigh-in/tests/test_smell_rules.py +96 -0
- package/skills/test-weigh-in/tests/test_smells.py +71 -0
- package/skills/test-weigh-in/tests/test_walking_skeleton.py +91 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/demo/__init__.py +0 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/demo/board.py +2 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/demo/config.py +2 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/pyproject.toml +8 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_board.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_config.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_parser.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_render.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_report.py +17 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_session.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_store.py +17 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_sync.py +17 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/uv.lock +1 -0
- package/skills/test-weigh-in/weigh.py +133 -0
- package/skills/test-weigh-in/weigh_coverage.py +154 -0
- package/skills/test-weigh-in/weigh_dashboard.py +72 -0
- package/skills/test-weigh-in/weigh_env.py +112 -0
- package/skills/test-weigh-in/weigh_git.py +119 -0
- package/skills/test-weigh-in/weigh_inventory.py +49 -0
- package/skills/test-weigh-in/weigh_mutation.py +190 -0
- package/skills/test-weigh-in/weigh_pytest_plugin.py +70 -0
- package/skills/test-weigh-in/weigh_ruff.py +22 -0
- package/skills/test-weigh-in/weigh_rules.py +65 -0
- package/skills/test-weigh-in/weigh_runs.py +134 -0
- package/skills/test-weigh-in/weigh_score.py +80 -0
- package/skills/test-weigh-in/weigh_smells.py +355 -0
- package/skills/test-weigh-in/weigh_snapshot.py +49 -0
- package/skills-manifest.json +11 -5
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en"><head><meta charset="utf-8"><title>test-weigh-in</title>
|
|
3
|
+
<style>
|
|
4
|
+
body{font:14px system-ui,sans-serif;margin:24px;color:#222}
|
|
5
|
+
#gauges{display:flex;gap:12px;margin:16px 0}
|
|
6
|
+
.gauge{flex:1;border:2px solid #ccc;border-radius:8px;padding:12px;background:#fff;text-align:center;cursor:pointer;font:inherit}
|
|
7
|
+
.gauge[aria-pressed=true]{border-color:#2563eb}
|
|
8
|
+
.score{display:block;font-size:32px;font-weight:600}
|
|
9
|
+
#banner{background:#fef2f2;color:#991b1b;padding:8px 12px;border-radius:6px}
|
|
10
|
+
.flag{display:block;color:#92400e}
|
|
11
|
+
table{border-collapse:collapse}td,th{padding:4px 12px;text-align:left}
|
|
12
|
+
</style></head><body>
|
|
13
|
+
<h1>test-weigh-in</h1>
|
|
14
|
+
<p data-testid="inventory" id="inventory"></p>
|
|
15
|
+
<p data-testid="banner" id="banner"></p>
|
|
16
|
+
<div id="gauges"></div>
|
|
17
|
+
<section data-testid="details" id="details"></section>
|
|
18
|
+
<script>
|
|
19
|
+
const data = __DATA__;
|
|
20
|
+
const shown = (s) => Math.min(99, Math.max(1, Math.round(s)));
|
|
21
|
+
const el = (tag, text, parent) => { const e = document.createElement(tag); e.textContent = text; parent.appendChild(e); return e; };
|
|
22
|
+
const fmt = (n) => String(Math.round(n * 100) / 100);
|
|
23
|
+
let selected = 0, tab = 'Metrics', picked = null;
|
|
24
|
+
const NS = 'http://www.w3.org/2000/svg';
|
|
25
|
+
function drawMap(parent) {
|
|
26
|
+
const near = picked ? new Map(picked.similar) : new Map();
|
|
27
|
+
const svg = document.createElementNS(NS, 'svg');
|
|
28
|
+
parent.appendChild(svg);
|
|
29
|
+
// tests with the same or nearly the same coverage land on or near one place: push apart each pair of dots that
|
|
30
|
+
// overlaps until none does, so every dot stays clickable; same data, same pushes, same map on every load
|
|
31
|
+
// ponytail: all pairs per pass, quadratic; a spatial grid if maps of thousands of dots get slow
|
|
32
|
+
const dots = data.map.map((d) => ({ d, cx: 20 + d.x * 360, cy: 20 + d.y * 260, r: 4 + Math.min(10, d.runtime * 4) }));
|
|
33
|
+
for (let pass = 0, moved = true; moved && pass < 200; pass++) {
|
|
34
|
+
moved = false;
|
|
35
|
+
dots.forEach((a, i) => dots.slice(i + 1).forEach((b, k) => {
|
|
36
|
+
const dx = b.cx - a.cx, dy = b.cy - a.cy, dist = Math.hypot(dx, dy), gap = a.r + b.r + 2;
|
|
37
|
+
if (dist >= gap) return;
|
|
38
|
+
// dots on one spot part along an angle fixed by their order
|
|
39
|
+
const angle = dist > 1e-9 ? Math.atan2(dy, dx) : 2.39996 * (i + k + 1), push = (gap - dist) / 2 + 0.01;
|
|
40
|
+
a.cx -= push * Math.cos(angle); a.cy -= push * Math.sin(angle);
|
|
41
|
+
b.cx += push * Math.cos(angle); b.cy += push * Math.sin(angle);
|
|
42
|
+
moved = true;
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
// the view grows to hold every ring, at one unit per pixel so sizes keep their meaning
|
|
46
|
+
const x0 = Math.min(0, ...dots.map((o) => o.cx - o.r - 2)), y0 = Math.min(0, ...dots.map((o) => o.cy - o.r - 2));
|
|
47
|
+
const w = Math.max(400, ...dots.map((o) => o.cx + o.r + 2)) - x0, h = Math.max(300, ...dots.map((o) => o.cy + o.r + 2)) - y0;
|
|
48
|
+
svg.setAttribute('viewBox', `${x0} ${y0} ${w} ${h}`); svg.setAttribute('width', w); svg.setAttribute('height', h);
|
|
49
|
+
dots.forEach(({ d, cx, cy, r }) => {
|
|
50
|
+
const c = document.createElementNS(NS, 'circle');
|
|
51
|
+
c.setAttribute('cx', cx); c.setAttribute('cy', cy);
|
|
52
|
+
c.setAttribute('r', r);
|
|
53
|
+
c.setAttribute('fill', d.unique === 0 ? '#9ca3af' : d.unique < 4 ? '#f59e0b' : '#16a34a');
|
|
54
|
+
c.setAttribute('stroke', picked && (picked === d || near.has(d.test)) ? '#2563eb' : 'none');
|
|
55
|
+
c.setAttribute('stroke-width', '3');
|
|
56
|
+
c.setAttribute('data-testid', 'map-dot'); c.dataset.test = d.test;
|
|
57
|
+
if (picked && (picked === d || near.has(d.test))) c.dataset.highlighted = 'true';
|
|
58
|
+
c.onclick = () => { picked = d; render(); };
|
|
59
|
+
svg.appendChild(c);
|
|
60
|
+
});
|
|
61
|
+
const list = el('div', '', parent); list.setAttribute('data-testid', 'map-similar');
|
|
62
|
+
if (picked) picked.similar.forEach(([n, s]) => el('p', n + ' ' + s.toFixed(2), list).setAttribute('data-testid', 'map-similar-item'));
|
|
63
|
+
}
|
|
64
|
+
function render() {
|
|
65
|
+
document.getElementById('inventory').textContent = data.inventory;
|
|
66
|
+
const banner = document.getElementById('banner');
|
|
67
|
+
if (banner) { if (data.banner) banner.textContent = data.banner; else banner.remove(); }
|
|
68
|
+
const gauges = document.getElementById('gauges'), details = document.getElementById('details');
|
|
69
|
+
gauges.replaceChildren(); details.replaceChildren();
|
|
70
|
+
data.pillars.forEach((p, i) => {
|
|
71
|
+
const g = el('button', '', gauges);
|
|
72
|
+
g.className = 'gauge'; g.dataset.testid = 'gauge'; g.setAttribute('data-testid', 'gauge');
|
|
73
|
+
g.setAttribute('aria-pressed', i === selected);
|
|
74
|
+
el('span', p.name, g);
|
|
75
|
+
el('span', p.score === null ? '–' : shown(p.score), g).className = 'score';
|
|
76
|
+
if (p.partial) el('span', 'partial: ' + p.metrics.length + ' of ' + p.total + ' metrics measured', g).className = 'flag';
|
|
77
|
+
g.onclick = () => { selected = i; tab = 'Metrics'; picked = null; render(); };
|
|
78
|
+
});
|
|
79
|
+
const p = data.pillars[selected];
|
|
80
|
+
el('h2', p.name, details);
|
|
81
|
+
const names = ['Metrics', 'Worst tests', 'Smells', ...(p.key === 'economy' ? ['Overlaps', 'Map'] : [])];
|
|
82
|
+
names.forEach((n) => { const b = el('button', n, details); b.setAttribute('aria-pressed', n === tab); b.onclick = () => { tab = n; picked = null; render(); }; });
|
|
83
|
+
el('h3', tab, details);
|
|
84
|
+
if (tab === 'Metrics') {
|
|
85
|
+
const t = el('table', '', details);
|
|
86
|
+
p.metrics.forEach((m) => {
|
|
87
|
+
const r = el('tr', '', t);
|
|
88
|
+
el('td', m.name, r); el('td', fmt(m.value), r); el('td', String(shown(m.score)), r);
|
|
89
|
+
});
|
|
90
|
+
if (data.skipped.length) {
|
|
91
|
+
el('h3', 'Skipped tests', details);
|
|
92
|
+
data.skipped.forEach((n) => el('p', n + ' (skipped)', details));
|
|
93
|
+
}
|
|
94
|
+
if (p.key === 'economy' && data.insufficient.length) {
|
|
95
|
+
el('h3', 'Insufficient evidence (fewer than 2 sampled mutants on their lines)', details);
|
|
96
|
+
data.insufficient.forEach((n) => el('p', n, details));
|
|
97
|
+
}
|
|
98
|
+
} else if (tab === 'Worst tests') {
|
|
99
|
+
p.worst.forEach((w) => el('p', w.test + ' (' + w.reason + ')', details).setAttribute('data-testid', 'worst-test'));
|
|
100
|
+
} else if (tab === 'Smells') {
|
|
101
|
+
const smells = Object.entries(p.smells);
|
|
102
|
+
if (!smells.length) el('p', 'No test has a smell of this pillar.', details);
|
|
103
|
+
smells.forEach(([smell, tests]) => {
|
|
104
|
+
el('h4', smell + ' (' + tests.length + (tests.length === 1 ? ' test)' : ' tests)'), details).setAttribute('data-testid', 'smell');
|
|
105
|
+
tests.forEach((n) => el('p', n, details).setAttribute('data-testid', 'smell-test'));
|
|
106
|
+
});
|
|
107
|
+
} else if (tab === 'Overlaps') {
|
|
108
|
+
data.overlaps.forEach((o) => el('p', o.tests.join(' ~ ') + ' ' + o.jaccard.toFixed(2), details));
|
|
109
|
+
} else if (tab === 'Map') drawMap(details);
|
|
110
|
+
}
|
|
111
|
+
render();
|
|
112
|
+
</script></body></html>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Sourced by a skill wrapper. The wrapper sets: inherited (`export -p` output
|
|
2
|
+
# taken before its first assignment), skill_dir, name (cache dir name,
|
|
3
|
+
# e.g. crap-gate), env_prefix (e.g. CRAP_GATE), prefix (message prefix), fail_code, engine (file in
|
|
4
|
+
# skill_dir; it gets the cached uv's path as <env_prefix>_UV), and optionally defines setup_failed MESSAGE (stdout on failure) and
|
|
5
|
+
# pins (space-separated requirements) with venv_key (e.g. jsonschema-4.26.0, whose
|
|
6
|
+
# first word names the package in errors): the engine then runs in a venv per pin set.
|
|
7
|
+
set -eu
|
|
8
|
+
|
|
9
|
+
fail() {
|
|
10
|
+
printf '%s: %s\n' "$prefix" "$1" >&2
|
|
11
|
+
! command -v setup_failed >/dev/null 2>&1 || setup_failed "$1"
|
|
12
|
+
exit "$fail_code"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
eval "cache_override=\${${env_prefix}_CACHE_DIR:-} offline=\${${env_prefix}_OFFLINE:-0}"
|
|
16
|
+
cache=${cache_override:-${XDG_CACHE_HOME:-$HOME/.cache}/$name}
|
|
17
|
+
case "$cache" in /*) ;; *) fail "${env_prefix}_CACHE_DIR must be an absolute path" ;; esac
|
|
18
|
+
uv_version=0.12.13
|
|
19
|
+
python_version=3.13.7
|
|
20
|
+
case "$(uname -s):$(uname -m)" in
|
|
21
|
+
Darwin:arm64|Darwin:aarch64)
|
|
22
|
+
target=aarch64-apple-darwin
|
|
23
|
+
digest=7e6ddb9316acc00f2296c82ff4d99977870ee34b2f0ddcae9444d714db9364ed ;;
|
|
24
|
+
Darwin:x86_64)
|
|
25
|
+
target=x86_64-apple-darwin
|
|
26
|
+
digest=5e287ef61cb6a9b61b3a83fef124fd143e400468a7dac794230147a810e17119 ;;
|
|
27
|
+
Linux:aarch64|Linux:arm64)
|
|
28
|
+
target=aarch64-unknown-linux-musl
|
|
29
|
+
digest=f44bc1037a17889fe562fffd2002d4ed108e499fbe68b4f022af244dc7b8244f ;;
|
|
30
|
+
Linux:x86_64)
|
|
31
|
+
target=x86_64-unknown-linux-musl
|
|
32
|
+
digest=4e2bfd0c9007b1032a50e539e965fd0a6037d87ad93ae1580d220a92d4c94098 ;;
|
|
33
|
+
*) fail 'Unsupported platform: use macOS or Linux on x86_64 or ARM64 (Windows: WSL)' ;;
|
|
34
|
+
esac
|
|
35
|
+
uv_dir=$cache/uv/$uv_version/$target
|
|
36
|
+
uv=$uv_dir/uv
|
|
37
|
+
if [ ! -x "$uv" ]; then
|
|
38
|
+
[ "$offline" != 1 ] || fail 'uv is not cached; provision this cache online first'
|
|
39
|
+
mkdir -p "$uv_dir" || fail 'Cannot create runtime cache'
|
|
40
|
+
stage=$(mktemp -d "$uv_dir/.download.XXXXXX") || fail 'Cannot create download directory'
|
|
41
|
+
trap 'rm -rf "$stage"' EXIT
|
|
42
|
+
trap 'exit "$fail_code"' HUP INT TERM
|
|
43
|
+
printf '%s: downloading uv %s\n' "$prefix" "$uv_version" >&2
|
|
44
|
+
curl --fail --location --silent --show-error --connect-timeout 15 --max-time 300 \
|
|
45
|
+
"https://github.com/astral-sh/uv/releases/download/$uv_version/uv-$target.tar.gz" \
|
|
46
|
+
-o "$stage/uv.tar.gz" || fail 'Cannot download uv; check network access and retry'
|
|
47
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
48
|
+
actual=$(sha256sum "$stage/uv.tar.gz")
|
|
49
|
+
elif command -v shasum >/dev/null 2>&1; then
|
|
50
|
+
actual=$(shasum -a 256 "$stage/uv.tar.gz")
|
|
51
|
+
else
|
|
52
|
+
fail 'SHA-256 verification requires sha256sum or shasum'
|
|
53
|
+
fi
|
|
54
|
+
[ "${actual%% *}" = "$digest" ] || fail 'uv archive checksum mismatch'
|
|
55
|
+
tar -xzf "$stage/uv.tar.gz" -C "$stage" || fail 'Cannot extract uv'
|
|
56
|
+
# Atomic publication: concurrent first runs never see a partial executable.
|
|
57
|
+
mv -f "$stage/uv-$target/uv" "$uv" || fail 'Cannot install cached uv'
|
|
58
|
+
rm -rf "$stage"
|
|
59
|
+
trap - EXIT HUP INT TERM
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
# Limit uv settings to this subprocess. Do not activate a venv or change PATH:
|
|
63
|
+
# coverage commands inherit the caller's project environment (the engine adds
|
|
64
|
+
# only the repo's own .venv/bin, when no virtualenv is active).
|
|
65
|
+
managed_uv() (
|
|
66
|
+
unset UV_NO_MANAGED_PYTHON UV_PYTHON UV_PYTHON_DOWNLOADS UV_PYTHON_BIN_DIR
|
|
67
|
+
export UV_PYTHON_INSTALL_DIR="$cache/python"
|
|
68
|
+
export UV_CACHE_DIR="$cache/uv-cache"
|
|
69
|
+
export UV_MANAGED_PYTHON=true
|
|
70
|
+
"$uv" --no-config "$@"
|
|
71
|
+
)
|
|
72
|
+
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version" 2>/dev/null) || {
|
|
73
|
+
[ "$offline" != 1 ] || fail 'Python is not cached; provision this cache online first'
|
|
74
|
+
managed_uv python install --no-bin "$python_version" >&2 || fail 'Cannot provision Python; check network access and retry'
|
|
75
|
+
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version") || fail 'Cannot locate managed Python'
|
|
76
|
+
}
|
|
77
|
+
if [ -n "${pins:-}" ]; then
|
|
78
|
+
venv=$cache/venv/$python_version-$venv_key
|
|
79
|
+
if [ ! -x "$venv/bin/python" ]; then
|
|
80
|
+
[ "$offline" != 1 ] || fail "${venv_key%%-*} is not cached; provision this cache online first"
|
|
81
|
+
mkdir -p "$cache/venv" || fail 'Cannot create runtime cache'
|
|
82
|
+
stage=$(mktemp -d "$cache/venv/.build.XXXXXX") || fail 'Cannot create build directory'
|
|
83
|
+
trap 'rm -rf "$stage"' EXIT
|
|
84
|
+
trap 'exit "$fail_code"' HUP INT TERM
|
|
85
|
+
# shellcheck disable=SC2086 # pins is a deliberate word list
|
|
86
|
+
managed_uv venv --quiet --python "$python" "$stage/venv" >&2 &&
|
|
87
|
+
managed_uv pip install --quiet --python "$stage/venv/bin/python" $pins >&2 ||
|
|
88
|
+
fail "Cannot provision ${venv_key%%-*}; check network access and retry"
|
|
89
|
+
# Publish by rename(2): a concurrent first run never sees a partial venv. A run that loses the
|
|
90
|
+
# race fails the rename (mv would move into the winner's directory) and uses the winner's venv.
|
|
91
|
+
[ -x "$venv/bin/python" ] || "$python" -I -c 'import os, sys; os.rename(*sys.argv[1:])' "$stage/venv" "$venv" 2>/dev/null || :
|
|
92
|
+
[ -x "$venv/bin/python" ] || fail 'Cannot install cached venv'
|
|
93
|
+
rm -rf "$stage"
|
|
94
|
+
trap - EXIT HUP INT TERM
|
|
95
|
+
fi
|
|
96
|
+
python=$venv/bin/python
|
|
97
|
+
fi
|
|
98
|
+
# Ignore Python-specific ambient settings for the engine, but preserve them for
|
|
99
|
+
# child coverage processes. -I would also remove the sibling module directory.
|
|
100
|
+
set -- "$python" -E -s "$skill_dir/$engine" "$@"
|
|
101
|
+
eval "$inherited"
|
|
102
|
+
# The engine finds the cached uv here: PATH stays the caller's.
|
|
103
|
+
export "${env_prefix}_UV=$uv"
|
|
104
|
+
exec "$@"
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
|
|
3
|
+
[ruff]
|
|
4
|
+
# PT rules that are not style-only; each violation inside a test is a maintainability smell of it
|
|
5
|
+
pt = ["PT009", "PT010", "PT011", "PT012", "PT014", "PT015", "PT017", "PT018", "PT027", "PT029", "PT030", "PT031"]
|
|
6
|
+
|
|
7
|
+
[pillars.regression]
|
|
8
|
+
name = "Protection against regressions"
|
|
9
|
+
|
|
10
|
+
[pillars.regression.metrics.mutation_score]
|
|
11
|
+
name = "Mutation score"
|
|
12
|
+
weight = 0.45
|
|
13
|
+
target = 80
|
|
14
|
+
bad = 40
|
|
15
|
+
|
|
16
|
+
[pillars.regression.metrics.branch_coverage]
|
|
17
|
+
name = "Branch coverage"
|
|
18
|
+
weight = 0.25
|
|
19
|
+
target = 90
|
|
20
|
+
bad = 50
|
|
21
|
+
partial_weight = 0.6
|
|
22
|
+
|
|
23
|
+
[pillars.regression.metrics.hollow_tests]
|
|
24
|
+
name = "Hollow tests"
|
|
25
|
+
weight = 0.2
|
|
26
|
+
target = 0
|
|
27
|
+
bad = 10
|
|
28
|
+
partial_weight = 0.4
|
|
29
|
+
|
|
30
|
+
[pillars.regression.metrics.pseudo_tested_functions]
|
|
31
|
+
name = "Pseudo-tested functions"
|
|
32
|
+
weight = 0.1
|
|
33
|
+
target = 0
|
|
34
|
+
bad = 15
|
|
35
|
+
|
|
36
|
+
[pillars.refactoring]
|
|
37
|
+
name = "Resistance to refactoring"
|
|
38
|
+
|
|
39
|
+
[pillars.refactoring.metrics.brittle_test_files]
|
|
40
|
+
name = "Brittle test files"
|
|
41
|
+
weight = 0.4
|
|
42
|
+
target = 15
|
|
43
|
+
bad = 60
|
|
44
|
+
|
|
45
|
+
[pillars.refactoring.metrics.private_access]
|
|
46
|
+
name = "Tests with private access"
|
|
47
|
+
weight = 0.25
|
|
48
|
+
target = 2
|
|
49
|
+
bad = 30
|
|
50
|
+
|
|
51
|
+
[pillars.refactoring.metrics.mock_heavy]
|
|
52
|
+
name = "Mock-heavy tests"
|
|
53
|
+
weight = 0.2
|
|
54
|
+
target = 5
|
|
55
|
+
bad = 30
|
|
56
|
+
|
|
57
|
+
[pillars.refactoring.metrics.interaction_only]
|
|
58
|
+
name = "Interaction-only tests"
|
|
59
|
+
weight = 0.15
|
|
60
|
+
target = 5
|
|
61
|
+
bad = 30
|
|
62
|
+
|
|
63
|
+
[pillars.feedback]
|
|
64
|
+
name = "Fast feedback"
|
|
65
|
+
|
|
66
|
+
[pillars.feedback.metrics.total_runtime]
|
|
67
|
+
name = "Total runtime"
|
|
68
|
+
weight = 0.4
|
|
69
|
+
target = 60
|
|
70
|
+
bad = 600
|
|
71
|
+
log = true
|
|
72
|
+
|
|
73
|
+
[pillars.feedback.metrics.p95_duration]
|
|
74
|
+
name = "p95 test duration"
|
|
75
|
+
weight = 0.3
|
|
76
|
+
target = 0.1
|
|
77
|
+
bad = 2
|
|
78
|
+
log = true
|
|
79
|
+
|
|
80
|
+
[pillars.feedback.metrics.slowest_decile_share]
|
|
81
|
+
name = "Runtime share of slowest 10% of tests"
|
|
82
|
+
weight = 0.15
|
|
83
|
+
target = 40
|
|
84
|
+
bad = 90
|
|
85
|
+
|
|
86
|
+
[pillars.feedback.metrics.tests_over_10s]
|
|
87
|
+
name = "Tests over 10 s"
|
|
88
|
+
weight = 0.15
|
|
89
|
+
target = 0
|
|
90
|
+
bad = 2
|
|
91
|
+
|
|
92
|
+
[pillars.maintainability]
|
|
93
|
+
name = "Maintainability"
|
|
94
|
+
|
|
95
|
+
[pillars.maintainability.metrics.smelly_tests]
|
|
96
|
+
name = "Tests with a maintainability smell"
|
|
97
|
+
weight = 0.5
|
|
98
|
+
target = 5
|
|
99
|
+
bad = 40
|
|
100
|
+
|
|
101
|
+
[pillars.maintainability.metrics.long_tests]
|
|
102
|
+
name = "Tests longer than 50 lines"
|
|
103
|
+
weight = 0.2
|
|
104
|
+
target = 2
|
|
105
|
+
bad = 20
|
|
106
|
+
|
|
107
|
+
[pillars.maintainability.metrics.test_source_ratio]
|
|
108
|
+
name = "Test : source lines-of-code ratio"
|
|
109
|
+
weight = 0.3
|
|
110
|
+
target = 1.5
|
|
111
|
+
bad = 4.0
|
|
112
|
+
|
|
113
|
+
[pillars.economy]
|
|
114
|
+
name = "Economy"
|
|
115
|
+
|
|
116
|
+
[pillars.economy.metrics.no_unique_coverage]
|
|
117
|
+
name = "Tests with no unique coverage"
|
|
118
|
+
weight = 0.35
|
|
119
|
+
target = 10
|
|
120
|
+
bad = 50
|
|
121
|
+
partial_weight = 0.6
|
|
122
|
+
|
|
123
|
+
[pillars.economy.metrics.subsumed_in_kill_matrix]
|
|
124
|
+
name = "Tests subsumed in the kill matrix"
|
|
125
|
+
weight = 0.4
|
|
126
|
+
target = 5
|
|
127
|
+
bad = 35
|
|
128
|
+
|
|
129
|
+
[pillars.economy.metrics.duplicate_clusters]
|
|
130
|
+
name = "Tests in a duplicate-body cluster"
|
|
131
|
+
weight = 0.25
|
|
132
|
+
target = 2
|
|
133
|
+
bad = 20
|
|
134
|
+
partial_weight = 0.4
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Wrapper: configures the shared launcher (launcher.sh is a byte-identical copy
|
|
3
|
+
# of shared/launcher.sh).
|
|
4
|
+
set -eu
|
|
5
|
+
# Snapshot the caller's environment: the launcher restores it before exec, so
|
|
6
|
+
# its settings never overwrite an inherited variable of the same name.
|
|
7
|
+
inherited=$(export -p)
|
|
8
|
+
|
|
9
|
+
# Resolve file symlinks as well as symlinked skill directories.
|
|
10
|
+
entry=$0
|
|
11
|
+
while [ -L "$entry" ]; do
|
|
12
|
+
parent=$(CDPATH= cd -- "$(dirname -- "$entry")" && pwd)
|
|
13
|
+
entry=$(readlink "$entry")
|
|
14
|
+
case "$entry" in /*) ;; *) entry=$parent/$entry ;; esac
|
|
15
|
+
done
|
|
16
|
+
skill_dir=$(CDPATH= cd -- "$(dirname -- "$entry")" && pwd)
|
|
17
|
+
|
|
18
|
+
name=test-weigh-in env_prefix=TEST_WEIGH_IN prefix=test-weigh-in fail_code=2 engine=weigh.py
|
|
19
|
+
# No pinned venv: ignore any inherited pins/venv_key.
|
|
20
|
+
pins= venv_key=
|
|
21
|
+
. "$skill_dir/launcher.sh"
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Fixture repos for ticket tw/s6-brittleness/12: the default repo with its tests replaced and a scripted git history.
|
|
2
|
+
|
|
3
|
+
Snapshot interface the tests pin (the spec leaves the JSON keys open):
|
|
4
|
+
test_files {<repo-relative test file>: {sources: [repo-relative paths of its mapped source files, sorted],
|
|
5
|
+
brittle: true | false | null (unmeasured)}}
|
|
6
|
+
metrics.brittle_test_files {value: % of mapped test files that are brittle, score}
|
|
7
|
+
commit: null or "" when the target is not a git repository.
|
|
8
|
+
Every body below is straight-line statements inside one function, so the test (not the import) covers each line.
|
|
9
|
+
"""
|
|
10
|
+
import shutil
|
|
11
|
+
import subprocess
|
|
12
|
+
|
|
13
|
+
from fixture_repo import GIT, build_repo, git
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def body(name, n):
|
|
17
|
+
return f"def run():\n" + "".join(f" {name}{i} = {i}\n" for i in range(n))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def commit(repo, message, touch=(), extra=()):
|
|
21
|
+
"""Append a comment to each file in `touch` (never a covered line) and commit; `extra` files are new."""
|
|
22
|
+
for rel in touch:
|
|
23
|
+
with (repo / rel).open("a") as out:
|
|
24
|
+
out.write(f"# {message}\n")
|
|
25
|
+
for rel in extra:
|
|
26
|
+
(repo / rel).parent.mkdir(parents=True, exist_ok=True)
|
|
27
|
+
(repo / rel).write_text(message)
|
|
28
|
+
subprocess.run([*GIT, "add", "-A", "--", *touch, *extra], cwd=repo, check=True, capture_output=True)
|
|
29
|
+
subprocess.run([*GIT, "commit", "-q", "-m", message], cwd=repo, check=True, capture_output=True)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def suite(path, modules, test_file, test_source):
|
|
33
|
+
"""Default repo with its demo modules and tests replaced by `modules` {rel: text} and one test file."""
|
|
34
|
+
repo = build_repo(path)
|
|
35
|
+
for old in [*(repo / "tests").glob("test_*.py"), *(repo / "demo").glob("[!_]*.py")]:
|
|
36
|
+
old.unlink()
|
|
37
|
+
for rel, text in {**modules, test_file: test_source}.items():
|
|
38
|
+
(repo / rel).write_text(text)
|
|
39
|
+
git(repo, "add", "-A")
|
|
40
|
+
git(repo, "commit", "-q", "-m", "suite")
|
|
41
|
+
return repo
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
CLAIMS = "demo/claims.py"
|
|
45
|
+
TEST = "tests/test_claims.py"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def claims_repo(path):
|
|
49
|
+
"""test_claims covers ~82 lines of claims.py and ~18 of other.py (other.py is under 20%, so not mapped)."""
|
|
50
|
+
return suite(
|
|
51
|
+
path,
|
|
52
|
+
{CLAIMS: body("c", 82), "demo/other.py": body("o", 18)},
|
|
53
|
+
TEST,
|
|
54
|
+
"from demo import claims, other\n\n\ndef test_claims():\n claims.run()\n other.run()\n",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def history(repo, both, claims_only):
|
|
59
|
+
"""After the suite commit (which changed both files): `both` more commits changing claims.py and the test, then `claims_only` changing claims.py alone."""
|
|
60
|
+
for i in range(both):
|
|
61
|
+
commit(repo, f"both {i}", [CLAIMS, TEST])
|
|
62
|
+
for i in range(claims_only):
|
|
63
|
+
commit(repo, f"claims {i}", [CLAIMS])
|
|
64
|
+
return repo
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def board_repo(path):
|
|
68
|
+
"""test_board covers 300 lines: 260 in board.py and 40 in config.py (13%)."""
|
|
69
|
+
return suite(
|
|
70
|
+
path,
|
|
71
|
+
{"demo/board.py": body("b", 260), "demo/config.py": body("g", 40)},
|
|
72
|
+
"tests/test_board.py",
|
|
73
|
+
"from demo import board, config\n\n\ndef test_board():\n board.run()\n config.run()\n",
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def without_git(repo):
|
|
78
|
+
shutil.rmtree(repo / ".git")
|
|
79
|
+
return repo
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
collect_ignore_glob = ["testdata/*"]
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from fixture_repo import build_repo, weigh
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.fixture(autouse=True, scope="session")
|
|
9
|
+
def no_browser():
|
|
10
|
+
"""The engine opens the dashboard unless --no-open: a no-op BROWSER keeps every test from opening a real tab.
|
|
11
|
+
|
|
12
|
+
Session scope sets it before any module fixture runs the engine."""
|
|
13
|
+
with pytest.MonkeyPatch.context() as patch:
|
|
14
|
+
patch.setenv("BROWSER", "true")
|
|
15
|
+
yield
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.fixture(scope="session")
|
|
19
|
+
def cache(tmp_path_factory):
|
|
20
|
+
return tmp_path_factory.mktemp("overlay-cache")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@pytest.fixture
|
|
24
|
+
def home(tmp_path):
|
|
25
|
+
(tmp_path / "home").mkdir()
|
|
26
|
+
return tmp_path / "home"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.fixture
|
|
30
|
+
def run(tmp_path, home, cache):
|
|
31
|
+
"""Build a repo (kwargs for build_repo, `name` picks the folder) and weigh it; returns (repo, result)."""
|
|
32
|
+
def _run(*flags, name="demo", now=None, **repo_kwargs):
|
|
33
|
+
repo = build_repo(tmp_path / "work" / name, **repo_kwargs)
|
|
34
|
+
return repo, weigh(repo, home, *flags, cache=cache, now=now)
|
|
35
|
+
return _run
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Builds fixture target repos from testdata/default_repo and runs weigh.py against them.
|
|
2
|
+
|
|
3
|
+
Snapshot interface the tests pin (the spec leaves the JSON keys open):
|
|
4
|
+
commit (short sha), dirty (bool), pytest_args (str), pytest_version, python_version,
|
|
5
|
+
inventory {tests, cases, test_files, test_lines, source_lines, runtime_seconds}.
|
|
6
|
+
Environment: TEST_WEIGH_IN_NOW=<ISO UTC> freezes the clock used to name snapshots;
|
|
7
|
+
TEST_WEIGH_IN_CACHE_DIR holds the overlay.
|
|
8
|
+
"""
|
|
9
|
+
import functools
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import shutil
|
|
13
|
+
import subprocess
|
|
14
|
+
import sys
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
HERE = Path(__file__).resolve().parent
|
|
18
|
+
WEIGH = HERE.parent / "weigh.py"
|
|
19
|
+
TEMPLATE = HERE / "testdata" / "default_repo"
|
|
20
|
+
FAKECLOCK = (
|
|
21
|
+
"import pytest\n"
|
|
22
|
+
"@pytest.hookimpl(hookwrapper=True)\n"
|
|
23
|
+
"def pytest_runtest_makereport(item, call):\n"
|
|
24
|
+
" rep = (yield).get_result()\n"
|
|
25
|
+
" if rep.when == 'call':\n"
|
|
26
|
+
" rep.duration = 1.125\n"
|
|
27
|
+
)
|
|
28
|
+
GIT = ["git", "-c", "user.name=t", "-c", "user.email=t@example.com", "-c", "commit.gpgsign=false"]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def git(root, *args):
|
|
32
|
+
return subprocess.run([*GIT, *args], cwd=root, check=True, capture_output=True, text=True).stdout.strip()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _pad(files, total):
|
|
36
|
+
have = sum(len(f.read_text().splitlines()) for f in files)
|
|
37
|
+
with files[0].open("a") as out:
|
|
38
|
+
out.writelines(f"_PAD_{i} = {i}\n" for i in range(total - have))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@functools.cache
|
|
42
|
+
def uv():
|
|
43
|
+
"""uv for the fixtures and the engine: TEST_WEIGH_IN_UV, then PATH, then the pinned uv that the skill's launcher downloads (CI has no uv on PATH)."""
|
|
44
|
+
found = os.environ.get("TEST_WEIGH_IN_UV") or shutil.which("uv")
|
|
45
|
+
if found:
|
|
46
|
+
return found
|
|
47
|
+
subprocess.run(["sh", str(HERE.parent / "run.sh"), "--help"], check=True, capture_output=True)
|
|
48
|
+
cache = os.environ.get("TEST_WEIGH_IN_CACHE_DIR") or Path(os.environ.get("XDG_CACHE_HOME") or Path.home() / ".cache") / "test-weigh-in"
|
|
49
|
+
return str(next(Path(cache).glob("uv/*/*/uv")))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _venv(repo, pytest_version):
|
|
53
|
+
py = repo / ".venv" / "bin" / "python"
|
|
54
|
+
subprocess.run([uv(), "venv", "-q", "--python", "3.12", str(repo / ".venv")], check=True)
|
|
55
|
+
subprocess.run([uv(), "pip", "install", "-q", "--python", str(py), f"pytest=={pytest_version}"], check=True)
|
|
56
|
+
site = next((repo / ".venv" / "lib").glob("python*/site-packages"))
|
|
57
|
+
(site / "fakeclock.py").write_text(FAKECLOCK)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def build_repo(path, origin="git@github.com:jesdi/demo.git", pytest_version="8.3.5", test_lines=None, source_lines=None):
|
|
61
|
+
path = Path(path)
|
|
62
|
+
shutil.copytree(TEMPLATE, path)
|
|
63
|
+
if test_lines:
|
|
64
|
+
_pad(sorted((path / "tests").glob("test_*.py")), test_lines)
|
|
65
|
+
if source_lines:
|
|
66
|
+
_pad([path / "demo" / "board.py", path / "demo" / "config.py"], source_lines)
|
|
67
|
+
_venv(path, pytest_version)
|
|
68
|
+
git(path, "init", "-q", "-b", "main")
|
|
69
|
+
if origin:
|
|
70
|
+
git(path, "remote", "add", "origin", origin)
|
|
71
|
+
git(path, "add", "-A")
|
|
72
|
+
git(path, "commit", "-q", "-m", "init")
|
|
73
|
+
return path
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def short_sha(repo):
|
|
77
|
+
return git(repo, "rev-parse", "--short", "HEAD")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def site_files(repo):
|
|
81
|
+
site = next((repo / ".venv" / "lib").glob("python*/site-packages"))
|
|
82
|
+
return sorted(str(p.relative_to(site)) for p in site.rglob("*"))
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def weigh(repo, home, *flags, cache, now=None):
|
|
86
|
+
env = {k: v for k, v in os.environ.items() if k not in ("VIRTUAL_ENV", "PYTHONPATH")}
|
|
87
|
+
env.update(HOME=str(home), TEST_WEIGH_IN_CACHE_DIR=str(cache), TEST_WEIGH_IN_UV=uv())
|
|
88
|
+
env.setdefault("UV_CACHE_DIR", subprocess.run([uv(), "cache", "dir"], capture_output=True, text=True).stdout.strip())
|
|
89
|
+
if now:
|
|
90
|
+
env["TEST_WEIGH_IN_NOW"] = now
|
|
91
|
+
return subprocess.run([sys.executable, str(WEIGH), str(repo), *flags], env=env, capture_output=True, text=True)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def snapshots(home, key):
|
|
95
|
+
return sorted((Path(home) / ".test-weigh-in" / key).glob("*.json"))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def load(path):
|
|
99
|
+
return json.loads(Path(path).read_text())
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Fixture repos for ticket tw/s7-mutation/14, the default repo with its sources and tests replaced.
|
|
2
|
+
|
|
3
|
+
Every mutated function has exactly the mutants named here (mutmut 3.8.1: one for a `return x <op> y`, two per `a = b <op> c`).
|
|
4
|
+
|
|
5
|
+
sample_repo demo/parser.py parse(t, u): six `name = prev + u` lines, 12 mutants on 6 lines; noop(): 1 mutant
|
|
6
|
+
tests test_parse_ok and test_parse_edge each kill every mutant of parse; test_noop kills noop's
|
|
7
|
+
matrix_repo demo/ops.py seven one-mutant functions: add, sub, mul (x * y: with y == 1 the mutant x / y survives),
|
|
8
|
+
pack, unpack, wrap, unwrap
|
|
9
|
+
tests test_a: asserts add, sub and mul: kills the add and sub mutants, not mul's
|
|
10
|
+
test_b: asserts add and sub: kills the same two
|
|
11
|
+
test_session_roundtrip: calls pack, unpack, wrap, unwrap and asserts `is not None`: kills none
|
|
12
|
+
shift_repo demo/shift.py shift(x, y): 1 mutant
|
|
13
|
+
tests test_parse_invalid and test_shift_other both kill it
|
|
14
|
+
"""
|
|
15
|
+
from fixture_repo import build_repo, git
|
|
16
|
+
|
|
17
|
+
PARSER = "def parse(t, u):\n" + "".join(f" {n} = {p} + u\n" for n, p in zip("abcdef", "tabcde")) + " return f\n\n\ndef noop():\n return 7\n"
|
|
18
|
+
SAMPLE_TESTS = '''from demo import parser
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_parse_ok():
|
|
22
|
+
assert parser.parse(1, 2) == 13
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_parse_edge():
|
|
26
|
+
assert parser.parse(0, 1) == 6
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_noop():
|
|
30
|
+
assert parser.noop() == 7
|
|
31
|
+
'''
|
|
32
|
+
OPS = "".join(f"def {n}(x, y):\n return x {op} y\n\n\n" for n, op in
|
|
33
|
+
(("add", "+"), ("sub", "-"), ("mul", "*"), ("pack", "+"), ("unpack", "-"), ("wrap", "*"), ("unwrap", "/"))).rstrip() + "\n"
|
|
34
|
+
MATRIX_TESTS = '''from demo import ops
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_a():
|
|
38
|
+
assert ops.add(1, 2) == 3
|
|
39
|
+
assert ops.sub(3, 1) == 2
|
|
40
|
+
assert ops.mul(3, 1) == 3
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_b():
|
|
44
|
+
assert ops.add(2, 2) == 4
|
|
45
|
+
assert ops.sub(5, 1) == 4
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_session_roundtrip():
|
|
49
|
+
assert ops.pack(1, 2) is not None
|
|
50
|
+
assert ops.unpack(1, 2) is not None
|
|
51
|
+
assert ops.wrap(1, 2) is not None
|
|
52
|
+
assert ops.unwrap(1, 2) is not None
|
|
53
|
+
'''
|
|
54
|
+
SHIFT = "def shift(x, y):\n return x + y\n"
|
|
55
|
+
SHIFT_TESTS = '''from demo import shift
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_parse_invalid():
|
|
59
|
+
assert shift.shift(1, 2) == 3
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_shift_other():
|
|
63
|
+
assert shift.shift(2, 2) == 4
|
|
64
|
+
'''
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def replaced(path, source, tests):
|
|
68
|
+
repo = build_repo(path)
|
|
69
|
+
for old in [*(repo / "tests").glob("test_*.py"), *(repo / "demo").glob("[!_]*.py")]:
|
|
70
|
+
old.unlink()
|
|
71
|
+
(repo / "demo" / source[0]).write_text(source[1])
|
|
72
|
+
(repo / "tests" / tests[0]).write_text(tests[1])
|
|
73
|
+
git(repo, "add", "-A")
|
|
74
|
+
git(repo, "commit", "-q", "-m", "fixture")
|
|
75
|
+
return repo
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def sample_repo(path):
|
|
79
|
+
return replaced(path, ("parser.py", PARSER), ("test_parser.py", SAMPLE_TESTS))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def matrix_repo(path):
|
|
83
|
+
return replaced(path, ("ops.py", OPS), ("test_ops.py", MATRIX_TESTS))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def shift_repo(path):
|
|
87
|
+
return replaced(path, ("shift.py", SHIFT), ("test_shift.py", SHIFT_TESTS))
|