Skip to content

r.support: add coverage for metadata, history and null-file flags - #7863

Merged
petrasovaa merged 10 commits into
OSGeo:mainfrom
Valyrian-Code:r.support-more-coverage
Sep 23, 2026
Merged

petrasovaa merged 10 commits into
OSGeo:mainfrom
Valyrian-Code:r.support-more-coverage

Conversation

@Valyrian-Code

Copy link
Copy Markdown
Contributor

Follow-up to #7821, adding coverage for the rest of r.support per the review there. This is stacked on #7821 and should be merged after it (the diff below will settle once that one lands).

Adds tests for:

  • title, units, vdatum, source1/source2 and description, all read back through r.info
  • history= appending a line rather than replacing prior ones
  • savehistory writing the current history to a file, and loadhistory restoring it onto another map (loadhistory replaces the target's history rather than appending to it)
  • the -n flag (create/reset the null file) and -d flag (delete the null file): on a map with an explicit null() cell, -n clears the reported null count and -d restores it, since removing the null file falls back to the implicit null sentinel in the raw cell values

Not covered: the -s flag (update statistics). Every normal write path (r.mapcalc, r.in.ascii, ...) already computes correct range/stats on write, so producing a genuinely stale range to verify -s fixing it would need writing raw cell data below the normal API, which felt too fragile for this PR. Happy to revisit if there's a clean way to do it.

Verified locally, all 9 tests pass.

Valyrian-Code and others added 6 commits August 11, 2026 21:56
Cover the same four cases as the gunittest testsuite: setting and removing a
semantic label at once fails, an over-long label is rejected, r.support
assigns the semantic label, and the -b flag clears it. Uses a tmp_path session
fixture with a synthetic raster and reads the label back via r.info
format=json instead of the ctypes library bindings.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
test_semantic_label_and_removal_are_exclusive used tools without creating
it in the test, which flake8 flags as F821 and which raises NameError at
run time.
Copilot AI lite review requested due to automatic review settings August 28, 2026 04:14
@github-actions github-actions Bot added raster Related to raster data processing Python Related code is in Python module tests Related to Test Suite labels Aug 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands automated pytest coverage for r.support to include additional metadata fields, history import/export behaviors, and null-file maintenance flags, as a follow-up to prior migration work.

Changes:

  • Adds pytest tests validating metadata fields (title, units, vdatum, sources, description) via r.info JSON output.
  • Adds tests for history behaviors: append semantics, savehistory export, and loadhistory restore/replace semantics.
  • Adds tests covering null-file maintenance flags -n (reset) and -d (delete) using r.univar null cell counts, and removes the legacy gunittest testsuite file.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
raster/r.support/testsuite/test_r_support.py Removes legacy gunittest-based semantic label tests (superseded by pytest coverage).
raster/r.support/tests/r_support_test.py Adds pytest coverage for metadata fields, history behaviors, and null-file flags in r.support.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@echoix

echoix commented Aug 28, 2026

Copy link
Copy Markdown
Member

@Valyrian-Code Solve conflicts please ;)

@echoix echoix added the conflicts/needs rebase Rebase to or merge with the latest base branch is needed label Sep 5, 2026
…rage

# Conflicts:
#	raster/r.support/tests/r_support_test.py
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Merged main now that #7821 landed, this PR is just the 5 new tests on top of it.

@ninsbl ninsbl removed the conflicts/needs rebase Rebase to or merge with the latest base branch is needed label Sep 10, 2026
echoix
echoix previously approved these changes Sep 10, 2026
.strip() masked the trailing newline savehistory writes after each
history line (main.c fprintf(fp, "%s\n", ...)), so the test would not
notice extra blank lines or other whitespace regressions in the output
file. Assert the exact expected content instead.
ninsbl
ninsbl previously approved these changes Sep 14, 2026
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

@echoix the Copilot point is fixed and @ninsbl has approved since. Could you take another look?

Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
@petrasovaa
petrasovaa enabled auto-merge (squash) September 23, 2026 02:11
@petrasovaa
petrasovaa merged commit cc18e7f into OSGeo:main Sep 23, 2026
26 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Sep 23, 2026
@Valyrian-Code
Valyrian-Code deleted the r.support-more-coverage branch October 2, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants