Skip to content

lib/cluster: Add pytest ctypes test suite (for LLVM coverage testing) - #698

Closed
echoix wants to merge 6 commits into
claude/llvm-coverage-linux-pytestfrom
claude/grass-llvm-coverage-pytest-grju4k
Closed

echoix wants to merge 6 commits into
claude/llvm-coverage-linux-pytestfrom
claude/grass-llvm-coverage-pytest-grju4k

Conversation

@echoix

@echoix echoix commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Summary

Cherry-picks the lib/cluster pytest ctypes test suite from
OSGeo/grass#7919 (commit
d60b222) onto the LLVM source-based coverage branch
(claude/llvm-coverage-linux-pytest, #681), so the new coverage
instrumentation can be exercised against a real, recently-added test
suite before that mechanism merges.

lib/cluster had no dedicated test coverage before OSGeo#7919. This PR adds
no new tests of its own; it lets the instrumented pytest CI job in
#681 build and run against these 20 new tests so their C-library
coverage (I_cluster_begin, I_cluster_point, I_cluster_means,
I_cluster_assign, I_cluster_reassign, I_cluster_sum2,
I_cluster_separation, I_cluster_distinct, I_cluster_merge,
I_cluster_reclass, I_cluster_exec, etc.) shows up in the LLVM/lcov
export.

Both branches shared the same base commit (4bb960b), so the cherry-pick
applied cleanly with no conflicts.

Testing

This PR is itself a coverage smoke test: the intent is for the
instrumented pytest CI job from #681 to run against these tests and
show lib/cluster coverage in the exported lcov/Codecov output.

AI Disclosure

Assembled with AI assistance (Claude Code): fetched the two source
branches, cherry-picked the test commit, and drafted this description.
The test suite's own content and verification are from OSGeo#7919
and are not the product of this session.


🤖 Generated with Claude Code

https://claude.ai/code/session_01ToEfp9Bpb3rkdhfcg8Wgei


Generated by Claude Code

Instrument the Ubuntu build with clang under GRASS_LLVM_COVERAGE,
enabled only on the Python 3.13 matrix cell so the 3.11 cell keeps the
default gcc build. LLVM_PROFILE_FILE encodes pid and a hash per
binary so xdist workers and C-tool subprocesses never collide on one
file, and -fprofile-update=atomic makes counter increments atomic in
OpenMP-parallel code (r.univar). Both were needed to make merged
coverage deterministic between runs.

utils/llvm_coverage_export.sh merges .profraw into .profdata and
exports lcov for Codecov. It passes the file list to llvm-profdata via
-f instead of argv, since a full test run's per-process .profraw
count overflows the shell argument-list limit. utils/
coverage_disk_usage.sh logs .profraw count/size and disk usage before
the merge for observability.

Also fixes coverage_mapper.py running before coverage combine, which
left it unable to read a .coverage file that parallel mode had not
created yet.

This is the Linux/pytest slice of #674, which also instruments macOS;
macOS is out of scope here.

AI assistance (Claude Code) helped draft the workflow and script
changes.
The script's env-var defaults already made it runnable outside CI;
spell that out so it doesn't read as CI-only.
@echoix
echoix added this pull request to stack #699 September 18, 2026 19:43
@echoix
echoix removed this pull request from stack #699 September 18, 2026 19:43
@echoix
echoix added this pull request to stack #700 September 18, 2026 19:44
@echoix
echoix force-pushed the claude/grass-llvm-coverage-pytest-grju4k branch from 48b93a8 to c840379 Compare September 18, 2026 19:44
@echoix
echoix force-pushed the claude/llvm-coverage-linux-pytest branch from 268712c to a8a97e7 Compare October 1, 2026 00:24
@echoix echoix closed this Oct 1, 2026
@echoix
echoix deleted the claude/grass-llvm-coverage-pytest-grju4k branch October 1, 2026 00:25
@echoix
echoix removed this pull request from stack #700 October 1, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants