Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,14 @@ glpython hint that it probably should `return` instead. Texts: `runTests`,
**Coverage** (capability `coverage`, off by default): when all examples pass,
the report also lists which lines of the tested file's functions no example
executed, each with its code («Zeile 11: `return "ungenügend"`»; consecutive
lines of one function as «Zeilen 8–12:»). Counted are the statements in
lines of one function as «Zeilen 8–12:»), in a pale orange box like their
marks in the editor. Counted are the statements in
function bodies (also methods and nested functions), as Python's own `trace`
module counts them during the examples - not `def` lines, docstrings, code
outside functions, or other files such as libraries. With the editor, the same
lines are marked in it (line background and a bar in the gutter) until the
file is edited or the program runs again. When every line ran, a neutral note
says so and that this doesn't show whether the examples check the edge cases:
file is edited or the program runs again. When every line ran, a light blue
note (`--glp-info`, never green like «bestanden») says so and that this doesn't show whether the examples check the edge cases:
coverage finds untested code, not wrong code. Recorded with `sys.monitoring`,
each line once, so it doesn't slow the examples down. Texts:
`testsUncoveredHeading`, `testsUncoveredLines`, `testsAllCovered`.
Expand Down Expand Up @@ -369,14 +370,15 @@ and monospace fonts, no web fonts). A host can override any of them:
| Variable | Role |
|---|---|
| `--glp-bg` | panel background |
| `--glp-surface` | code in the visualizer, output, REPL; coverage after Tests |
| `--glp-surface` | code in the visualizer, output, REPL |
| `--glp-border` | decorative borders and separator lines |
| `--glp-border-control` | borders of controls, call boxes in box mode; coverage after Tests (its bar) |
| `--glp-border-control` | borders of controls, call boxes in box mode |
| `--glp-text`, `--glp-text-muted` | text and code; line numbers, step counter, secondary info, connector lines |
| `--glp-accent`, `--glp-on-accent` | active mode, scrubber, focus, primary button; text on it |
| `--glp-current`, `--glp-current-outline` | current subexpression and new value, current line; next step (dashed) |
| `--glp-error`, `--glp-error-bg` | errors, failing tests, «Erhalten · Erwartet» |
| `--glp-warning`, `--glp-warning-bg` | hints; the coverage marks in the editor |
| `--glp-warning`, `--glp-warning-bg` | hints; lines no example ran (coverage after Tests, and their marks in the editor) |
| `--glp-info`, `--glp-info-bg` | information that isn't a result: every line ran (coverage after Tests) - never green |
| `--glp-success` | passed tests, runtime ready |
| `--glp-syntax-keyword`, `-string`, `-number`, `-comment` | syntax colours (names, operators, brackets use `--glp-text`) |
| `--glp-font-code`, `--glp-font-ui`, `--glp-radius` | fonts and corner radius |
Expand Down
4 changes: 2 additions & 2 deletions src/GlPythonWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@
{parens && '('}
{lines.map((line, index) => {
const lineStart = cursor
cursor += line.length + 1

Check warning on line 730 in src/GlPythonWorkspace.tsx

View workflow job for this annotation

GitHub Actions / check

react(immutability)

src/GlPythonWorkspace.tsx:730:11: Cannot reassign variable after render completes
return <Fragment key={index}>{index > 0 && '\n'}{renderSegments(lineSegments(line, lineStart))}</Fragment>
})}
{parens && ')'}
Expand Down Expand Up @@ -887,9 +887,9 @@
}

// Coverage after Tests that all passed: the lines no example executed, each
// with its code, or a neutral note when every line ran.
// with its code, or an informative note when every line ran.
function TestCoverageView({ gaps, t }: { gaps: CoverageGap[]; t: CoreStrings }) {
if (gaps.length === 0) return <p className="test-coverage" role="note">{t.testsAllCovered ?? 'Every line of the functions was run by at least one example. This doesn\'t show whether the examples also check the edge cases.'}</p>
if (gaps.length === 0) return <p className="test-coverage test-coverage--complete" role="note">{t.testsAllCovered ?? 'Every line of the functions was run by at least one example. This doesn\'t show whether the examples also check the edge cases.'}</p>
const label = (gap: CoverageGap) => t.testsUncoveredLines?.(gap.start, gap.end) ?? (gap.start === gap.end ? `Line ${gap.start}:` : `Lines ${gap.start}\u2013${gap.end}:`)
return (
<div className="test-coverage" role="note">
Expand Down
10 changes: 7 additions & 3 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
--glp-error-bg: #FDECEA;
--glp-warning: #8A4B00;
--glp-warning-bg: #FFF4E5;
--glp-info: #1D5B9A;
--glp-info-bg: #E3EEFA;
--glp-success: #1E6B3A;
--glp-syntax-keyword: #1F3A5F;
--glp-syntax-string: #8A3B12;
Expand Down Expand Up @@ -309,9 +311,11 @@
.error-hint code { font: 600 1em var(--glp-font-code); }
.visual-error-hint { padding: 0 8px 4px; }
.visual-error-hint .error-hint { margin: 0; }
/* Coverage after Tests: neutral, neither a success nor a warning (covered
code can still be wrong). */
.test-coverage { margin: 0 0 8px; padding: 6px 10px; color: var(--glp-text); background: var(--glp-surface); border-left: 3px solid var(--glp-border-control); border-radius: var(--glp-radius); font: 13px/1.5 var(--glp-font-ui); }
/* Coverage after Tests: lines no example ran in the colours of their marks
in the editor; every line ran as information in blue - never green, since
covered code can still be wrong. */
.test-coverage { margin: 0 0 8px; padding: 6px 10px; color: var(--glp-text); background: var(--glp-warning-bg); border-left: 3px solid var(--glp-warning); border-radius: var(--glp-radius); font: 13px/1.5 var(--glp-font-ui); }
.test-coverage--complete { background: var(--glp-info-bg); border-left-color: var(--glp-info); }
.test-coverage-heading { margin: 0 0 2px; }
.test-coverage ul { margin: 0; padding: 0; list-style: none; }
.test-coverage code { font: 13px/1.5 var(--glp-font-code); }
Expand Down
Loading