Skip to content

Add an ERT test suite and run it in CI - #66

Merged
zonuexe merged 1 commit into
masterfrom
test/add-ert-suite
Jul 17, 2026
Merged

Add an ERT test suite and run it in CI#66
zonuexe merged 1 commit into
masterfrom
test/add-ert-suite

Conversation

@zonuexe

@zonuexe zonuexe commented Jul 17, 2026

Copy link
Copy Markdown
Member

Adds the package's first automated tests and runs them in CI.

Why

There were no tests: the Eask test script was a placeholder that only errored, and CI ran make all, which compiles but executes nothing. Every bug fixed in the recent PRs (#62#65) — a destructive nconc growing phpstan-executable, the (STRING . (ARGS...)) form dropping the command name, the version probe reading docker --version instead of PHPStan, the parse fallback silently discarding failures — was invisible on inspection and only surfaced when the code ran. That is exactly what a test suite should catch.

What

  • test/phpstan-test.el — container detection (phpstan--container-runtime-command / -executable-p), version parsing (phpstan--version-from-output), editor-mode gating (through the version cache, so it never shells out), path normalization, and phpstan-get-command-args: that it keeps the command name for the (STRING . (ARGS...)) form, does not mutate phpstan-executable or the caller's :options, and rewrites the config path to the container mount point. Project and filesystem access is stubbed with cl-letf, so the tests are hermetic.
  • test/flycheck-phpstan-test.el — that the JSON report is found even when a container runtime prefixes it with progress on STDERR, and that a no-JSON failure is surfaced as a warning instead of dropped.

Each test was verified to fail when its bug is reintroduced (e.g. swapping append back to nconc fails the two mutation tests; reverting the JSON detection to string-prefix-p fails the stderr-prefix test), so they pin behaviour rather than merely describe it.

Wiring

make all now runs eask test ert after compiling, so the existing CI — which already calls make all — runs the suite on all nine matrix jobs with no workflow change, including the Emacs 27.2 job through Eask.27. The local .github/run-emacs-27-2.sh helper runs the tests too. Eask gains a test script (eask run script test); Eask.27 is kept in sync.

Verification

13/13 pass on system Emacs and on Emacs 27.2 (via nix-emacs-ci, MELPA Stable deps). make all runs compile + test cleanly.

This package had no automated tests -- the Eask `test' script was a
placeholder that only errored -- and CI ran `make all', which compiles
but never executes anything.  Every bug fixed recently (a destructive
`nconc', a dropped command name, a version probe that read the launcher
instead of PHPStan, a swallowed parse fallback) was invisible on
inspection and only showed up when the code ran, so it is exactly the
kind of thing a test suite should pin down.

The tests cover the pure and stubbable functions where those bugs lived:

  * test/phpstan-test.el -- container detection, version parsing, editor
    mode gating (through the version cache, so it does not shell out),
    path normalization, and `phpstan-get-command-args' (that it keeps the
    command name for the `(STRING . (ARGS...))' form, does not mutate
    `phpstan-executable' or `:options', and rewrites the config path for
    a container).  Project and filesystem access is stubbed with
    `cl-letf', so the tests are hermetic.

  * test/flycheck-phpstan-test.el -- that the JSON report is found even
    when a container runtime prefixes it with progress on STDERR, and
    that a no-JSON failure is surfaced as a warning rather than dropped.

Each test was checked to fail when its bug is reintroduced, so they
verify behaviour rather than merely describe it.

`make all' now runs `eask test ert' after compiling, so the existing
CI (which calls `make all') exercises the suite on every matrix job,
including the Emacs 27.2 one via Eask.27.  The 27.2 helper script runs
the tests too.  `Eask' gains a `test' script for `eask run script test';
`Eask.27' is kept in sync.
@zonuexe
zonuexe force-pushed the test/add-ert-suite branch from 5e91ff2 to a634fd0 Compare July 17, 2026 16:03
@zonuexe
zonuexe merged commit 04a0c39 into master Jul 17, 2026
9 checks passed
@zonuexe
zonuexe deleted the test/add-ert-suite branch July 17, 2026 16:12
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