Skip to content

test: add a functional test suite - #1

Open
amineau wants to merge 1 commit into
developfrom
claude/tests-8m4ax9
Open

test: add a functional test suite#1
amineau wants to merge 1 commit into
developfrom
claude/tests-8m4ax9

Conversation

@amineau

@amineau amineau commented Aug 2, 2026

Copy link
Copy Markdown
Owner

The project had no tests, which made any change to the protocol handling a
matter of trusting a manual session. This adds a suite that starts a real
server against a fixture root and drives it over a socket, plus end-to-end
cases through the client binary. Run it with make test.

Driving the protocol directly rather than through ./client is what lets the
suite send deliberately malformed input and assert on exact reply codes; the
client exits on the first unexpected reply, so it cannot express those cases.

Cases covering behaviour the server does not have yet are marked as expected
failures rather than left out. They run on every invocation and document the
intended behaviour, and fixing the code reports them as unexpected successes,
which fails the run and prompts removing the marker.

Three defects surfaced while writing this and are encoded as expected
failures:

  • The working directory leaks between sessions. Workers chdir() the process
    and never reset, so a client can start in whatever directory the previous
    one left behind. Which directory depends on which worker accepts the
    connection, so the symptom is intermittent.
  • ft_indexof cannot report "not found": it returns -1 only for a NULL
    haystack, and otherwise reads past the end of the array until it meets a
    matching byte. TYPE, MODE and STRU accept junk arguments as a result.
  • TYPE, MODE and STRU dereference their argument without checking it, so a
    bare verb kills the worker handling the connection.

The harness pins the working directory when opening a connection so that the
first of these does not make execution order significant; a dedicated case
covers the defect itself.

The project had no tests, which made any change to the protocol handling a
matter of trusting a manual session. This adds a suite that starts a real
server against a fixture root and drives it over a socket, plus end-to-end
cases through the client binary. Run it with `make test`.

Driving the protocol directly rather than through ./client is what lets the
suite send deliberately malformed input and assert on exact reply codes; the
client exits on the first unexpected reply, so it cannot express those cases.

Cases covering behaviour the server does not have yet are marked as expected
failures rather than left out. They run on every invocation and document the
intended behaviour, and fixing the code reports them as unexpected successes,
which fails the run and prompts removing the marker.

Four defects surfaced while writing this and are encoded as expected
failures:

- A rejected password does not end the session. The credentials are checked
  and refused, but the outcome is never recorded, so the next command is
  served as though the login had succeeded.
- The working directory leaks between sessions. Workers chdir() the process
  and never reset, so a client can start in whatever directory the previous
  one left behind. Which directory depends on which worker accepts the
  connection, so the symptom is intermittent.
- ft_indexof cannot report "not found": it returns -1 only for a NULL
  haystack, and otherwise reads past the end of the array until it meets a
  matching byte. TYPE, MODE and STRU accept junk arguments as a result.
- TYPE, MODE and STRU dereference their argument without checking it, so a
  bare verb kills the worker handling the connection.

The harness pins the working directory when opening a connection so that the
second of these does not make execution order significant; a dedicated case
covers the defect itself.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWMoXxqX1CdGZ7FKW5bsk7
@amineau
amineau force-pushed the claude/tests-8m4ax9 branch from a8a7dc7 to 896c870 Compare August 2, 2026 14:54
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.

2 participants