mudlet/cmake
Vadim Peretokin 2d4d9b9ca5
infrastructure: harden the Widgets audit script and refresh its baseline (#9516)
#### Brief overview of PR changes/additions

Follow-up to #9508. Hardens `cmake/audit-core-widgets.sh` against five
silent-wrong-count failure modes (each reproduced by running the script
against crafted inputs), and refreshes the committed baseline/report to
the current count.

- **CMakeLists parser** now strips `#` comments and a trailing `\r`, and
tracks multi-line `list(APPEND mudlet_SRCS ...)` blocks. Previously a
`)` inside a comment truncated the file list, a commented-out filename
got audited, a wrapped `APPEND` dropped its continuation lines, and a
CRLF checkout only partially parsed.
- **Comment/string stripper** now matches a `/* ... */` comment whose
body contains `*` (the `/** ... */` one-liner that used to latch the
scanner into comment mode and silently swallow the rest of a file), and
hard-fails (exit 2) on an unterminated comment at EOF rather than
under-counting.
- **`--enforce`** is now a real gate: a source file listed in
`CMakeLists.txt` but missing from disk is fatal, and the baseline is
strict-parsed (bare integer on line 1). The old `tr -cd 0-9` pooled
every digit in the file, so a `# updated 2026-07-20` comment produced a
baseline like `20260720158` that out-ranked any real count and passed
forever.
- **Qt sanity**: if the `QtGui`/`QtCore` header listings come out empty
while `QtWidgets` is non-empty (a partial/broken Qt), the script aborts
instead of miscounting relocated forwarder headers (`qaction.h`,
`qshortcut.h`, ...) as Widgets dependencies.
- **Baseline + report refreshed** from `160` to `158`: #9507 decoupled
the telnet engine from UI dialogs after the original report was
generated, so `ctelnet.cpp`/`ctelnet.h` are now clean.

The script stays POSIX `sh`, deterministic (`LC_ALL=C`), and fast
(~0.2s). The parser change is count-neutral: old and new parsers produce
an identical 392-file list on the current `src/CMakeLists.txt`.

#### Motivation for adding to Mudlet

The audit becomes a CI gate once the count reaches 0 (#8681, #9011).
Before that, it must never report a wrong number quietly - every one of
these paths could have made the count drift (up or down) with no visible
error, which would erode trust in the gate. Loud failure beats a
silently passing check.

#### Other info (issues closed, discussion etc)

Follow-up to #9508. No build required (shell + docs only). Self-tested
with a 17-assertion harness that crafts each proven failure input and
confirms the fixed script returns the correct count or exits 2, while
the pre-fix script mis-parses.

**Test case:**

```
bash cmake/audit-core-widgets.sh --summary
# expected: mudlet_core Qt Widgets audit: 158 of 392 files depend on Qt Widgets

bash cmake/audit-core-widgets.sh --enforce
# expected: mudlet_core Qt Widgets audit: 158 offending files (baseline 158).  (exit 0)
```

Assisted-by: Claude:claude-opus-4-8
2026-07-26 18:05:59 +02:00
..
audit-core-widgets.sh infrastructure: harden the Widgets audit script and refresh its baseline (#9516) 2026-07-26 18:05:59 +02:00
core-widgets-baseline.txt infrastructure: harden the Widgets audit script and refresh its baseline (#9516) 2026-07-26 18:05:59 +02:00
FindHUNSPELL.cmake Enhance: enable builds in a full Windows MSYS2 environment (#3889) 2020-08-25 21:01:41 +02:00
FindLua51.cmake Add Linux build to Github Actions (#3657) 2020-04-21 06:04:47 +02:00
FindONIGURUMA.cmake Infrastructure: update edbee-lib submodule & use system oniguruma if present (#9156) 2026-04-06 16:28:46 +01:00
FindPCRE.cmake Add Windows 64bit build to Github Actions (#4348) 2020-11-13 20:30:10 +01:00
FindPCRE2.cmake Fix: handle CMake aliasing problems when PCRE2::8BIT is itself an alias (#9128) 2026-03-30 00:06:42 +01:00
FindPUGIXML.cmake Infrastructure: update edbee-lib submodule & use system oniguruma if present (#9156) 2026-04-06 16:28:46 +01:00
FindSparkle.cmake Fix finding Sparkle with CMake (#4144) 2020-10-09 14:31:21 +02:00
FindYAJL.cmake Enhance: enable builds in a full Windows MSYS2 environment (#3889) 2020-08-25 21:01:41 +02:00
FindZIP.cmake Enhance: enable builds in a full Windows MSYS2 environment (#3889) 2020-08-25 21:01:41 +02:00
FindZZIPLIB.cmake Fix 50 typos in the rest of the code (#5389) 2021-08-22 07:19:30 +02:00
IncludeOptionalModule.cmake Improve: add a new, experimental 3D mapper (#8087) 2025-08-29 12:15:48 +02:00
InitGitSubmodule.cmake Infrastructure: allow CMake initGitSubmodule.cmake to act recursively (#8717) 2025-12-29 15:16:28 +00:00
StaticAnalysis.cmake Add: Optional static analysis during build (#8708) 2025-12-28 23:12:20 +01:00