What's this cmdtest thing?

Zig library to test CLI apps without the boilerplate. It handles process spawning, I/O capture, and exit codes so you can just write tests.

cmdtest is a smol Zig library I wrote to test command-line apps.

I build a lot of minimal CLI tools for my own need, and testing them was always a bit of a pain. You have to spawn the process, capture stdout and stderr, check the exit code, and handle all the boilerplate. I got tired of writing that code over and over.

So I made cmdtest to handle all of that for me. My goal was to make it super simple and easy to use. I didn’t want to think about process management, I just wanted to check if my CLI tool did the right thing.

The whole library is basically two functions:

  1. add(options): You use this in your build.zig to tell it where your test file is.
  2. run(options): You use this in your test file to run a command and check its output.

That’s it. It’s small, focused, and it just works.

Table of Contents