Skip to content

Test presence: add bats coverage for add-submodules, sync_repo_master, Weblate POST.#44

Merged
wpak-ai merged 2 commits into
cppalliance:masterfrom
whisper67265:feature/test-presence
Jul 2, 2026
Merged

Test presence: add bats coverage for add-submodules, sync_repo_master, Weblate POST.#44
wpak-ai merged 2 commits into
cppalliance:masterfrom
whisper67265:feature/test-presence

Conversation

@whisper67265

@whisper67265 whisper67265 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Close #37.

Summary by CodeRabbit

  • New Features
    • Extended coverage for translation and documentation sync scenarios, including more accurate verification of Weblate-triggered updates and submodule behavior.
  • Bug Fixes
    • Strengthened validation for edge cases like non-fast-forward push failures, ensuring clear failure behavior and correct branch state handling.
    • Improved reliability checks around Weblate HTTP responses and curl timeout handling.
  • Tests
    • Added a local Weblate-like HTTP mock and curl timeout simulation, plus new Bats suites for sync_repo_master, translations submodule updates, and trigger_weblate.
    • Enhanced existing assertions for submodule-related success paths.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4f675e0e-2d88-47ea-8f2d-4ef06c728eab

📥 Commits

Reviewing files that changed from the base of the PR and between 11c6cf5 and fe12ca5.

📒 Files selected for processing (3)
  • tests/helpers/http_mock.bash
  • tests/test_sync_repo_master.bats
  • tests/test_trigger_weblate.bats
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/test_sync_repo_master.bats
  • tests/test_trigger_weblate.bats
  • tests/helpers/http_mock.bash

📝 Walkthrough

Walkthrough

Adds Bats coverage for sync_repo_master, translations submodule management, and trigger_weblate, plus shared test helpers for a mock Weblate endpoint and curl timeout stubbing. Updates the lint workflow to install jq and curl, and extends one existing submodule assertion.

Changes

Test infrastructure and coverage

Layer / File(s) Summary
CI dependency installation
.github/workflows/lint.yml
The lint workflow test job installs bats, jq, and curl together.
Shared test helper infrastructure
tests/helpers/http_mock.bash, tests/helpers/test_helper.bash
Adds a local Weblate-style HTTP mock server, request logging, configurable responses, a curl timeout stub, and a helper facade that sources shared test modules.
sync_repo_master test coverage
tests/test_sync_repo_master.bats
New Bats coverage verifies source sync, idempotent re-runs, and non-fast-forward rejection handling.
Translations submodule test coverage
tests/test_translations_submodule.bats, tests/test_add_one_submodule.bats
New Bats coverage verifies bot config, .gitmodules detection, submodule registration/update, commit-and-push behavior, missing-remote failure handling, and one added mirror commit-message assertion.
trigger_weblate test coverage
tests/test_trigger_weblate.bats
New Bats coverage verifies HTTP 202/200 success cases, HTTP 403/409 failures, and curl timeout handling against the mock endpoint.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: henry0816191, wpak-ai

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding Bats coverage for add-submodules, sync_repo_master, and Weblate POST.
Linked Issues check ✅ Passed The added tests and workflow update satisfy all #37 acceptance criteria for sync_repo_master, translations submodule, trigger_weblate, and CI deps.
Out of Scope Changes check ✅ Passed The changes are confined to test coverage, shared test helpers, and the lint workflow dependency update, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/test_sync_repo_master.bats (1)

34-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer bats' built-in run helper over manual set +e/set -e.

The repeated set +e; cmd; status=$?; set -e pattern across all three tests can be replaced with bats' run helper, which captures $status/$output without disabling errexit and is the idiomatic bats pattern.

♻️ Proposed refactor (example for first test)
-  set +e
-  sync_repo_master "$dest_repo" "$sub_clone" "$libs_ref"
-  status=$?
-  set -e
-
-  [ "$status" -eq 0 ]
+  run sync_repo_master "$dest_repo" "$sub_clone" "$libs_ref"
+  [ "$status" -eq 0 ]

Apply the same simplification to the other two @test blocks.

Bats includes a run helper that invokes its arguments as a command, saves the exit status and output into special global variables, and then returns with a 0 status code so you can continue to make assertions in your test case.

Also applies to: 56-59, 74-77

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_sync_repo_master.bats` around lines 34 - 37, The three `@test`
blocks in tests/test_sync_repo_master.bats are using manual set +e / set -e to
capture exit status; replace that pattern with bats’ built-in run helper so the
command output and exit code are captured idiomatically without toggling
errexit. Update the sync_repo_master call in each test to use run, then assert
against the special bats variables ($status and any relevant output) in the
existing test flow, keeping the same behavior across all three blocks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/helpers/http_mock.bash`:
- Around line 25-30: The mock server startup in http_mock.bash has a
port-selection race because the ephemeral port is chosen before HTTPServer binds
it. Update the server process entrypoint and readiness flow so HTTPServer binds
to port 0 itself, then communicate the assigned port back to Bash and use that
value for polling/connect logic. Keep the fix centered around the mock server
startup and readiness loop symbols that manage port selection and server
creation.

In `@tests/test_trigger_weblate.bats`:
- Around line 38-41: The JSON checks in the trigger Weblate test are too loose
and do not verify the payload shape. Tighten the assertions in the test that
uses body_json and jq so `add_or_update.en` is validated as an array containing
the expected entries, and `extensions` is validated as the expected JSON array
structure rather than just existing. Use the existing test block in
tests/test_trigger_weblate.bats to make the contract explicit and catch shape
regressions earlier.

---

Nitpick comments:
In `@tests/test_sync_repo_master.bats`:
- Around line 34-37: The three `@test` blocks in tests/test_sync_repo_master.bats
are using manual set +e / set -e to capture exit status; replace that pattern
with bats’ built-in run helper so the command output and exit code are captured
idiomatically without toggling errexit. Update the sync_repo_master call in each
test to use run, then assert against the special bats variables ($status and any
relevant output) in the existing test flow, keeping the same behavior across all
three blocks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4af683a3-7c10-40f6-8ee4-649c7d27f68b

📥 Commits

Reviewing files that changed from the base of the PR and between 3168b65 and 11c6cf5.

📒 Files selected for processing (7)
  • .github/workflows/lint.yml
  • tests/helpers/http_mock.bash
  • tests/helpers/test_helper.bash
  • tests/test_add_one_submodule.bats
  • tests/test_sync_repo_master.bats
  • tests/test_translations_submodule.bats
  • tests/test_trigger_weblate.bats

Comment thread tests/helpers/http_mock.bash
Comment thread tests/test_trigger_weblate.bats Outdated
@whisper67265 whisper67265 requested a review from henry0816191 July 1, 2026 20:34
@whisper67265 whisper67265 requested a review from wpak-ai July 2, 2026 17:50
@wpak-ai wpak-ai merged commit ac0c38f into cppalliance:master Jul 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test presence: add bats coverage for add-submodules, sync_repo_master, Weblate POST

3 participants