From f46532b63161855c286f882b8108fe1c8ef3c818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Vogel?= <104342347+cedricvogel-leo@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:29:02 +0100 Subject: [PATCH] Coverage report: orange for untested lines, blue for full coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two states of the coverage after Tests can now be told apart at a glance. Lines no example ran get the colours of their marks in the IDE's editor (--glp-warning-bg, --glp-warning bar). Full coverage gets a light blue info box (new tokens --glp-info-bg #E3EEFA, --glp-info #1D5B9A): distinct from the grey console, and never green like «bestanden», since covered code can still be wrong. Texts and behaviour are unchanged. Co-Authored-By: Claude Opus 5.5 --- README.md | 14 ++++++++------ src/GlPythonWorkspace.tsx | 4 ++-- src/style.css | 10 +++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9624b59..2947880 100644 --- a/README.md +++ b/README.md @@ -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`. @@ -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 | diff --git a/src/GlPythonWorkspace.tsx b/src/GlPythonWorkspace.tsx index d57378c..7ed0515 100644 --- a/src/GlPythonWorkspace.tsx +++ b/src/GlPythonWorkspace.tsx @@ -887,9 +887,9 @@ function TestReportView({ report, t, onVisualizeExample }: { report: TestReport; } // 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

{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.'}

+ if (gaps.length === 0) return

{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.'}

const label = (gap: CoverageGap) => t.testsUncoveredLines?.(gap.start, gap.end) ?? (gap.start === gap.end ? `Line ${gap.start}:` : `Lines ${gap.start}\u2013${gap.end}:`) return (
diff --git a/src/style.css b/src/style.css index a236ddb..b52b1da 100644 --- a/src/style.css +++ b/src/style.css @@ -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; @@ -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); }