<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ci on Ryan's Ghost</title><link>https://ryansghost.github.io/tags/ci/</link><description>Recent content in ci on Ryan's Ghost</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Fri, 30 Oct 2026 15:27:27 +0000</lastBuildDate><atom:link href="https://ryansghost.github.io/tags/ci/index.xml" rel="self" type="application/rss+xml"/><item><title>Testing Emacs Lisp with ERT: A Field Manual</title><link>https://ryansghost.github.io/posts/2026-10-30-testing-emacs-lisp-with-ert/</link><pubDate>Fri, 30 Oct 2026 15:27:27 +0000</pubDate><guid>https://ryansghost.github.io/posts/2026-10-30-testing-emacs-lisp-with-ert/</guid><description>&lt;p&gt;This manual covers what you need to write excellent unit tests for Emacs Lisp, and a CI pipeline that catches problems before your users do. Its running example is &lt;a href="https://github.com/RyansGhost/rcf-sword"&gt;RyansGhost/rcf-sword&lt;/a&gt; 0.3.0 (commit &lt;a href="https://github.com/RyansGhost/rcf-sword/commit/3b42ff236bc7ca538be78789d044e635460f168c"&gt;&lt;code&gt;3b42ff2&lt;/code&gt;&lt;/a&gt;). That&amp;rsquo;s a package with 53 ERT tests and a three-job GitHub Actions workflow. Every command and every piece of output below was run for real on GNU Emacs 29.3, and claims about tools are footnoted.&lt;/p&gt;
&lt;nav class="toc" aria-label="Contents"&gt;
 &lt;details open&gt;
 &lt;summary class="toc__title"&gt;Contents&lt;/summary&gt;
 &lt;ul&gt;
 &lt;li&gt;&lt;a href="#ert-in-one-minute"&gt;ERT in one minute&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#writing-tests-that-hold-up"&gt;Writing tests that hold up&lt;/a&gt;
 &lt;ul&gt;
 &lt;li&gt;&lt;a href="#set-up-the-file-properly"&gt;Set up the file properly&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#make-pure-functions-and-test-them-with-tables"&gt;Make pure functions, and test them with tables&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#build-fixtures-from-functions-and-macros"&gt;Build fixtures from functions and macros&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#leave-the-environment-as-you-found-it"&gt;Leave the environment as you found it&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#stub-the-prompts-not-the-logic"&gt;Stub the prompts, not the logic&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#pass-in-the-clock"&gt;Pass in the clock&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#test-randomness-by-its-distribution"&gt;Test randomness by its distribution&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#test-through-the-keys-people-press"&gt;Test through the keys people press&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#check-that-related-pieces-agree"&gt;Check that related pieces agree&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#skip-what-cant-run-rather-than-fail"&gt;Skip what can&amp;rsquo;t run, rather than fail&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#test-the-packages-promises-in-a-fresh-emacs"&gt;Test the package&amp;rsquo;s promises in a fresh Emacs&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#check-error-messages-word-for-word-and-mind-the-locale"&gt;Check error messages word for word, and mind the locale&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;
 &lt;/li&gt;
 &lt;li&gt;&lt;a href="#when-a-test-fails"&gt;When a test fails&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#running-tests"&gt;Running tests&lt;/a&gt;
 &lt;ul&gt;
 &lt;li&gt;&lt;a href="#interactively"&gt;Interactively&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#in-batch-mode"&gt;In batch mode&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#tools-that-wrap-ert"&gt;Tools that wrap ERT&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;
 &lt;/li&gt;
 &lt;li&gt;&lt;a href="#a-robust-ci-pipeline"&gt;A robust CI pipeline&lt;/a&gt;
 &lt;ul&gt;
 &lt;li&gt;&lt;a href="#the-pipeline"&gt;The pipeline&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#what-makes-it-robust"&gt;What makes it robust&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#add-a-junit-report"&gt;Add a JUnit report&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#gitlab-ci"&gt;GitLab CI&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;
 &lt;/li&gt;
 &lt;li&gt;&lt;a href="#checklist"&gt;Checklist&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;
 &lt;/details&gt;
&lt;/nav&gt;
&lt;h2 id="ert-in-one-minute"&gt;ERT in one minute&lt;/h2&gt;
&lt;p&gt;ERT, &lt;em&gt;Emacs Lisp Regression Testing&lt;/em&gt;, was written by Christian Ohler and has shipped with Emacs since Emacs 24.&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;sup id="fnref:2"&gt;&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref"&gt;2&lt;/a&gt;&lt;/sup&gt; &amp;ldquo;Tests are simply Lisp code: code that invokes other code and checks whether it behaves as expected.&amp;rdquo;&lt;sup id="fnref:3"&gt;&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref"&gt;3&lt;/a&gt;&lt;/sup&gt; You define a test with &lt;code&gt;ert-deftest&lt;/code&gt;, and check results with three macros:&lt;/p&gt;</description></item></channel></rss>