Skip to content

fix: propagate RUN_ONCE exit status and align behave suite - #97

Merged
acolomba merged 5 commits into
mainfrom
features/behave-guidelines-compliance
Oct 2, 2026
Merged

acolomba merged 5 commits into
mainfrom
features/behave-guidelines-compliance

Conversation

@acolomba

@acolomba acolomba commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Rework the behave suite so it follows
skills/behave-behavioral-testing/SKILL.md, and fix the exit status of the
Docker image. Each review and each fix of the suite ran in a separate agent.
The loop stopped when a fresh review found no major problems.

With RUN_ONCE set, entrypoint.sh always exited 0, because the script
ended with an if statement without else. A failed sync looked like a
success to whatever started the container, and in docker mode no behave
check of the exit code could fail. The script now keeps the sync status and
exits with it. Cron mode is unchanged: crond starts after the first sync,
whatever its result.

Several checks could pass without testing anything. Three destination checks
returned early when a setup step was missing, and most checks tested only a
subset of the files. All checks now compare the whole set of files in the
destination, or the whole set of requests that the fake dashcam received. A
failed check prints the missing and the unexpected files. The exit code check
prints the output of blackvuesync.

Step modules are now grouped by function: blackvuesync runs, the dashcam, the
destination, and general checks. One step, blackvuesync runs with ...,
replaces six. The Gherkin uses the active voice, and each feature has a short
description.

The fake dashcam listens on a random port on 127.0.0.1 and shuts down at the
end of the run. It records the files that blackvuesync requests. A scenario
can make it fail a download or the recording list. Cleanup goes through
context.add_cleanup. When a scenario fails, the run keeps only the directory
of that scenario, with its destination and a log of each blackvuesync run.

New scenarios cover a failed recording list (exit code 2), daily and weekly
grouping, leftover partial downloads, and a destination that already has some
of the dashcam recordings. A step that backdates the failure markers replaces
a 2-second sleep.

The suite now requires behave 1.3.3, the latest release. It uses tag
expressions v2 (not @ignore) and active tags (@use.with_protocol=legacy)
in place of the hand-written skips. Fixtures, the Rule keyword, and
cucumber expressions did not make this suite simpler, so the suite does not
use them. mypy now ignores the missing behave stubs, so local runs match the
pre-commit hook.

The unit-test and behave guidelines now prefer PyHamcrest's assert_that()
with a matcher to state the condition of an assertion. The behave steps use
equal_to() for every whole-value comparison, and pass the set differences
and the output of blackvuesync as the reason. The change also removes the
CLAUDE.md files that only imported AGENTS.md.

Validation: scripts/check.sh passed, with 71.51% unit test coverage. The
behave results are 27 passed and 1 skipped for the current protocol, and 28
passed for the legacy protocol. Docker mode gives the same results, and the
listing error scenario runs there too. The coverage runs passed. A direct run
on Python 3.9 passed. All pre-commit hooks passed. The package version
remains 2.2.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XhzDTTf8Wj1sNRHqJdHcUz

acolomba and others added 2 commits October 2, 2026 03:34
Rework the behave suite to follow skills/behave-behavioral-testing:

- compare whole file and request sets, with observed values in failure
  messages; remove guards that let assertions pass vacuously
- group step modules by function and share helpers in features/lib
- rewrite Gherkin in the active voice with feature descriptions
- run the fake dashcam on an ephemeral loopback port with a real
  shutdown; record requests and arm download and listing failures
- own fixture lifetimes through context.add_cleanup and keep only
  failed scenarios' directories and run logs
- add scenarios for listing errors, grouping, partial downloads, and
  syncing against a partially populated destination

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhzDTTf8Wj1sNRHqJdHcUz
entrypoint.sh ended with an if statement without else, so a RUN_ONCE
container always exited 0. The script now keeps the sync status and
exits with it. Cron mode is unchanged and still starts crond after the
first sync.

With exit codes visible in docker mode, the listing-error scenario runs
there too. The behave suite now requires behave 1.3.3: it uses tag
expressions v2 and active tags (@use.with_protocol=legacy) in place of
the hand-written skips. mypy ignores the missing behave stubs, so local
runs match the pre-commit hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhzDTTf8Wj1sNRHqJdHcUz
@acolomba acolomba changed the title test: align behave suite with the behavioral testing guidelines fix: propagate RUN_ONCE exit status and align behave suite Oct 2, 2026
acolomba and others added 3 commits October 2, 2026 09:23
Delete the root and features/ CLAUDE.md files, which only imported
AGENTS.md, and drop a comment in entrypoint.sh that restated the code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhzDTTf8Wj1sNRHqJdHcUz
Make PyHamcrest's assert_that() the preferred way to state conditions in
the unit-test authoring and review skills and in the behave skill. A
plain assert remains for a condition that no matcher states, and
matchers that pass for a partial value do not satisfy the whole-value
rule.

Restore hamcrest in the behave steps, which an earlier rework had
switched to plain assert. The whole-value comparisons stay, with the
set differences and the run output passed as the reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhzDTTf8Wj1sNRHqJdHcUz
Reword the step that compares downloaded files with the "mock fixture"
to say that they match the files on the dashcam, and describe the
partial download as a truncated dashcam video.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XhzDTTf8Wj1sNRHqJdHcUz
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

@acolomba
acolomba merged commit 0b45ef7 into main Oct 2, 2026
7 checks passed
@acolomba
acolomba deleted the features/behave-guidelines-compliance branch October 2, 2026 14:35
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.

1 participant